Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
AttributeSetsFixture Class Reference
Inheritance diagram for AttributeSetsFixture:
Fixture

Public Member Functions

 __construct (FixtureModel $fixtureModel, AttributeSet\AttributeSetFixture $attributeSetsFixture, \Magento\Setup\Fixtures\AttributeSet\Pattern $pattern)
 
 execute ()
 
 getActionTitle ()
 
 introduceParamLabels ()
 
- Public Member Functions inherited from Fixture
 __construct (FixtureModel $fixtureModel)
 
 execute ()
 
 getActionTitle ()
 
 printInfo (OutputInterface $output)
 
 introduceParamLabels ()
 
 getPriority ()
 

Data Fields

const PRODUCT_SET_NAME = 'Product Set '
 

Protected Attributes

 $priority = 25
 
- Protected Attributes inherited from Fixture
 $priority
 
 $fixtureModel
 

Detailed Description

Fixture for Attribute Sets and Attributes based on the configuration

Support the following format:

<product_attribute_sets>{int}</product_attribute_sets>

<product_attribute_sets_attributes>{int}</product_attribute_sets_attributes>

<product_attribute_sets_attributes_values>{int}</product_attribute_sets_attributes_values>

See also
setup/performance-toolkit/profiles/ce/small.xml

Definition at line 24 of file AttributeSetsFixture.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( FixtureModel  $fixtureModel,
AttributeSet\AttributeSetFixture  $attributeSetsFixture,
\Magento\Setup\Fixtures\AttributeSet\Pattern  $pattern 
)
Parameters
FixtureModel$fixtureModel
AttributeSet\AttributeSetFixture$attributeSetsFixture
AttributeSet\Pattern$pattern

Definition at line 49 of file AttributeSetsFixture.php.

53  {
54  parent::__construct($fixtureModel);
55  $this->attributeSetsFixture = $attributeSetsFixture;
56  $this->pattern = $pattern;
57  }
$pattern
Definition: website.php:22

Member Function Documentation

◆ execute()

execute ( )

{}

Definition at line 62 of file AttributeSetsFixture.php.

63  {
64  $attributeSets = $this->fixtureModel->getValue('attribute_sets', null);
65  if ($attributeSets !== null) {
66  foreach ($attributeSets['attribute_set'] as $attributeSetData) {
67  $this->attributeSetsFixture->createAttributeSet($attributeSetData);
68  }
69  }
70 
71  $attributeSetsCount = $this->fixtureModel->getValue('product_attribute_sets', null);
72  if ($attributeSetsCount !== null) {
73  for ($index = 1; $index <= $attributeSetsCount; $index++) {
74  $this->attributeSetsFixture->createAttributeSet(
75  $this->pattern->generateAttributeSet(
76  self::PRODUCT_SET_NAME . $index,
77  $this->fixtureModel->getValue('product_attribute_sets_attributes', 3),
78  $this->fixtureModel->getValue('product_attribute_sets_attributes_values', 3),
79  function ($attributeIndex, $attribute) use ($index) {
80  return array_replace_recursive(
81  $attribute,
82  [
83  'attribute_code' => "attribute_set{$index}_" . $attributeIndex,
84  ]
85  );
86  }
87  )
88  );
89  }
90  }
91  }
$index
Definition: list.phtml:44

◆ getActionTitle()

getActionTitle ( )

{}

Definition at line 96 of file AttributeSetsFixture.php.

97  {
98  return 'Generating attribute sets';
99  }

◆ introduceParamLabels()

introduceParamLabels ( )

{}

Definition at line 104 of file AttributeSetsFixture.php.

105  {
106  return [
107  'attribute_sets' => 'Attribute Sets (Default)',
108  'product_attribute_sets' => 'Attribute Sets (Extra)'
109  ];
110  }

Field Documentation

◆ $priority

$priority = 25
protected

Definition at line 32 of file AttributeSetsFixture.php.

◆ PRODUCT_SET_NAME

const PRODUCT_SET_NAME = 'Product Set '

Name of generated attribute set

Definition at line 27 of file AttributeSetsFixture.php.


The documentation for this class was generated from the following file: