6 declare(strict_types=1);
14 $installer = Bootstrap::getObjectManager()->create(\
Magento\Catalog\Setup\CategorySetup::class);
17 'attribute_code' =>
'color_swatch',
18 'entity_type_id' =>
$installer->getEntityTypeId(
'catalog_product'),
20 'is_user_defined' => 1,
21 'frontend_input' =>
'select',
25 'is_visible_in_advanced_search' => 1,
28 'is_filterable_in_search' => 1,
29 'is_used_for_promo_rules' => 0,
30 'is_html_allowed_on_front' => 1,
31 'is_visible_on_front' => 1,
32 'used_in_product_listing' => 1,
33 'used_for_sort_by' => 1,
34 'frontend_label' => [
'Test Swatch'],
35 'backend_type' =>
'int',
36 'use_product_image_for_swatch' => 0,
37 'update_product_preview_image' => 0,
41 $data[
'swatch_input_type'] =
'visual';
42 $data[
'swatchvisual'][
'value'] = array_reduce(
54 $data[
'optionvisual'][
'value'] = array_reduce(
63 $data[
'options'][
'option'] = array_reduce(
67 'label' =>
'option ' .
$index,
68 'value' =>
'option_' .
$index,
83 \
Magento\Catalog\Api\Data\ProductAttributeInterface::class,
110 ->setAttributeSetId(4)
111 ->setName(
'Simple Product1')
113 ->setTaxClassId(
'none')
114 ->setDescription(
'description')
115 ->setShortDescription(
'short description')
116 ->setOptionsContainer(
'container1')
117 ->setMsrpDisplayActualPriceType(\
Magento\Msrp\Model\Product\Attribute\Source\Type::TYPE_IN_CART)
120 ->setMetaTitle(
'meta title')
121 ->setMetaKeyword(
'meta keyword')
122 ->setMetaDescription(
'meta description')
123 ->setVisibility(\
Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
124 ->setStatus(\
Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
127 ->setStockData([
'use_config_manage_stock' => 1,
'qty' => 100,
'is_qty_decimal' => 0,
'is_in_stock' => 1])
128 ->setSpecialPrice(
'5.99')
135 ->setAttributeSetId(4)
136 ->setName(
'Simple Product2')
138 ->setTaxClassId(
'none')
139 ->setDescription(
'description')
140 ->setShortDescription(
'short description')
141 ->setOptionsContainer(
'container1')
142 ->setMsrpDisplayActualPriceType(\
Magento\Msrp\Model\Product\Attribute\Source\Type::TYPE_ON_GESTURE)
145 ->setMetaTitle(
'meta title')
146 ->setMetaKeyword(
'meta keyword')
147 ->setMetaDescription(
'meta description')
148 ->setVisibility(\
Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
149 ->setStatus(\
Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
152 ->setStockData([
'use_config_manage_stock' => 1,
'qty' => 50,
'is_qty_decimal' => 0,
'is_in_stock' => 1])
153 ->setSpecialPrice(
'15.99')
160 ->setAttributeSetId(4)
161 ->setName(
'Simple Product3')
163 ->setTaxClassId(
'none')
164 ->setDescription(
'description')
165 ->setShortDescription(
'short description')
168 ->setVisibility(\
Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
169 ->setStatus(\
Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
172 ->setStockData([
'use_config_manage_stock' => 1,
'qty' => 140,
'is_qty_decimal' => 0,
'is_in_stock' => 1])
173 ->setSpecialPrice(
'25.99')
181 '2014-06-23 09:50:07' 190 )->setAvailableSortBy(
198 )->setPostedProducts(
199 [10 => 10, 11 => 11, 12 => 12]
foreach($data['options']['option'] as $optionData) $attribute
static getObjectManager()