Add CL3 support to products list and supplemental feed
This commit is contained in:
@@ -1083,7 +1083,7 @@ class Products
|
|||||||
\S::number_display( $row['conversions_value'] ),
|
\S::number_display( $row['conversions_value'] ),
|
||||||
$roasCellHtml,
|
$roasCellHtml,
|
||||||
'<input type="text" class="form-control min_roas" product_id="' . $row['product_id'] . '" value="' . $row['min_roas'] . '" style="width: 100px;">',
|
'<input type="text" class="form-control min_roas" product_id="' . $row['product_id'] . '" value="' . $row['min_roas'] . '" style="width: 100px;">',
|
||||||
'',
|
htmlspecialchars( (string) ( $row['custom_label_3'] ?? '' ) ),
|
||||||
'<input type="text" class="form-control custom_label_4" product_id="' . $row['product_id'] . '" value="' . $custom_label_4 . '" style="' . $custom_label_4_color . '">',
|
'<input type="text" class="form-control custom_label_4" product_id="' . $row['product_id'] . '" value="' . $custom_label_4 . '" style="' . $custom_label_4_color . '">',
|
||||||
'<div class="btn-group btn-group-sm products-row-actions" role="group">'
|
'<div class="btn-group btn-group-sm products-row-actions" role="group">'
|
||||||
. '<button type="button" class="btn btn-primary assign-product-scope" product_id="' . $row['product_id'] . '" title="Dodaj produkt do kampanii/grupy"><i class="fa-solid fa-diagram-project"></i></button>'
|
. '<button type="button" class="btn btn-primary assign-product-scope" product_id="' . $row['product_id'] . '" title="Dodaj produkt do kampanii/grupy"><i class="fa-solid fa-diagram-project"></i></button>'
|
||||||
|
|||||||
@@ -497,6 +497,7 @@ class Products
|
|||||||
'campaign_name' => 'campaign_name',
|
'campaign_name' => 'campaign_name',
|
||||||
'ad_group_name' => 'ad_group_name',
|
'ad_group_name' => 'ad_group_name',
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
|
'custom_label_3' => 'custom_label_3',
|
||||||
'impressions' => 'impressions',
|
'impressions' => 'impressions',
|
||||||
'impressions_30' => 'impressions_30',
|
'impressions_30' => 'impressions_30',
|
||||||
'clicks' => 'clicks',
|
'clicks' => 'clicks',
|
||||||
@@ -517,6 +518,7 @@ class Products
|
|||||||
p.id AS product_id,
|
p.id AS product_id,
|
||||||
p.offer_id,
|
p.offer_id,
|
||||||
p.min_roas,
|
p.min_roas,
|
||||||
|
COALESCE( NULLIF( TRIM( p.custom_label_3 ), \'\' ), \'\' ) AS custom_label_3,
|
||||||
CASE
|
CASE
|
||||||
WHEN COUNT( DISTINCT pa.campaign_id ) = 1 THEN MAX( pa.campaign_id )
|
WHEN COUNT( DISTINCT pa.campaign_id ) = 1 THEN MAX( pa.campaign_id )
|
||||||
ELSE 0
|
ELSE 0
|
||||||
@@ -581,7 +583,7 @@ class Products
|
|||||||
$params[':custom_label_4'] = '%' . $custom_label_4 . '%';
|
$params[':custom_label_4'] = '%' . $custom_label_4 . '%';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql .= ' GROUP BY p.id, p.offer_id, p.min_roas, p.name, p.title';
|
$sql .= ' GROUP BY p.id, p.offer_id, p.min_roas, p.custom_label_3, p.name, p.title';
|
||||||
$sql .= ' ORDER BY ' . $order_sql . ' ' . $order_dir . ', product_id DESC LIMIT ' . $start . ', ' . $limit;
|
$sql .= ' ORDER BY ' . $order_sql . ' ' . $order_dir . ', product_id DESC LIMIT ' . $start . ', ' . $limit;
|
||||||
|
|
||||||
return $mdb -> query( $sql, $params ) -> fetchAll( \PDO::FETCH_ASSOC );
|
return $mdb -> query( $sql, $params ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||||
|
|||||||
@@ -163,12 +163,12 @@ class SupplementalFeed
|
|||||||
$labels_updated = self::refresh_bestseller_labels_for_client( $client_id );
|
$labels_updated = self::refresh_bestseller_labels_for_client( $client_id );
|
||||||
|
|
||||||
$products = $mdb -> query(
|
$products = $mdb -> query(
|
||||||
"SELECT p.offer_id, p.title, p.description, p.google_product_category, p.custom_label_4
|
"SELECT p.offer_id, p.title, p.description, p.google_product_category, p.custom_label_3, p.custom_label_4
|
||||||
FROM products p
|
FROM products p
|
||||||
WHERE p.client_id = :client_id
|
WHERE p.client_id = :client_id
|
||||||
AND p.offer_id IS NOT NULL
|
AND p.offer_id IS NOT NULL
|
||||||
AND p.offer_id <> ''
|
AND p.offer_id <> ''
|
||||||
AND ( p.title IS NOT NULL OR p.description IS NOT NULL OR p.google_product_category IS NOT NULL OR p.custom_label_4 IS NOT NULL )",
|
AND ( p.title IS NOT NULL OR p.description IS NOT NULL OR p.google_product_category IS NOT NULL OR p.custom_label_3 IS NOT NULL OR p.custom_label_4 IS NOT NULL )",
|
||||||
[ ':client_id' => $client_id ]
|
[ ':client_id' => $client_id ]
|
||||||
) -> fetchAll( \PDO::FETCH_ASSOC );
|
) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ class SupplementalFeed
|
|||||||
throw new \RuntimeException( 'Nie mozna otworzyc pliku: ' . $file_path );
|
throw new \RuntimeException( 'Nie mozna otworzyc pliku: ' . $file_path );
|
||||||
}
|
}
|
||||||
|
|
||||||
fwrite( $fp, "id\ttitle\tdescription\tgoogle_product_category\tcustom_label_4\n" );
|
fwrite( $fp, "id\ttitle\tdescription\tgoogle_product_category\tcustom_label_3\tcustom_label_4\n" );
|
||||||
|
|
||||||
$written = 0;
|
$written = 0;
|
||||||
foreach ( $products as $row )
|
foreach ( $products as $row )
|
||||||
@@ -196,9 +196,10 @@ class SupplementalFeed
|
|||||||
$title = self::sanitize_for_tsv( $row['title'] ?? '' );
|
$title = self::sanitize_for_tsv( $row['title'] ?? '' );
|
||||||
$description = self::sanitize_for_tsv( $row['description'] ?? '' );
|
$description = self::sanitize_for_tsv( $row['description'] ?? '' );
|
||||||
$category = trim( (string) ( $row['google_product_category'] ?? '' ) );
|
$category = trim( (string) ( $row['google_product_category'] ?? '' ) );
|
||||||
|
$custom_label_3 = trim( (string) ( $row['custom_label_3'] ?? '' ) );
|
||||||
$custom_label_4 = trim( (string) ( $row['custom_label_4'] ?? '' ) );
|
$custom_label_4 = trim( (string) ( $row['custom_label_4'] ?? '' ) );
|
||||||
|
|
||||||
if ( $offer_id === '' || ( $title === '' && $description === '' && $category === '' && $custom_label_4 === '' ) )
|
if ( $offer_id === '' || ( $title === '' && $description === '' && $category === '' && $custom_label_3 === '' && $custom_label_4 === '' ) )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -208,6 +209,7 @@ class SupplementalFeed
|
|||||||
$title,
|
$title,
|
||||||
$description,
|
$description,
|
||||||
$category,
|
$category,
|
||||||
|
$custom_label_3,
|
||||||
$custom_label_4
|
$custom_label_4
|
||||||
] ) . "\n" );
|
] ) . "\n" );
|
||||||
|
|
||||||
|
|||||||
@@ -487,7 +487,7 @@ $( function()
|
|||||||
{ width: '90px', name: 'conversions_value', className: "dt-type-numeric" },
|
{ width: '90px', name: 'conversions_value', className: "dt-type-numeric" },
|
||||||
{ width: '60px', name: 'roas' },
|
{ width: '60px', name: 'roas' },
|
||||||
{ width: '70px', name: 'min_roas' },
|
{ width: '70px', name: 'min_roas' },
|
||||||
{ width: '50px', name: 'cl3', orderable: false },
|
{ width: '50px', name: 'custom_label_3' },
|
||||||
{ width: '120px', orderable: false },
|
{ width: '120px', orderable: false },
|
||||||
{ width: '190px', orderable: false, className: 'dt-center' }
|
{ width: '190px', orderable: false, className: 'dt-center' }
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user