Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $objectManager = MagentoFrameworkAppObjectManager::getInstance(); // instance of object manager
- $product = $objectManager->create('MagentoCatalogModelProduct');
- $product->setSku('my-sku11'); // Set your sku here
- $product->setName('Sample Simple Product11'); // Name of Product
- $product->setAttributeSetId(4); // Attribute set id
- $product->setStatus(1); // Status on product enabled/ disabled 1/0
- $product->setWeight(10); // weight of product
- $product->setVisibility(4); // visibilty of product (catalog / search / catalog, search / Not visible individually)
- $product->setTaxClassId(0); // Tax class id
- $product->setTypeId('simple'); // type of product (simple/virtual/downloadable/configurable)
- $product->setPrice(100); // price of product
- $product->setStockData(
- array(
- 'use_config_manage_stock' => 0,
- 'manage_stock' => 1,
- 'is_in_stock' => 1,
- 'qty' => 99999
- )
- );
- $product = $product->save();
- $product->setStoreId(0); //1,2,3,4
- $objectManager = MagentoFrameworkAppObjectManager::getInstance(); // instance of object manager
- $product = $objectManager->create('MagentoCatalogModelProduct');
- $product->setSku('my-sku11'); // Set your sku here
- $product->setName('Sample Simple Product11'); // Name of Product
- $product->setAttributeSetId(4); // Attribute set id
- $product->setStatus(1); // Status on product enabled/ disabled 1/0
- $product->setWeight(10); // weight of product
- $product->setVisibility(4); // visibilty of product (catalog / search / catalog, search / Not visible individually)
- $product->setTaxClassId(0); // Tax class id
- $product->setTypeId('simple'); // type of product (simple/virtual/downloadable/configurable)
- $product->setPrice(100); // price of product
- $product->setStockData(
- array(
- 'use_config_manage_stock' => 0,
- 'manage_stock' => 1,
- 'is_in_stock' => 1,
- 'qty' => 99999
- )
- );
- $product = $product->save();
- $product->setHasOptions(1);
- $product->getResource()->save($product);
- $setStore = $objectManager->create('MagentoCatalogModelProductOption')
- ->setStoreId(0)
- $setStore->save();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement