0

i have this code

$productCollection = Mage::getModel('catalog/product')->getCollection();
        $productCollection->addAttributeToSelect('SKU')
            ->addAttributeToFilter('modelnumber', $params['modelnumber'])
            ->addAttributeToFilter('attribute_set_id', '10')
            ->joinField(
                'qty',
                'cataloginventory/stock_item',
                'qty',
                'product_id=entity_id',
                '{{table}}.stock_id=1',
                'left'
            )
            ->getFirstItem();

        $productCollection->setStockData(array(
                'use_config_manage_stock' => 1,
                'manage_stock'=>1,
                'is_in_stock' => 1,
                'qty' => 25
            )
        );

        $productCollection->save();

But i have error

 Call to undefined method Mage_Catalog_Model_Resource_Product_Collection::setStockData()

How i can save stockData ?

0

Please try with below code,

$stockData = ['qty' => 25, 'is_in_stock' => 1];

     $productCollection->setStockData($stockData);

I hope its work for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.