How to get a Magento product collection as a comma separated list of SKU's
Posted
by Sam
on Stack Overflow
See other posts from Stack Overflow
or by Sam
Published on 2010-03-26T18:19:00Z
Indexed on
2010/03/26
18:23 UTC
Read the original article
Hit count: 436
magento
Hi All
I have a custom module I made for Magento. From the admin, there is a multi-select list of store products. The selected products from this are output in the form of a comma separated list of SKU's - for example:
// Get Featured Products from list
$configData = Mage::getStoreConfig('featured_products');
$featuredlist = $configData['settings']['featuredlist'];
This gives the output in the following format if I < ?php echo $featuredlist ?>:
cn,asc,ken,steve,nine,ecco,ana
Is it possible to output a collection from a category in the same way, as a comma separated list of SKU's? I currently use the following to get a collection:
$_productCollection = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->addAttributeToFilter('visibility', $visibility)
->addCategoryFilter($_category);
$_productCollection->load()
© Stack Overflow or respective owner