Guest User

Untitled

a guest
Feb 19th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. $productObj = Mage::getModel('catalog/product')->load($product->getId());
  2. $productObj->setData('filter_category','51,52');
  3. $productObj->save();
  4.  
  5. $attrCode = 'your_attribute';
  6. $sourceModel = Mage::getModel('catalog/product')->getResource()
  7. ->getAttribute($attrCode)->getSource();
  8. $valuesText = explode(',', 'red,green,blue');
  9. $valuesIds = array_map(array($sourceModel, 'getOptionId'), $valuesText);
  10. $product->setData($attrCode, $valuesIds);
  11. $product->getResource()->saveAttribute($product, $attrCode);
  12.  
  13. public function setFilterCategoryBeforeSave(Varien_Event_Observer $observer)
  14. {
  15. $observer->getProduct()->setData('filter_category','51,52');
  16. }
  17.  
  18. $collection = $this->getCollection()
  19. ->addAttributeToSelect('*')
  20. ->addAttributeToFilter('visibility', $visibility)
  21. ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
  22. ->addAttributeToFilter($attribute,array('finset'=>array_search($selection,$valueId)))
  23. ->setPageSize($limit)
  24. ->load();
  25. Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
Add Comment
Please, Sign In to add comment