Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. $objectManager = MagentoFrameworkAppObjectManager::getInstance(); // instance of object manager
  2. $product = $objectManager->create('MagentoCatalogModelProduct');
  3. $product->setSku('my-sku11'); // Set your sku here
  4. $product->setName('Sample Simple Product11'); // Name of Product
  5. $product->setAttributeSetId(4); // Attribute set id
  6. $product->setStatus(1); // Status on product enabled/ disabled 1/0
  7. $product->setWeight(10); // weight of product
  8. $product->setVisibility(4); // visibilty of product (catalog / search / catalog, search / Not visible individually)
  9. $product->setTaxClassId(0); // Tax class id
  10. $product->setTypeId('simple'); // type of product (simple/virtual/downloadable/configurable)
  11. $product->setPrice(100); // price of product
  12. $product->setStockData(
  13. array(
  14. 'use_config_manage_stock' => 0,
  15. 'manage_stock' => 1,
  16. 'is_in_stock' => 1,
  17. 'qty' => 99999
  18. )
  19. );
  20. $product = $product->save();
  21.  
  22. $product->setStoreId(0); //1,2,3,4
  23.  
  24. $objectManager = MagentoFrameworkAppObjectManager::getInstance(); // instance of object manager
  25. $product = $objectManager->create('MagentoCatalogModelProduct');
  26. $product->setSku('my-sku11'); // Set your sku here
  27. $product->setName('Sample Simple Product11'); // Name of Product
  28. $product->setAttributeSetId(4); // Attribute set id
  29. $product->setStatus(1); // Status on product enabled/ disabled 1/0
  30. $product->setWeight(10); // weight of product
  31. $product->setVisibility(4); // visibilty of product (catalog / search / catalog, search / Not visible individually)
  32. $product->setTaxClassId(0); // Tax class id
  33. $product->setTypeId('simple'); // type of product (simple/virtual/downloadable/configurable)
  34. $product->setPrice(100); // price of product
  35. $product->setStockData(
  36. array(
  37. 'use_config_manage_stock' => 0,
  38. 'manage_stock' => 1,
  39. 'is_in_stock' => 1,
  40. 'qty' => 99999
  41. )
  42. );
  43. $product = $product->save();
  44.  
  45. $product->setHasOptions(1);
  46. $product->getResource()->save($product);
  47. $setStore = $objectManager->create('MagentoCatalogModelProductOption')
  48. ->setStoreId(0)
  49. $setStore->save();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement