php $product->保存()在magento 2.1.3中保存一个简单的产品需要4秒

ddrv8njm  于 2023-05-16  发布在  PHP
关注(0)|答案(1)|浏览(120)

我有下面的代码与图像上传这是工作正常...但它需要4秒钟,以保存一个简单的产品...我的商店有超过25000种产品。创建/更新产品需要超过4/5小时...求你了救命

use Magento\Framework\App\Bootstrap;

include('app/bootstrap.php');
$bootstrap = Bootstrap::create(BP, $_SERVER);

$objectManager = $bootstrap->getObjectManager();

$state = $objectManager->get('Magento\Framework\App\State'); 

$state->setAreaCode('frontend');

$_product = $objectManager->create('Magento\Catalog\Model\Product');

$_product->setName('Test Product');

$_product->setTypeId('simple');

$_product->setAttributeSetId(4);
$_product->setSku('test-SKU');

$_product->setWebsiteIds(array(1));

$_product->setVisibility(4);

$_product->setPrice(array(1));

$_product->setImage('/testimg/test.jpg');

$_product->setSmallImage('/testimg/test.jpg');

$_product->setThumbnail('/testimg/test.jpg');

$_product->setStockData(array(

        'use_config_manage_stock' => 0, //'Use config settings' checkbox
    enter code here
        'manage_stock' => 1, //manage stock

        'min_sale_qty' => 1, //Minimum Qty Allowed in Shopping Cart

        'max_sale_qty' => 2, //Maximum Qty Allowed in Shopping Cart

        'is_in_stock' => 1, //Stock Availability

        'qty' => 100 //qty

        )

    );

$_product->save();
fcwjkofz

fcwjkofz1#

我首先要看的是表损坏或表索引

相关问题