Tufanayd Posted August 9, 2013 Share Posted August 9, 2013 Hi, I am not very good at PHP however I am trying to edit a php function for Magento. $categoryID = $this->getCategoryId(); //the value is like 7,3,6,9 $cats = explode(',', $categoryID); $collection = Mage::getModel('catalog/product') ->getCollection() ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left') ->addAttributeToSelect('*') ->addAttributeToFilter('category_id', array( array('finset' => '7'), array('finset' => '3'), array('finset' => '6'), array('finset' => '9') ) ); I want to generate the below part automatically based on the value(s) of $cats array('finset' => '7'),array('finset' => '3'), array('finset' => '6'), array('finset' => '9') How can I do it, urgent help will be extremely appreciated. Thanks in advance Link to comment https://forums.phpfreaks.com/topic/280987-loop-array/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.