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
setup
src
Magento
Setup
Model
FixtureGenerator
ProductTemplateGeneratorFactory.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Setup\Model\FixtureGenerator
;
8
9
use
Magento\Bundle\Model\Product\Type
as BundleType;
10
use
Magento\Catalog\Model\Product\Type
;
11
use
Magento\ConfigurableProduct\Model\Product\Type\Configurable
;
12
use
Magento\Framework\ObjectManagerInterface
;
13
17
class
ProductTemplateGeneratorFactory
18
{
22
private
$objectManager;
23
27
private
$templateEntityMap = [
28
Type::TYPE_SIMPLE
=> SimpleProductTemplateGenerator::class,
29
BundleType::TYPE_CODE => BundleProductTemplateGenerator::class,
30
Configurable::TYPE_CODE
=> ConfigurableProductTemplateGenerator::class,
31
];
32
36
public
function
__construct
(
ObjectManagerInterface
$objectManager)
37
{
38
$this->objectManager =
$objectManager
;
39
}
40
46
public
function
create
(array $fixture)
47
{
48
$type
= isset($fixture[
'type_id'
]) ? $fixture[
'type_id'
] :
Type::TYPE_SIMPLE
;
49
if
(!isset($this->templateEntityMap[
$type
])) {
50
throw
new \InvalidArgumentException(sprintf(
51
'Cannot instantiate product template generator. Wrong type_id "%s" passed'
,
52
$type
53
));
54
}
55
56
return
$this->objectManager->create($this->templateEntityMap[
$type
], [
'fixture'
=> $fixture]);
57
}
58
}
Magento\Catalog\Model\Product\Type\TYPE_SIMPLE
const TYPE_SIMPLE
Definition:
Type.php:22
Magento\Bundle\Model\Product\Type
Definition:
Type.php:25
$objectManager
$objectManager
Definition:
bootstrap.php:17
Magento\Framework\ObjectManagerInterface
Definition:
ObjectManagerInterface.php:12
Magento\ConfigurableProduct\Model\Product\Type\Configurable\TYPE_CODE
const TYPE_CODE
Definition:
Configurable.php:35
Magento\Setup\Model\FixtureGenerator
Definition:
ProductGeneratorTest.php:7
$type
$type
Definition:
item.phtml:13
Magento\ConfigurableProduct\Model\Product\Type\Configurable
Definition:
AttributeTest.php:6
Magento\Setup\Model\FixtureGenerator\ProductTemplateGeneratorFactory\__construct
__construct(ObjectManagerInterface $objectManager)
Definition:
ProductTemplateGeneratorFactory.php:36
Magento\Setup\Model\FixtureGenerator\ProductTemplateGeneratorFactory
Definition:
ProductTemplateGeneratorFactory.php:17
Magento\Setup\Model\FixtureGenerator\ProductTemplateGeneratorFactory\create
create(array $fixture)
Definition:
ProductTemplateGeneratorFactory.php:46
Magento\Catalog\Model\Product\Type
Definition:
AbstractTypeTest.php:7