SHARE
TWEET

Untitled

a guest Jun 27th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. use Magento\Framework\App\Bootstrap;
  4.  
  5. include 'app/bootstrap.php';
  6.  
  7. $bootstrap = Bootstrap::create(BP, $_SERVER);
  8. $objectManager = $bootstrap->getObjectManager();
  9.  
  10. $state = $objectManager->get('Magento\Framework\App\State');
  11. $state->setAreaCode('adminhtml');
  12.  
  13. $productCollectionFactory = $objectManager->get('\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
  14. $productcollection = $productCollectionFactory->create()
  15.                         ->addAttributeToSelect('*')
  16.                         ->addAttributeToFilter('type_id', array('eq' => 'configurable'))
  17.                         ->load();
  18.  
  19. foreach ($productcollection as $product) {
  20.     $productId = $product->getId();
  21.     $product = $objectManager->create('Magento\Catalog\Model\Product');
  22.     $product->load($productId);
  23.     $product->save();
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top