Closed damienwebdev closed 5 years ago
Does the e-commerce data contain the right price? https://github.com/yireo/Yireo_GoogleTagManager/blob/master/source/app/design/frontend/base/default/template/googletagmanager/data/product.phtml#L68
@jissereitsma Yes it does. But the issue is that not all my "child" configurable products are the same price as their parent configurable product. E.g. a T-shirt has a base price, a XXL T-shirt may cost $1.00 more. Listing the configurable child at the same price results in inaccurate data.
So wouldn't replacing line 48 with the following code fix it or would it not?
$child['price'] = $this->formatPrice($this->getModuleHelper()->getProductPrice($childProduct));
I don't necessarily think so.
If I remember Mage 1 core correctly, configurable "children" don't necessarily pull their prices from their associated simples (this is now the case in Magento 2, thankfully). There's a convoluted middle layer which involves setting the "customOptions".
$product = Mage::getModel('catalog/product')->load(CONFIG_ID); //configurable product
$childProduct = Mage::getModel('catalog/product')->load(CONFIG_CHILD_ID); //associated simple product
$confAttributes = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
$pdtOptValues = array();
foreach ($confAttributes as $attribute) {
$attrCode = $attribute['attribute_code'];
$attrId = $attribute['attribute_id'];
$childValue = $childProduct->getData($attrCode);
$pdtOptValues[$attrId] = $childValue;
}
$product->addCustomOption('attributes', serialize($pdtOptValues));
echo $product->getFinalPrice();
It's a similar process for bundles as well (setting custom options and then calling getFinalPrice)
if ($this->formatPrice($this->getModuleHelper()->getProductPrice($childProduct))) {
$child['price'] = $this->formatPrice($this->getModuleHelper()->getProductPrice($childProduct));
} else {
$child['price'] = $this->formatPrice($price);
}
@app/design/frontend/base/default/template/googletagmanager/data/product.phtml worked for me.
productChildren prices appear as 0.00 for configurable product types on a clean install of Magento 1.9.4.1 with Yireo GoogleTagManager 1.5.2.
In a previous Pull Request by a third party contributor, support for Configurable Products was added, but the name and the price was still missing. This has now been added in the latest release.
Currently, the price of configurable product children is inaccurate. It renders the price of the parent product for each child. This may be an intentional design decision, but thought I'd report just the same.
See: https://github.com/yireo/Yireo_GoogleTagManager/blob/da473a6320ddb420587897a212fb0d9501d9f5a3/source/app/design/frontend/base/default/template/googletagmanager/data/product.phtml#L48