Add CL3 support to products list and supplemental feed

This commit is contained in:
2026-03-17 00:39:08 +01:00
parent b071d02578
commit ad24195cdd
4 changed files with 11 additions and 7 deletions

View File

@@ -1083,7 +1083,7 @@ class Products
\S::number_display( $row['conversions_value'] ),
$roasCellHtml,
'<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 . '">',
'<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>'

View File

@@ -497,6 +497,7 @@ class Products
'campaign_name' => 'campaign_name',
'ad_group_name' => 'ad_group_name',
'name' => 'name',
'custom_label_3' => 'custom_label_3',
'impressions' => 'impressions',
'impressions_30' => 'impressions_30',
'clicks' => 'clicks',
@@ -517,6 +518,7 @@ class Products
p.id AS product_id,
p.offer_id,
p.min_roas,
COALESCE( NULLIF( TRIM( p.custom_label_3 ), \'\' ), \'\' ) AS custom_label_3,
CASE
WHEN COUNT( DISTINCT pa.campaign_id ) = 1 THEN MAX( pa.campaign_id )
ELSE 0
@@ -581,7 +583,7 @@ class Products
$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;
return $mdb -> query( $sql, $params ) -> fetchAll( \PDO::FETCH_ASSOC );

View File

@@ -163,12 +163,12 @@ class SupplementalFeed
$labels_updated = self::refresh_bestseller_labels_for_client( $client_id );
$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
WHERE p.client_id = :client_id
AND p.offer_id IS NOT NULL
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 ]
) -> fetchAll( \PDO::FETCH_ASSOC );
@@ -187,7 +187,7 @@ class SupplementalFeed
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;
foreach ( $products as $row )
@@ -196,9 +196,10 @@ class SupplementalFeed
$title = self::sanitize_for_tsv( $row['title'] ?? '' );
$description = self::sanitize_for_tsv( $row['description'] ?? '' );
$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'] ?? '' ) );
if ( $offer_id === '' || ( $title === '' && $description === '' && $category === '' && $custom_label_4 === '' ) )
if ( $offer_id === '' || ( $title === '' && $description === '' && $category === '' && $custom_label_3 === '' && $custom_label_4 === '' ) )
{
continue;
}
@@ -208,6 +209,7 @@ class SupplementalFeed
$title,
$description,
$category,
$custom_label_3,
$custom_label_4
] ) . "\n" );

View File

@@ -487,7 +487,7 @@ $( function()
{ width: '90px', name: 'conversions_value', className: "dt-type-numeric" },
{ width: '60px', name: 'roas' },
{ width: '70px', name: 'min_roas' },
{ width: '50px', name: 'cl3', orderable: false },
{ width: '50px', name: 'custom_label_3' },
{ width: '120px', orderable: false },
{ width: '190px', orderable: false, className: 'dt-center' }
],