如何在magento主页的左面板中显示特殊类别的产品?
我想在主页的左面板中显示特殊类别的产品。为此,我在管理中创建了一个类别,并在该类别下添加了一些产品。但我不知道如何在主页的左面板中显示 如果有人知道这一点,请帮助我。如何在magento主页的左面板中显示特殊类别的产品?,magento,magento-1.8,Magento,Magento 1.8,我想在主页的左面板中显示特殊类别的产品。为此,我在管理中创建了一个类别,并在该类别下添加了一些产品。但我不知道如何在主页的左面板中显示 如果有人知道这一点,请帮助我。 谢谢 您可以在主页的布局xml中使用以下代码来显示该特殊类别的产品列表: <reference name="left"> <block type="catalog/product_list" name="mycatblock" template="catalog/product/list.phtm
谢谢 您可以在主页的布局xml中使用以下代码来显示该特殊类别的产品列表:
<reference name="left">
<block type="catalog/product_list" name="mycatblock" template="catalog/product/list.phtml">
<action method="setData"><name>category_id</name><value>YOUR_CATEGORY_ID_HERE</value></action>
</block>
</reference>
希望这对您有所帮助。转到您的主题/layout/catalog.xml 下标签下
<reference name="left">
<block type="core/template" name="left.cat.product" template="custom/leftsideproduct.phtml">
</reference>
现在转到主题/模板文件夹,创建一个名为custom的文件夹,并创建一个文件leftsideproduct.phtml
<?php $catid=3; //go to admin click on category you have created check id and use here
$category_prd = Mage::getModel('catalog/category')->load($catid);
}?>
<?php $prodCollection = $category_prd->getProductCollection();
foreach ($prodCollection as $product)
{
$prdIds[] = $product->getId(); //Array to store all the product ids
}
$allProducts = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToFilter('entity_id', array('in' => $prdIds))
->addAttributeToSelect('price')->addAttributeToSelect('name')->addAttributeToSelect('image')->addAttributeToSelect('id');
foreach($allProducts as $product):?>
<?php echo $product->getId();?>">
<?php echo $product->getName();?>
<img src="<?php echo Mage::helper('catalog/image')->init($product, 'image')->resize(150,150);?>" title="<?php echo $product->getName();?>
<?php endforeach;?>
">
init($product,'image')->调整大小(150150);?>“title=”
现在转到cms页面下的管理员点击主页设置布局2列左侧栏并立即保存检查。
如果有帮助的话,别忘了喜欢我的ans
<?php $catid=3; //go to admin click on category you have created check id and use here
$category_prd = Mage::getModel('catalog/category')->load($catid);
}?>
<?php $prodCollection = $category_prd->getProductCollection();
foreach ($prodCollection as $product)
{
$prdIds[] = $product->getId(); //Array to store all the product ids
}
$allProducts = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToFilter('entity_id', array('in' => $prdIds))
->addAttributeToSelect('price')->addAttributeToSelect('name')->addAttributeToSelect('image')->addAttributeToSelect('id');
foreach($allProducts as $product):?>
<?php echo $product->getId();?>">
<?php echo $product->getName();?>
<img src="<?php echo Mage::helper('catalog/image')->init($product, 'image')->resize(150,150);?>" title="<?php echo $product->getName();?>
<?php endforeach;?>