2121namespace PrestaShop \Module \Ps_Googleanalytics \Wrapper ;
2222
2323use Configuration ;
24- use Db ;
2524use Context ;
25+ use Db ;
26+ use Manufacturer ;
2627use PrestaShop \PrestaShop \Adapter \Presenter \Product \ProductLazyArray ;
2728use PrestaShop \PrestaShop \Adapter \Presenter \Product \ProductListingLazyArray ;
2829use Product ;
@@ -80,7 +81,7 @@ public function prepareItemListFromProductList($productList, $useProvidedQuantit
8081 * @return array Item data standardized for GA
8182 */
8283 public function prepareItemFromProduct ($ product , $ useProvidedQuantity = false )
83- {
84+ {
8485 // Standardize product ID
8586 $ product_id = 0 ;
8687 if (!empty ($ product ['id_product ' ])) {
@@ -89,7 +90,7 @@ public function prepareItemFromProduct($product, $useProvidedQuantity = false)
8990 $ product_id = $ product ['id ' ];
9091 }
9192
92- // Standardize product price
93+ // Standardize product price, make sure this price went through calculation before you pass it here
9394 if (empty ($ product ['price_amount ' ])) {
9495 $ product ['price_amount ' ] = $ product ['price ' ];
9596 }
@@ -107,7 +108,7 @@ public function prepareItemFromProduct($product, $useProvidedQuantity = false)
107108 if (!empty ($ product ['manufacturer_name ' ])) {
108109 $ item ['item_brand ' ] = $ product ['manufacturer_name ' ];
109110 // If we don't, which can happen due to some bugs in getProductProperties, we will fetch it manually
110- } else if (!empty ($ product ['id_manufacturer ' ])) {
111+ } elseif (!empty ($ product ['id_manufacturer ' ])) {
111112 $ manufacturerName = Manufacturer::getNameById ((int ) $ product ['id_manufacturer ' ]);
112113 if (!empty ($ manufacturerName )) {
113114 $ item ['item_brand ' ] = $ manufacturerName ;
@@ -124,7 +125,7 @@ public function prepareItemFromProduct($product, $useProvidedQuantity = false)
124125 $ item ['item_variant ' ] = $ product ['attributes_small ' ];
125126
126127 // If we don't, we will construct it in the same format
127- } else if (!empty ($ product ['id_product_attribute ' ])) {
128+ } elseif (!empty ($ product ['id_product_attribute ' ])) {
128129 $ variant = $ this ->getProductVariant ((int ) $ product ['id_product_attribute ' ]);
129130 if (!empty ($ variant )) {
130131 $ item ['item_variant ' ] = $ variant ;
0 commit comments