This commit is contained in:
2026-04-30 01:04:06 +02:00
parent 2903ea2517
commit 2639242ca6
21 changed files with 1989 additions and 116 deletions

View File

@@ -319,10 +319,10 @@ class Products
}
$offer_id = trim( (string) ( $row['offer_id'] ?? '' ) );
$product_name = trim( (string) ( $row['title'] ?? '' ) );
$product_name = trim( (string) ( $row['title_gmc'] ?? '' ) );
if ( $product_name === '' )
{
$product_name = trim( (string) ( $row['name'] ?? '' ) );
$product_name = trim( (string) ( $row['title'] ?? '' ) );
}
if ( $product_name === '' )
{
@@ -697,8 +697,8 @@ class Products
$product_id = \S::get( 'product_id' );
$product_name = \factory\Products::get_product_name( $product_id );
$product_title = \factory\Products::get_product_data( $product_id, 'title' );
$product_description = \factory\Products::get_product_data( $product_id, 'description' );
$product_title = \factory\Products::get_product_data( $product_id, 'title_gmc' );
$product_description = \factory\Products::get_product_data( $product_id, 'description_gmc' );
$google_product_category = \factory\Products::get_product_data( $product_id, 'google_product_category' );
$product_url = \factory\Products::get_product_data( $product_id, 'product_url' );
@@ -854,9 +854,9 @@ class Products
}
$context = [
'original_name' => $product['name'],
'current_title' => \factory\Products::get_product_data( $product_id, 'title' ),
'current_description' => \factory\Products::get_product_data( $product_id, 'description' ),
'original_name' => $product['title'],
'current_title' => \factory\Products::get_product_data( $product_id, 'title_gmc' ),
'current_description' => \factory\Products::get_product_data( $product_id, 'description_gmc' ),
'current_category' => \factory\Products::get_product_data( $product_id, 'google_product_category' ),
'offer_id' => $product['offer_id'],
'impressions_30' => $product['impressions_30'] ?? 0,
@@ -986,7 +986,7 @@ class Products
$custom_class = '';
$custom_label_4 = \factory\Products::get_product_data( $product_id, 'custom_label_4' );
$custom_label_1 = \factory\Products::get_product_data( $product_id, 'custom_label_1' );
$custom_name = \factory\Products::get_product_data( $product_id, 'title' );
$custom_name = \factory\Products::get_product_data( $product_id, 'title_gmc' );
$product_url = trim( (string) \factory\Products::get_product_data( $product_id, 'product_url' ) );
if ( $custom_name )
@@ -1095,6 +1095,9 @@ class Products
foreach ( $breakdown_rows as $breakdown_row )
{
$breakdown_for_view[] = [
'product_id' => (int) ( $breakdown_row['product_id'] ?? $product_id ),
'campaign_id' => (int) ( $breakdown_row['campaign_id'] ?? 0 ),
'ad_group_id' => (int) ( $breakdown_row['ad_group_id'] ?? 0 ),
'campaign_name' => (string) ( $breakdown_row['campaign_name'] ?? '' ),
'ad_group_name' => (string) ( $breakdown_row['ad_group_name'] ?? '' ),
'impressions' => (int) ( $breakdown_row['impressions'] ?? 0 ),
@@ -1185,6 +1188,29 @@ class Products
exit;
}
static public function delete_product_scope_history()
{
$product_id = (int) \S::get( 'product_id' );
$campaign_id = (int) \S::get( 'campaign_id' );
$ad_group_id = (int) \S::get( 'ad_group_id' );
if ( $product_id <= 0 )
{
echo json_encode( [ 'status' => 'error', 'message' => 'Brak identyfikatora produktu.' ] );
exit;
}
if ( \factory\Products::delete_product_scope_history( $product_id, $campaign_id, $ad_group_id ) )
{
echo json_encode( [ 'status' => 'ok' ] );
}
else
{
echo json_encode( [ 'status' => 'error', 'message' => 'Nie udalo sie usunac wpisow historii dla tego zakresu.' ] );
}
exit;
}
static public function save_min_roas()
{
$product_id = \S::get( 'product_id' );
@@ -1390,8 +1416,8 @@ class Products
$google_product_category = \S::get( 'google_product_category' );
$product_url = \S::get( 'product_url' );
$old_title = (string) \factory\Products::get_product_data( $product_id, 'title' );
$old_description = (string) \factory\Products::get_product_data( $product_id, 'description' );
$old_title = (string) \factory\Products::get_product_data( $product_id, 'title_gmc' );
$old_description = (string) \factory\Products::get_product_data( $product_id, 'description_gmc' );
$old_category = (string) \factory\Products::get_product_data( $product_id, 'google_product_category' );
$changed_for_merchant = [];
@@ -1400,13 +1426,13 @@ class Products
{
if ( $custom_title )
{
\factory\Products::set_product_data( $product_id, 'title', $custom_title );
\factory\Products::set_product_data( $product_id, 'title_gmc', $custom_title );
$changed_for_merchant['title'] = [ 'old' => $old_title, 'new' => (string) $custom_title ];
}
if ( $custom_description )
{
\factory\Products::set_product_data( $product_id, 'description', $custom_description );
\factory\Products::set_product_data( $product_id, 'description_gmc', $custom_description );
$changed_for_merchant['description'] = [ 'old' => $old_description, 'new' => (string) $custom_description ];
}