【问题标题】:How Can I Print the Number of Associated Products within a configurable product in Magento如何在 Magento 的可配置产品中打印关联产品的数量
【发布时间】:2013-10-03 21:42:40
【问题描述】:

我有一堆可配置的产品,它们在我的 magento 商店中都有不同数量的相关产品。在打印价格和描述的类别页面上,我还想打印“查看所有 7 种颜色选项”之类的内容,7 是相关产品数量的动态值。

我已经想出了如何隔离可配置和关联的产品,但是在简单地获取计数并打印它时找不到任何东西。

【问题讨论】:

    标签: php magento printing


    【解决方案1】:

    在 list.phtml 中尝试这个,在产品的 foreach 迭代中

    <?php 
    $usedProductIds = $_product->getTypeInstance()->getUsedProductIds();
    if(count($usedProductIds)>0) {
       echo "Number of products: " . count($usedProductIds);
    }
    ?>
    

    【讨论】:

      猜你喜欢
      • 2015-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-01
      相关资源
      最近更新 更多