Magento 将属性集名称添加到Google analytics Ga.php?
我正在尝试将属性集的名称添加到文件/www/app/code/local/Mage/GoogleAnalytics/Block/Ga.php中的分析报告中 这是我正在使用的代码,但有些地方不对劲,我在Magento成功页面上一直看到一个空白页面:Magento 将属性集名称添加到Google analytics Ga.php?,magento,google-analytics,Magento,Google Analytics,我正在尝试将属性集的名称添加到文件/www/app/code/local/Mage/GoogleAnalytics/Block/Ga.php中的分析报告中 这是我正在使用的代码,但有些地方不对劲,我在Magento成功页面上一直看到一个空白页面: $attributeSetName = null; $attributeSetName = Mage::getModel('eav/entity_attribute_set')->load($_product->getAttributeS
$attributeSetName = null;
$attributeSetName = Mage::getModel('eav/entity_attribute_set')->load($_product->getAttributeSetId())->getAttributeSetName();
foreach ($order->getAllVisibleItems() as $item) {
$result[] = sprintf("_gaq.push(['_addItem', '%s', '%s', '%s', '%s', '%s', '%s']);",
$order->getIncrementId(),
$this->jsQuoteEscape($item->getSku()), $this->jsQuoteEscape($item->getName()),
$attributeSetName,
$item->getBasePrice(), $item->getQtyOrdered()
);
}
$\u产品似乎未定义
试一试
这似乎起到了完美的作用。非常感谢!
foreach ($order->getAllVisibleItems() as $item) {
$_product = Mage::getModel('catalog/product')->load($item->getProductId());
$attributeSetName = Mage::getModel('eav/entity_attribute_set')->load($_product->getAttributeSetId())->getAttributeSetName();
$result[] = sprintf("_gaq.push(['_addItem', '%s', '%s', '%s', '%s', '%s', '%s']);",
$order->getIncrementId(),
$this->jsQuoteEscape($item->getSku()), $this->jsQuoteEscape($item->getName()),
$this->jsQuoteEscape($attributeSetName),
$item->getBasePrice(), $item->getQtyOrdered()
);
}