Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
category_duplicates.php
Go to the documentation of this file.
1 <?php
8 $category->isObjectNew(true);
9 $category->setId(
10  '444'
11 )->setName(
12  'Category 2'
13 )->setAttributeSetId(
14  '3'
15 )->setParentId(
16  2
17 )->setPath(
18  '1/2/444'
19 )->setLevel(
20  '2'
21 )->setDefaultSortBy(
22  'name'
23 )->setIsActive(
24  true
25 )->save();
26 
28  \Magento\Catalog\Model\Product::class
29 );
30 
31 $productModel->setTypeId(
32  \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE
33 )->setId(
34  1
35 )->setAttributeSetId(
36  4
37 )->setName(
38  'New Product'
39 )->setSku(
40  'simple3'
41 )->setPrice(
42  10
43 )->setTierPrice(
44  [0 => ['website_id' => 0, 'cust_group' => 0, 'price_qty' => 3, 'price' => 8]]
45 )->setVisibility(
46  \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
47 )->setStatus(
48  \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
49 )->setWebsiteIds(
50  [1]
51 )->setCategoryIds(
52  []
53 )->setStockData(
54  ['qty' => 100, 'is_in_stock' => 1, 'manage_stock' => 1]
55 )->setCategoryIds(
56  [444]
57 )->save();