Skip to content

Commit

Permalink
gid is now stable and unique
Browse files Browse the repository at this point in the history
This changes is required, to make the id stable and unique for each product. Any history you might have in your merchant center feed or anywhere else might be lost, since the ID in the feed for each product will change!

This change is required to make it possible to use the feed for remarketing.

https://support.google.com/merchants/answer/6324405
  • Loading branch information
Casper-O committed Oct 16, 2018
1 parent 526b402 commit 35f0b2e
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions gshoppingflux/gshoppingflux.php
Original file line number Diff line number Diff line change
Expand Up @@ -2200,15 +2200,7 @@ private function generateFile($lang, $id_curr, $id_shop)
if ($this->module_conf['export_attributes'] == 1) {
$attributesResume = $p->getAttributesResume($id_lang);
}

if ($this->module_conf['mpn_type'] == 'reference' && !empty($product['reference'])) {
$product['pid'] = $product['reference'];
} elseif ($this->module_conf['mpn_type'] == 'supplier_reference' && !empty($product['supplier_reference'])) {
$product['pid'] = $product['supplier_reference'];
} else {
$product['pid'] = $product['id_product'];
}
$product['gid'] = $product['pid'];
$product['gid'] = $product['id_product'];
$product['color'] = '';
$product['material'] = '';
$product['pattern'] = '';
Expand All @@ -2217,6 +2209,7 @@ private function generateFile($lang, $id_curr, $id_shop)
$original_product = $product;
$categories_value = $this->categories_values[$product['id_gcategory']];
$combinum = 0;

foreach ($attributesResume as $productCombination) {
$product = $original_product;
$attributes = $p->getAttributeCombinationsById($productCombination['id_product_attribute'], $id_lang);
Expand All @@ -2240,8 +2233,8 @@ private function generateFile($lang, $id_curr, $id_shop)
$product['upc'] = (!empty($a['upc']) ? $a['upc'] : $product['upc']);
$product['supplier_reference'] = (!empty($a['supplier_reference']) ? $a['supplier_reference'] : $product['supplier_reference']);
$product['weight'] += $a['weight'];
$product['item_group_id'] = $product['pid'];
$product['gid'] = $product['pid'].'-'.$combinum;
$product['item_group_id'] = $product['id_product'];
$product['gid'] = $product['id_product'].'-'.$productCombination['id_product_attribute'];
$xml_googleshopping = $this->getItemXML($product, $lang, $id_curr, $id_shop, $productCombination['id_product_attribute']);
fwrite($googleshoppingfile, $xml_googleshopping);
}
Expand Down

0 comments on commit 35f0b2e

Please sign in to comment.