小智 2
我不知道你所说的外部是什么意思,但我能够使用magerun2创建一个产品。这就是我走了多远:
# bin/n98-magerun2.phar dev:console
$productFactory = $objectManager->create("\Magento\Catalog\Model\ProductFactory");
// this needs to be set to avoid exception:
// Magento\Framework\Exception\SessionException with message 'Area code not set: Area code must be set before starting a session.'
// I don't know why ...
$appState = $objectManager->get("Magento\Framework\App\State")
$appState->setAreaCode("de")
$product = $productFactory->create()
$product->setName("FooBar")
$product->setName("123")
$product->setAttributeSetId(15)
$product->save()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2943 次 |
| 最近记录: |