Hello I know this is simple question but I don’t get any solution in here. So I am going to ask.
I am using magento 1.9, and I want a product list with name and product Url of particular category. I tried a lot but I am not getting product name and product URL.
Here is my query.
$catid = $this->getCategory()->getId();
$_productCollection = Mage::getModel('catalog/category')->load($catid)
->getProductCollection()
->addAttributeToSelect('*')
->addAttributeToSelect('name')
->addFieldToFilter('status', 1)
->addAttributeToFilter('visibility', 4)
->joinField('is_in_stock',
'cataloginventory/stock_item',
'is_in_stock',
'product_id=entity_id',
'is_in_stock=1',
'{{table}}.stock_id=1',
'left');
Output
[entity_id] => 1
[entity_type_id] => 4
[attribute_set_id] => 4
[type_id] => simple
[sku] => foo
[has_options] => 1
[required_options] => 1
[created_at] => 2018-02-03 06:46:56
[updated_at] => 2018-02-05 00:22:04
[cat_index_position] => 1
[status] => 1
[visibility] => 4
[is_in_stock] => 1
So how to get product name and product url in this query ?
2
Answers
Try using foreach loop
OR
If you know product ID of the product
Here is the way to get product list with name and product Url of particular category.
And the corresponding MySQL query that gets executed behind it is :