Custom Script to change product Type



<?php

$bootstrap = realpath(__DIR__) . './app/bootstrap.php';
if (is_file($bootstrap )) {
    include $bootstrap 
}
​
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
​
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('adminhtml');
$productCollectionFactory = $objectManager->get('\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
​
$collection = $productCollectionFactory->create()
->addAttributeToSelect('*')
->addAttributeToFilter('type_id', "[your type ]" );
foreach($collection  as $product){
    $product->setTypeId('simple')->save(); [changed type]
   echo "sku-> ". $product->getSku() ."\n";
}



Ready to elevate your e-commerce business?

Discuss your business objectives with us. Get in touch today to explore ways we can assist in reaching them.

Copyright © 2021-present ArmMage Inc. All rights reserved.