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
Model
ResourceModel
_files
few_simple_products.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
use
Magento\TestFramework\Helper\Bootstrap
;
9
use Magento\Catalog\Model\ProductFactory;
10
use
Magento\Catalog\Api\ProductRepositoryInterface
;
11
13
$objectManager
= Bootstrap::getObjectManager();
14
16
$productFactory
=
$objectManager
->create(ProductFactory::class);
17
19
$productRepository
=
$objectManager
->create(ProductRepositoryInterface::class);
20
21
// Create 10 products (with change this variable, don't forget to change the same in rollback)
22
$productsAmount
= 10;
23
24
for
(
$i
= 1;
$i
<=
$productsAmount
;
$i
++) {
25
$productArray = [
26
'data'
=> [
27
'name'
=>
"Product{$i}"
,
28
'sku'
=>
"Product{$i}"
,
29
'price'
=> 100,
30
'attribute_set_id'
=> 4,
31
'website_ids'
=> [1]
32
]
33
];
34
35
$productRepository
->save(
$productFactory
->create($productArray));
36
}
$objectManager
$objectManager
Definition:
few_simple_products.php:13
Magento\TestFramework\Helper\Bootstrap
Definition:
Bootstrap.php:12
$productRepository
$productRepository
Definition:
few_simple_products.php:19
Magento\Catalog\Api\ProductRepositoryInterface
Definition:
ProductRepositoryInterface.php:14
$productsAmount
$productsAmount
Definition:
few_simple_products.php:22
$productFactory
$productFactory
Definition:
few_simple_products.php:16
$i
$i
Definition:
gallery.phtml:31