Can anyone know what is the difference between use of
$product->getResource()->save($product);
$product->save();
magento-1.9product
Can anyone know what is the difference between use of
$product->getResource()->save($product);
$product->save();
Best Answer
There is not a huge difference. When calling save directly from the product object, that function also calls
$product->getResource()->save($product)
.However, both the product model and product resource model can have
beforeSave()
andafterSave()
events. So when you call$product->getResource()->save($product)
, you end up skipping the beforeSave/afterSave events that exist within the main product model and only those that exist within the resource model are called.The main difference between the two, is that when calling
$product->save()
, it callsMage_Catalog_Model_Product::_beforeSave()
which contains this logic:After this runs, the same
$this->getResource()->save($this)
is called.