On catalog_product_save_before event I've got handler that should update prices for product. On save I need to update prices for every store, not one price for Default.
$sellerslist = Mage::getModel('mpassignproduct/mpassignproduct')->getCollection();
$sellerslist = $this->getSellersList();
$data = $sellerslist->getData();
if (!empty($data) && count($data) > 0 && !empty($data[0]['mpassignproduct_id']) && $data[0]['mpassignproduct_id'] + 0 > 0) {
$stores = Mage::helper('advox_core')->getStoresByWebsiteId($websiteId);
foreach ($stores as $storeId) {
// Previously I tried to load this product to new variable.
//$product = Mage::getModel('catalog/product')->setStoreId($storeId + 0)->load($product->getId());
$product->setStoreId($storeId + 0);
$product->setMinPrice($data[0]['minprice']);
$price = $data[0]['minprice'];
if ($price === null) {
$price = 0;
}
$product->setPrice($price);
}
}
I can't load product again for specific store because on save there is once again called catalog_product_save_before so infinite event observer is called. How to change product prices for specific store.
Update:
I changed to:
$websiteIds = $product->getWebsiteIds();
foreach ($websiteIds as $websiteId) {
$sellerslist = $this->getSellersList();
$data = $sellerslist->getData();
if (!empty($data) && count($data) > 0 && !empty($data[0]['mpassignproduct_id']) && $data[0]['mpassignproduct_id'] + 0 > 0) {
$product->setWebsiteId(array($websiteId + 0));
$product->setMinPrice($data[0]['minprice']);
$price = $data[0]['minprice'];
if ($price === null) {
$price = 0;
}
$product->setPrice($price);
}
}
$product->setWebsiteIds($websiteIds);
as you said that prices should be changed only for websites. I tried with catalog_product_prepare_save event but still not updating.
Update 2:
While saving product in admin panel I've got only global product model. Is there any simple way to load website specific data to this product model and then change this details?