-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge forwardport of #12283 to 2.3-develop branch
Applied pull request patch https://github.com/magento/magento2/pull/12283.patch (created by @p-bystritsky) based on commit(s): 1. 41e9ec0 2. 89d613c Fixed GitHub Issues in 2.3-develop branch: - #12083: Cannot import zero (0) value into custom attribute (reported by @gwilliams01)
- Loading branch information
Showing
4 changed files
with
124 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...tegration/testsuite/Magento/CatalogImportExport/Model/Import/_files/custom_attributes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); | ||
|
||
/** @var \Magento\Eav\Model\Entity\Type $entityType */ | ||
$entityType = $objectManager->create(\Magento\Eav\Model\Entity\Type::class); | ||
$entityType->loadByCode('catalog_product'); | ||
$entityTypeId = $entityType->getId(); | ||
|
||
/** @var \Magento\Eav\Model\Entity\Attribute\Set $attributeSet */ | ||
$attributeSet = $objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class); | ||
$attributeSet->load('default', 'attribute_set_name'); | ||
$attributeSetId = $attributeSet->getId(); | ||
|
||
$attributeGroupId = $attributeSet->getDefaultGroupId($entityType->getDefaultAttributeSetId()); | ||
|
||
$attributeData = [ | ||
[ | ||
'attribute_code' => 'test_attribute', | ||
'entity_type_id' => $entityTypeId, | ||
'backend_type' => 'varchar', | ||
'is_required' => 1, | ||
'is_user_defined' => 1, | ||
'is_unique' => 0, | ||
'attribute_set_id' => $attributeSetId, | ||
'attribute_group_id' => $attributeGroupId, | ||
], | ||
]; | ||
|
||
foreach ($attributeData as $data) { | ||
/** @var \Magento\Eav\Model\Entity\Attribute $attribute */ | ||
$attribute = $objectManager->create(\Magento\Eav\Model\Entity\Attribute::class); | ||
$attribute->setData($data); | ||
$attribute->setIsStatic(true); | ||
$attribute->save(); | ||
} |
20 changes: 20 additions & 0 deletions
20
.../testsuite/Magento/CatalogImportExport/Model/Import/_files/custom_attributes_rollback.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); | ||
|
||
$attributeCodes = [ | ||
'test_attribute', | ||
]; | ||
|
||
foreach ($attributeCodes as $attributeCode) { | ||
/** @var \Magento\Eav\Model\Entity\Attribute $attribute */ | ||
$attribute = $objectManager->create(\Magento\Eav\Model\Entity\Attribute::class); | ||
$attribute->loadByCode('catalog_product', $attributeCode); | ||
if ($attribute->getId()) { | ||
$attribute->delete(); | ||
} | ||
} |