magento跟踪像素

magento跟踪像素,magento,tracking,Magento,Tracking,跟踪像素中需要两个变量,这两个变量需要放在类别、产品信息、购物车和确认页面上 我已经设法让Prod列表和Prod工作,但是,后两个给我带来了问题 我可以在购物车中回显sku,但是,产品是可配置的产品,因此它在输出中复制sku。我使用的代码如下: <?php // $items = Mage::getModel('checkout/cart')->getQuote()->getAllItems(); $items = Mage::getSingleton('checkout/se

跟踪像素中需要两个变量,这两个变量需要放在类别、产品信息、购物车和确认页面上

我已经设法让Prod列表和Prod工作,但是,后两个给我带来了问题

我可以在购物车中回显sku,但是,产品是可配置的产品,因此它在输出中复制sku。我使用的代码如下:

<?php
// $items = Mage::getModel('checkout/cart')->getQuote()->getAllItems();
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();foreach($items as $item) { echo ''.$item->getSku().'&nbsp;';}
?>

如何将其更改为仅显示一个可配置的SKU

第二个元素是产品存在的类别名称,有人对此有什么想法吗?我尝试了多种变体,但它们要么破坏了页面,要么什么也没有返回

任何帮助都将不胜感激。如果有人也能在确认页面上给我举个例子,说明它们是如何工作的,那就太好了


感谢您的帮助。

检查产品的可见性(连接到可配置服务器的简单产品将不可见):

关于类别名称,一个产品可以出现在多个类别中,所以我不知道你想如何处理。此外,还存在一个问题,即您开始在多个模板文件中复制代码。你会想把这一切移到一个块。

无论如何,在这里获取产品所属的类别名称至少是一种方法

$categoryCollection = $item->getProduct()->getCategoryCollection()
                            ->addAttributeToSelect('name');

    foreach($categoryCollection as $category) {
       echo $category->getData('name') . "<br/>";
    }
$categoryCollection=$item->getProduct()->getCategoryCollection()
->addAttributeToSelect(“名称”);
foreach($categoryCollection作为$category){
echo$category->getData('name')。“
”; }
$categoryCollection = $item->getProduct()->getCategoryCollection()
                            ->addAttributeToSelect('name');

    foreach($categoryCollection as $category) {
       echo $category->getData('name') . "<br/>";
    }