2

I have researched on this issue about Magento 1.9 not adding the category to the home page. So, I ended up adding:

{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="15" template="catalog/product/list.phtml"}}

To the home page content. It also shows up on the home page BUT: only with 1 product out of 5. Why is that and can this be changed?

I am still very new to Magento and I haven't changed anything at the layout bit. I have seen this post: Same problem, but no one has answered (and I can't comment on it), I have followed these steps - but all of it didn't work.

6
  • How many products are assign to category id 15 – Renon Stewart Nov 5 '14 at 12:43
  • @R.S 5 products. And it shows only the latest one I added, I just noticed. – Akkanon Nov 5 '14 at 12:45
  • When browsing that category how many products listed? – Renon Stewart Nov 5 '14 at 12:48
  • @R.S This is how a user sees it and this is the config part in Magento – Akkanon Nov 5 '14 at 12:55
  • Since it show 5 in the upper right, try inspect element or view source to see if the other are hidden and if this is a css related issue – Renon Stewart Nov 5 '14 at 13:02
3

Are you using the rwd theme from Magento 1.9? If so, the problem might be in the catalog/product/list.phtml template file.

In catalog/product/list.phtml from the rwd theme the following code

from line 133 to 140

<?php $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren(); foreach($_nameAfterChildren as $_nameAfterChildName): $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName); $_nameAfterChild->setProduct($_product); ?> <?php echo $_nameAfterChild->toHtml(); ?> <?php endforeach; ?>

and from line 178 to 186

<?php //set product collection on after blocks $_afterChildren = $this->getChild('after')->getSortedChildren(); foreach($_afterChildren as $_afterChildName): $_afterChild = $this->getChild('after')->getChild($_afterChildName); $_afterChild->setProductCollection($_productCollection); ?> <?php echo $_afterChild->toHtml(); ?> <?php endforeach; ?>

will cause errors if you add the block in the layout without the children blocks 'name.after' and 'after'.

If you want this to work on your home page you should create a new template in the theme, for example catalog/product/list_home.phtml, and copy the code from catalog/product/list.phtml but delete the code from the lines I indicated. You should then use the new template in the home page block:

{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="15" template="catalog/product/list_home.phtml"}}

2
  • Thank you very much, this was exactly what was wrong. Now all of my products show up. – Akkanon Nov 6 '14 at 10:07
  • You're welcome! – Marina Vilcea Nov 6 '14 at 16:37
-1

Remove those lines from catalog/product/list.phtml

<?php
    //set product collection on after blocks
    $_afterChildren = $this->getChild('after')->getSortedChildren();
    foreach($_afterChildren as $_afterChildName):
        $_afterChild = $this->getChild('after')->getChild($_afterChildName);
        $_afterChild->setProductCollection($_productCollection);
    ?>
    <?php echo $_afterChild->toHtml(); ?>
<?php endforeach; ?>
3
  • Welcome to Magento SE. This answer probably needs some context to be useful, it does not seem to address the same problem as described in the question. Or how should removing this code from the template fix the number of products in the category list? – Fabian Schmengler Apr 25 '17 at 20:24
  • @FabianSchmengler actuall i am facing the same problem that mention here so if fixed this no reason to downvote my answer – Muhammad Waqas Apr 26 '17 at 17:43
  • Looked at it again, and the other answer suggests basically the same but also provides some explanation. That's what your answer was lacking – Fabian Schmengler Apr 26 '17 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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