Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
product_different_store_prices.php
Go to the documentation of this file.
1 <?php
14 
15 require __DIR__ . '/../../Store/_files/core_fixturestore.php';
16 
17 $objectManager = Bootstrap::getObjectManager();
18 
20 $indexerRegistry = $objectManager->create(IndexerRegistry::class);
21 $indexer = $indexerRegistry->get('catalogsearch_fulltext');
22 
23 $indexer->reindexAll();
24 
26 $product = $objectManager->create(Product::class);
27 $product->isObjectNew(true);
28 $product->setTypeId(Type::TYPE_SIMPLE)
29  ->setAttributeSetId(4)
30  ->setWebsiteIds([1])
31  ->setName('Simple Product')
32  ->setSku('tier_prices')
33  ->setPrice(10)
34  ->setWeight(1)
35  ->setShortDescription("Short description")
36  ->setTaxClassId(0)
37  ->setDescription('Description with <b>html tag</b>')
38  ->setMetaTitle('meta title')
39  ->setMetaKeyword('meta keyword')
40  ->setMetaDescription('meta description')
41  ->setVisibility(Visibility::VISIBILITY_BOTH)
42  ->setStatus(Status::STATUS_ENABLED)
43  ->setStockData(
44  [
45  'use_config_manage_stock' => 1,
46  'qty' => 100,
47  'is_qty_decimal' => 0,
48  'is_in_stock' => 1,
49  ]
50  );
51 
53 $productRepository = $objectManager->create(ProductRepositoryInterface::class);
55 
56 $product->setStoreId($store->getId());
57 $product->setPrice(15);
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60