Prashant Parekh
Prashant Parekh

Reputation: 428

Search Product by category in magento 1.8

I have to find products from category that user selected. I made a one dropdown that show all category and subcategory, now user select any category from that dropdown and search product accordingly. I am not sure what kind of changes i have to made and also which files i have to modify.So does any one know how i will achieve it. please share you idea.

Upvotes: 0

Views: 339

Answers (1)

Keyur Shah
Keyur Shah

Reputation: 11533

I think you got category_id from category selection

 $_productCollection = Mage::getModel('catalog/product')->getCollection()
    ->addAttributeToSelect("*")
    ->addStoreFilter()
    ->addAttributeToFilter("visibility",4)
    ->addCategoryFilter(Mage::getModel('catalog/category')->load($catid))
    ->setOrder("position","asc");

Where $catid is your category id

In $_productCollection you get all product collection with specific category filter

and try to run foreach in $_productCollection to get all product infromation

Let me know if you have any query

Upvotes: 1

Related Questions