How can I create a collection to get all products with the same name (grouped by name) and the same category (grouped by category) in the same collection ??
Thanks a lot for help.
How can I create a collection to get all products with the same name (grouped by name) and the same category (grouped by category) in the same collection ??
Thanks a lot for help.
I am not sure if I understand clearly what you want. You can group products by name using groupByAttribute method:
$_collection = Mage::getModel('catalog/product')->getCollection();
$_collection->addAttributeToSelect('*');
$_collection->groupByAttribute('name');
But grouping by category is not that simple, since one product can be in more categories. So I am not sure if it is possible, you will probably have to write some checking script logic.
But maybe, you want just get products by name with
$_collection->addAttributeToFilter('name', 'My product name')
And get products by category: Magento products by categories
Read more about collections in Magento: http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/using_collections_in_magento