I am trying to create a magento side bar box that can list products in certain category.
I have created a file that creates a list of products in a certain catagory called most_sold_list.phtml with the following contents...
<?php
$_productCollection_1 = $this->getLoadedProductCollection();
?>
<div class="link_list_with_title">
<p class="catagory_title">Best Sellers</p>
<ul>
<?php foreach ($_productCollection_1 as $_product_1): ?>
<li>
<a href="<?php echo $_product_1->getProductUrl() ?>" title="<?php echo $_product_1->getName(); ?>"><?php echo $_product_1->getName(); ?></a>
</li>
<?php endforeach ?>
</ul>
</div>
I then update my local.xml to contain (within <default><reference name="left">
)...
<block type="catalog/product_list" name="most_sold.leftnav" template="most_sold_list.phtml">
<action method="setCategoryId"><category_id>18</category_id></action>
</block>
This add the block to the page as I would expect. But when I go to the products page I get the following error...
Fatal error: Cannot redeclare get_quatity_weight_string_view() (previously declared in /.../app/design/frontend/superchef/default/template/catalog/product/view.phtml:37) in /.../app/design/frontend/superchef/default/template/catalog/product/view.phtml on line 54
I have checked and that function is not declared anywhere else and this error message goes away as soon as I remove my new block. Also note line 54 is the closing brace of the function.
I have tried removing that function completely by putting its code inline but then I just get the magento error message page.
The only conclusion I can come to is that view.phtml is being loaded twice. I have searched for this and I have seen mentions of zend loader loading files twice.
Can anybody help me fix this, it makes no sense to me.
I have now worked out how to solve this problem from reading this: http://www.bwigg.com/2010/01/magento-featured-products-in-sidebar/
So here is what I have done incase anybody else hits this weird problem.
update the layout xml file so the block type is "catalog/navigation".
So it now looks like this...
<block type="catalog/navigation" name="most_sold.leftnav" template="most_sold_list.phtml">
<action method="setCategoryId"><category_id>18</category_id></action>
</block>
<remove name="category.products" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.