I have 50k products in my website and want to update tier price. I have existing tier prices for products, but based on the existing product price, I need to update customer price.
I have created an external root file and created one function. Like in Magento 1 I did:
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('id')
->addAttributeToFilter('status', 1)
->addAttributeToFilter('visibility', 4)
->addAttributeToSort('created_at', 'desc');
Mage::getSingleton('core/resource_iterator')
->walk(
$products->getSelect(),
array(array($this, '_Callback')),
array()
);
I want to do the same thing in Magento 2m using a collection. I want to only call _Callback function with Magento 2 product collection so that it can work collection walk iteratively.
$productCollection = $objectManager
->create('Magento\Catalog\Model\ResourceModel\Product\Collection');
$productcollection = $productCollection
->addAttributeToSelect('name')
->addAttributeToSelect('price')
->addAttributeToSelect('entity_id')
->setOrder('entity_id','ASC')
->load();
Please give me solution.