【发布时间】:2013-06-27 06:33:57
【问题描述】:
我创建了以下内容,以允许根据类别 ID 在产品页面上显示不同的静态 CMS 块。
<?php
$_category_detail=Mage::registry('current_category'); //Get the current category id
$product = Mage::getModel('catalog/product')->load($product_id); //Get the current category id
$category = Mage::getModel('catalog/layer')->getCurrentCategory(); //Get the current category id
?>
<?php if($category->getId()==23): ?>
<div id="sizingmap">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('sizespecpantsslim')->toHtml(); ?>
</div>
<?php endif;?>
<?php if($category->getId()==10): ?>
<div id="sizingmap">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('sizespecjacket')->toHtml(); ?>
</div>
<?php endif;?>
类别部分的一切都很好,尽管我想根据同一类别中的产品 ID 显示不同的块。
例如(这显然是不正确的):
<?php if($category->getId()==23) "AND the product id are "372,363,354,349,344": ?>
<div id="sizingmap">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('sizespecpantsslim')->toHtml(); ?>
</div>
else // if they are not the mentioned product id's
<div id="sizingmap">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('sizespecpantsstd')->toHtml(); ?>
</div>
【问题讨论】:
-
您为什么不使用
magento提供的类别描述字段以任何具体原因使用类别的静态块?? -
这是一个包含大小图表图像的块,该图表图像因类别而异。尽管裤子属于同一类别,但根据裤子的类型(修身/标准),有两种不同的图表。所以我想根据类别和产品 ID 显示图表。我不想使用产品描述,因为图表显示在选项卡中。
标签: php magento content-management-system block specs