Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento 将属性集名称添加到Google analytics Ga.php?_Magento_Google Analytics - Fatal编程技术网

Magento 将属性集名称添加到Google analytics Ga.php?

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

我正在尝试将属性集的名称添加到文件/www/app/code/local/Mage/GoogleAnalytics/Block/Ga.php中的分析报告中

这是我正在使用的代码,但有些地方不对劲,我在Magento成功页面上一直看到一个空白页面:

$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()
      );
}