我需要在magento中单独放置捆绑产品的块或图像?
我需要在所有捆绑产品页面的面包屑下面放置一个静态块或图像我需要在magento中单独放置捆绑产品的块或图像?,magento,magento-1.8,Magento,Magento 1.8,我需要在所有捆绑产品页面的面包屑下面放置一个静态块或图像 如何实现这一点。请帮助我找到解决方案 您可以尝试在适当的视图文件中添加以下代码。并确保$\u product变量在该视图文件中可用 <?php if( $_product->getTypeId() == 'bundle' ): ?> <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_id')->
如何实现这一点。请帮助我找到解决方案 您可以尝试在适当的视图文件中添加以下代码。并确保
$\u product
变量在该视图文件中可用
<?php if( $_product->getTypeId() == 'bundle' ): ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_id')->toHtml() ?>
<?php endif; ?>
您可以尝试以下方法: -第一,在“设计”部分创建捆绑产品时,在“自定义布局更新”中添加
catalog/product/viewbundle.phtml
-然后在模板中添加静态块,如下所示:
<div class="class1">
<p><?php echo Mage::helper('yourmodule')->getStaticBlock('staticBlockId')?></p>
</div>
下面是getStaticBlock方法的实现:
/**
* @param string $blockId
* @param string $class
*/
public static function getStaticBlock($blockId, $class = '') {
if (Mage::app ()->getLayout ()->createBlock ( 'cms/block' )->setBlockId ( $blockId )->toHtml ()) {
return '<div class="static-block ' . $class . '">' . Mage::app ()->getLayout ()->createBlock ( 'cms/block' )->setBlockId ( $blockId )->toHtml () . '</div>';
}
return '';
}
/**
*@param string$blockId
*@param string$class
*/
公共静态函数getStaticBlock($blockId,$class=''){
if(Mage::app()->getLayout()->createBlock('cms/block')->setBlockId($blockId)->toHtml()){
返回'.Mage::app()->getLayout()->createBlock('cms/block')->setBlockId($blockId)->toHtml()';
}
返回“”;
}
/**
* @param string $blockId
* @param string $class
*/
public static function getStaticBlock($blockId, $class = '') {
if (Mage::app ()->getLayout ()->createBlock ( 'cms/block' )->setBlockId ( $blockId )->toHtml ()) {
return '<div class="static-block ' . $class . '">' . Mage::app ()->getLayout ()->createBlock ( 'cms/block' )->setBlockId ( $blockId )->toHtml () . '</div>';
}
return '';
}