2015-01-10 24 views
0

我想調用cms塊preorder_note如果產品具有屬性preorder_note的值(無關緊要)。但我無法實現它的工作。在Magento中:如果產品具有特定屬性,則獲取靜態塊

這是在頁面模板/目錄/產品做/ view.phtml

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

我在做什麼錯?

回答

1

我自己找到了解決方案。

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