Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
magento2-base
dev
tests
integration
testsuite
Magento
Catalog
_files
product_with_two_websites.php
Go to the documentation of this file.
1
<?php
7
use
Magento\Catalog\Api\Data\ProductInterface
;
8
9
$objectManager
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
();
11
$website
=
$objectManager
->get(
Magento
\Store\Model\Website::class);
12
13
$website
->setData(
14
[
15
'code'
=>
'second_website'
,
16
'name'
=>
'Test Website'
,
17
]
18
);
19
20
$website
->save();
21
22
$objectManager
->get(\
Magento
\Store\Model\StoreManagerInterface::class)->reinitStores();
23
25
$product
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()
26
->create(ProductInterface::class);
27
$product
28
->setTypeId(
'simple'
)
29
->setAttributeSetId(4)
30
->setWebsiteIds([1,
$website
->getId()])
31
->setName(
'Simple Product'
)
32
->setSku(
'unique-simple-azaza'
)
33
->setPrice(10)
34
->setMetaTitle(
'meta title'
)
35
->setMetaKeyword(
'meta keyword'
)
36
->setMetaDescription(
'meta description'
)
37
->setVisibility(\
Magento
\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
38
->setStatus(\
Magento
\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
39
->setStockData([
'use_config_manage_stock'
=> 0])
40
->save();
$objectManager
$objectManager
Definition:
product_with_two_websites.php:9
$product
$product
Definition:
product_with_two_websites.php:25
Magento
$website
$website
Definition:
product_with_two_websites.php:11
Magento\Catalog\Api\Data\ProductInterface
Definition:
ProductInterface.php:14
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125