0

Well, I am working on my first Magento website. I am using Magento 1.9.2 & lunxury theme 1.2.X

I am trying to add products in left navigation bar manually.

What I have done so far

In my app\design\frontend\mgstheme\luxury\template\mgs\mpanel\template\category-navigation.phtml File I put this code.

<?php
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
?>


<ul id="content-navigation">
       <?php echo $_menu ?>
        <li>
            <ul>
              <?php foreach ($products as $_product) { ?>
                    <li><?php echo $_product->getName(); ?></li>
                <?php } ?>
            </ul>
        </li>
    </ul>

for now, its printing all products but I want all products under their category name.

I am attaching screenshot for reference here jemmy proof lock to cupboard are the categories and after that its loading all products enter image description here enter image description here

  • pls check my answer : you need to pass category id for the specific category product – Nikunj Vadariya Oct 21 '16 at 10:24
  • do i writing code in correct file? because its printing product after completion of my category list – parish Oct 21 '16 at 10:32
  • check where to come $_menu and there you need to change as i told you. – Nikunj Vadariya Oct 21 '16 at 10:35
  • I guess \app\code\core\Mage\Catalog\Block\navigation.php this file may have code... Help me to editing it – parish Oct 21 '16 at 10:43
  • You need to override this block into one custom extension. In that you have to create menu like you want, means currently it return only category but you need to do code for adding product into list with category. – Dhiren Vasoya Oct 21 '16 at 13:59
-1

Try this:

$_product = Mage::getModel('catalog/category')->load($category_id)
 ->getProductCollection()
 ->addAttributeToSelect('*')
 ->addAttributeToFilter('status', 1) // enabled
 ->addAttributeToFilter('visibility', 4) //visibility in catalog,search
 ->setOrder('price', 'ASC'); //sets the order by price
  • So if there are X categories on the page, you plan on loading X times a category model, and X times a collection of products? This will destroy the page load time. – Mayers Oct 21 '16 at 10:36
  • @Mayers if you have any good idea then pls help to parish. – Nikunj Vadariya Oct 21 '16 at 10:39

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.