Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
product_export_with_product_links_data.php
Go to the documentation of this file.
1 <?php
7 require dirname(dirname(__DIR__)) . '/Catalog/_files/category.php';
9 require dirname(dirname(__DIR__)) . '/Store/_files/second_store.php';
11 require dirname(dirname(__DIR__)) . '/Catalog/_files/products_with_multiselect_attribute.php';
12 
14  \Magento\Catalog\Model\Product::class
15 );
16 
17 $productModel->setTypeId(
18  \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE
19 )->setId(
20  1
21 )->setAttributeSetId(
22  4
23 )->setName(
24  'New Product'
25 )->setSku(
26  'simple'
27 )->setPrice(
28  10
29 )->setTierPrice(
30  [0 => ['website_id' => 0, 'cust_group' => 0, 'price_qty' => 3, 'price' => 8]]
31 )->setVisibility(
32  \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
33 )->setStatus(
34  \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
35 )->setWebsiteIds(
36  [1]
37 )->setCategoryIds(
38  []
39 )->setStockData(
40  ['qty' => 100, 'is_in_stock' => 1, 'manage_stock' => 1]
41 )->setCanSaveCustomOptions(
42  true
43 )->setCategoryIds(
44  [333]
45 )->setUpSellLinkData(
46  [$product->getId() => ['position' => 1]]
47 )->setCrossSellLinkData(
48  [$product->getId() => ['position' => 2]]
49 )->setRelatedLinkData(
50  [$product->getId() => ['position' => 3]]
51 )->save();
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60