浏览文章
文章信息
Magento2 删除所有产品Options选项
16469
1、示例,具体是删除什么,自己写程序控制,核心代码如下
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $products = $objectManager->get('\Magento\Catalog\Model\Product')->getCollection(); foreach ($products as $product) { $product = $objectManager->get('\Magento\Catalog\Model\Product')->load($product->getId()); $prod[$product->getId()] = $product->getId(); if ($product->getOptions()) { foreach ($product->getOptions() as $opt) { $prod[$product->getId()][] = $opt->getId(); $opt->delete(); } } }