i have created a script to import configurable product with its associated products. it was working fine in magento 1.9.0.1 .after i updated my magento to latest version(1.9.2.2) the script is not working.
it showing error while calling $product->save();
the snippet of displaying error -
Invalid method Mage_CatalogRule_Model_Rule::loadProductRules(Array
(
[0] => Mage_Catalog_Model_Product Object
(
[_cacheTag:protected] => catalog_product
[_eventPrefix:protected] => catalog_product
[_eventObject:protected] => product
[_canAffectOptions:protected] =>
[_typeInstance:protected] =>
[_typeInstanceSingleton:protected] => Mage_Catalog_Model_Product_Type_Simple Object
(
[_product:protected] =>
[_typeId:protected] =>
[_setAttributes:protected] =>
[_editableAttributes:protected] =>
[_isComposite:protected] =>
[_canConfigure:protected] =>
[_canUseQtyDecimals:protected] => 1
[_storeFilter:protected] =>
[_fileQueue:protected] => Array
(
))
Snippet of Code in Script
$sProduct = Mage::getModel('catalog/product');
$sProduct -> setName($product['name']);
$sProduct -> setSku($product['sku']);
$sProduct -> setWeight($product['weight']);
$sProduct -> setAttributeSetId($product['attribute_set_id']);
$sProduct -> setDescription($product['description']);
$sProduct -> setShortDescription($product['short_description']);
$sProduct -> setTypeId($product['type_id']) -> setWebsiteIds(array(1)) -> setStatus($product['status']) -> setVisibility($product['visibility']) -> setTaxClassId($product['tax_class_id']);
$sProduct -> setPrice($product['price']);
$sProduct -> setStockData($product['stock_data']);
$sProduct -> setCategoryId($product['category_ids']);
$optionId = $this -> getOptionId('size', $product['size']);
$sProduct -> setData('size', $optionId);
$optionIdcolor = $this -> getOptionId('color', $product['color']);
$sProduct -> setData('color', $optionIdcolor);
$mode = array("small_image", "thumbnail", "image");
$mode1 = array();
$imges = explode(',',$product['img']);
$ij = 0;
foreach ($imges as $nml) {
$imges[$ij] = $nml.'.jpg';
$ij++;
}
$a = 0;
foreach ($imges as $im) {
$img = $mediaDir.'/import/'.$im;
Mage::log($img);
if ($a == 0) {
Mage::log($im);
if (file_exists($img)) {
$sProduct -> addImageToMediaGallery($img, $mode, false, false);
}
} else {
if(substr($im, 0, 1) == ' ')
{
$im = substr($im, 1);
}
Mage::log($im);
if (file_exists($img)) {
$sProduct -> addImageToMediaGallery($img, $mode1, false, false);
}
}
$a++;
}
$sProduct->save();
i am getting correct values while print_r($sProduct)
but it shows error while saving