【问题标题】:In Magento: get static block if product has specific attribute在 Magento 中:如果产品具有特定属性,则获取静态块
【发布时间】:2015-01-10 23:19:54
【问题描述】:

如果产品具有属性 preorder_note 的值(不管值是什么),我正在尝试调用 cms 块 preorder_note。但我无法让它工作。

这是在页面模板/目录/产品/view.phtml上完成的

    <?php if ($_product->getAttribute('preorder_note')): ?>
    <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('preoder_short')->toHtml() ?>
<?php endif; ?>

我做错了什么?

【问题讨论】:

    标签: magento attributes block


    【解决方案1】:

    我自己找到了解决方案。

    <?php $_howtouse = $this->getProduct()->getPreorder_note(); ?>
    <?php if ($_howtouse): ?>
     <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('preoder_short')->toHtml() ?>
       <?php endif; ?>
    

    【讨论】:

      猜你喜欢
      • 2017-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多