0

here is the custom layout xml i am using:

 <reference name="content">
        <block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
            <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">

            <action method="setColumnCount"><columns>4</columns></action>


               </block>

i am seeing products twice in front end.

6
  • give more details. where did you put this code ? how did you set product collection etc Commented Oct 8, 2014 at 13:22
  • i have put this code to "Custom Layout Update" in category i did not understand your mean about "product collection" Commented Oct 8, 2014 at 13:24
  • ok got it. only one thing to know more? why did you add this code ? or what are you trying to achieve ? Commented Oct 8, 2014 at 13:36
  • actually theme layout not working and i could not figure out it. So i try to add the custom layout for it and its working fine just showing products twice Commented Oct 8, 2014 at 13:39
  • and how do the product shows now ? same product are appearing one after another or are they appearing seperateley ? Commented Oct 8, 2014 at 13:39

2 Answers 2

2

You have added this layout update via admin side. The layout update that you are used actually will create a new category view section under content section along with the default one.

There are two types of categories basically

  • Default Categories :- Categories which do not possess layered navigation

  • Layered Categories :- Categories which do possess layered navigation

Depending upon the type of category, Magento uses two desperate layout handles for them. For default categories, it uses catalog_category_default and for catalog_category_layered. These two layout handles will not process simultaneously.

Now Magento defines this layout handles in catalog.xml file. So take a look on these handles over there

File : app/design/frontend/<your_package>/<your_theme>/layout/catalog.xml

 <reference name="content">

        <block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
            <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
             .....
            </block>
            .....
        </block>
        ...
</reference>

(Above I showed only relevant sections)

Both of this layout handle already defines category-view block and product-list block over there.

Now, after processing the above layout update handle, then magento will take into consider your custom admin layout update that you have included via admin section. Your custom layout updation again do the same thing that is done by above mentioned layout handles here. That is why you are viewing two lists.

In order to avoid this, you need to refer blocks that are included through layout handles catalog_category_default or catalog_category_layered and then do customization then. That is you can refer a category-view block like this

<reference name="category.products">
     <!-- custom udpates comes here-->
</reference>

Similarly product-list block can be refered as

<reference name="product_list">
     <!-- custom udpates comes here-->
</reference>

So if you just need to set column via your custom update, then you can use this

<reference name="content>
    <reference name="product_list">
         <action method="setColumnCount"><columns>4</columns></action>
    </reference>
</reference>

This will set column count for existing product list block that is defined via category specific layout handles, instead of new one.

2
  • solution did not work but it given me an idea i have comment the catalog.xml <reference name="content" an i did it :D Commented Oct 9, 2014 at 2:13
  • this code will not work if you need to set column. I just show you how your code will looks like, in order to avoid mutiple product list Commented Oct 9, 2014 at 3:41
0

Try adding:

<remove name="product_list"/>

after the first line:

<reference name="content">
     <remove name="product_list"/>
     ...

in your custom xml design

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.