I am creating a custom module.
I am testing the ability to update a products quantity.
I have created a bare bones magento module and began testing with code inside indexController.php here is my code:
public function indexAction() {
//Just grabbing sku# 62701 for testing...
$tempProduct = Mage::getModel('catalog/product')->loadByAttribute('sku', 62701 );
$stockData['qty'] = 300;
$tempProduct->setStockData($stockData);
$tempProduct->save();
}
By having the last line in there i get the error.
From the error log:
a:5:{i:0;s:46:”Invalid method Varien_Object::save(Array
(
)
Followed by the stack trace…
Any help is appreciated, thank you.
I found a way to save data that seemed to work in my scenario (not sure why it worked) here:
https://stackoverflow.com/a/7608195/1110880
The code that made it work was the following:
I hope this helps someone.