php - Magento - Set product visibility on observer at store level before product save -



php - Magento - Set product visibility on observer at store level before product save -

i have 2 websites, each of has 2 stores.

when create product store(say, store 1) of website(say, website 1), , if set websites product website 1 , website 2, product's visibility set catalog, search store created it(store 1). other stores, visibility set not visible individually.

i have observer catalog_product_save_before, in want set visibility @ store level.

tried code:

mage::getmodel('catalog/product_action')->updateattributes( array($productid), array('visibility'=>4), 1 );

and works. this, need productid, wont since product not yet saved in observer function.

how set product visibility particular store(say store 3 of website 2) catalog, search in catalog_product_save_before observer?

finally got it.

the observer function:

public function before_product_save($observer) { $product = $observer->getproduct(); $product->setstoreid(1)->setdata('visibility', 4); }

where, store id 1 , visibility attribute value 4 refers catalog, search.

php magento magento-1.8

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -