|
5 | 5 | */
|
6 | 6 | declare(strict_types=1);
|
7 | 7 |
|
| 8 | +use Magento\Catalog\Model\Product; |
8 | 9 | use Magento\Eav\Api\AttributeRepositoryInterface;
|
| 10 | +use Magento\Eav\Model\Config; |
9 | 11 | use Magento\Eav\Model\Entity\Attribute\FrontendLabel;
|
10 | 12 | use Magento\TestFramework\Helper\Bootstrap;
|
| 13 | +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; |
11 | 14 |
|
12 |
| -require __DIR__ . '/configurable_products.php'; |
| 15 | +Resolver::getInstance()->requireDataFixture('Magento/ConfigurableProduct/_files/configurable_products.php'); |
13 | 16 |
|
| 17 | +$objectManager = Bootstrap::getObjectManager(); |
| 18 | +/** @var AttributeRepositoryInterface $attributeRepository */ |
| 19 | +$attributeRepository = $objectManager->create(AttributeRepositoryInterface::class); |
14 | 20 | // Add frontend label to created attribute:
|
15 |
| -$frontendLabelAttribute = Bootstrap::getObjectManager()->get(FrontendLabel::class); |
| 21 | +$frontendLabelAttribute = $objectManager->get(FrontendLabel::class); |
16 | 22 | $frontendLabelAttribute->setStoreId(1);
|
17 | 23 | $frontendLabelAttribute->setLabel('Default Store View label');
|
18 |
| - |
| 24 | +/** @var Config $eavConfig */ |
| 25 | +$eavConfig = $objectManager->get(Config::class); |
| 26 | +$attribute = $eavConfig->getAttribute(Product::ENTITY, 'test_configurable'); |
19 | 27 | $frontendLabels = $attribute->getFrontendLabels();
|
20 | 28 | $frontendLabels[] = $frontendLabelAttribute;
|
21 | 29 |
|
22 | 30 | $attribute->setFrontendLabels($frontendLabels);
|
23 |
| -$attributeRepository = Bootstrap::getObjectManager()->create(AttributeRepositoryInterface::class); |
24 | 31 | $attributeRepository->save($attribute);
|
0 commit comments