I need to update(increase/decrease) the price & special price by certain amount or percentage for all products in all stores.

Here is the my code but its not increase/decrease the price. I have also refered few links but not match with the needs.


ini_set('max_execution_time', 0);
use \Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$state = $objectManager->get('\Magento\Framework\App\State');

$updateprice = "100";

$productFactory = $objectManager->get('\Magento\Catalog\Model\ProductFactory');
$product = $productFactory->create()->load();

My version is Magento 2.2.4

Can anyone let me know how to increase/decrease the price for all products?


try my below code

use Magento\Framework\App\Bootstrap;
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
ini_set('memory_limit', '1024M');

$updateprice = "100";
$storeId = '1'; //Store ID
$productCollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Collection');
$products = $productCollection->addAttributeToSelect('*')
foreach ($products as $_product) {
    $price = $_product->getPrice();   
    $getSpecialPrice = $_product->getSpecialPrice(); 
    $_product->setPrice($price + $updateprice);
    $_product->setSpecialPrice($price + $updateprice);


enter image description here


enter image description here

  • Thanks. I need to increase/decrease the product price by certain amount for all products & all stores. For example if already product price is 1000 then it should increase by 100 so the final amount after update is 1100
    – mysti
    Mar 29 '19 at 5:44
  • ok let me check and i will update you Mar 29 '19 at 5:46
  • Thanks,Will check it. It will applies for all products in all Stores? For percentage?
    – mysti
    Mar 29 '19 at 6:38
  • I have tried above code, added as php file and executed the file but loading for very long and nothing happened.
    – mysti
    Apr 2 '19 at 15:27
  • Also in backend price updated in wrong logic. For example the same amount is added to special price if the special price don't have value
    – mysti
    Apr 2 '19 at 15:34

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.