Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Commit

Permalink
Fix the problem 'Attribute with the same code already exists'
Browse files Browse the repository at this point in the history
in attribute_user_defined_address_custom_attribute_rollback.php
Add signatures and unify style in naming of variables

Signed-off-by: Tomash Khamlai <[email protected]>
  • Loading branch information
TomashKhamlai committed Oct 18, 2019
1 parent 68c48d5 commit bcdd17d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* See COPYING.txt for license details.
*/

$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Customer\Model\Attribute::class);
$model->setName(
/** @var \Magento\Customer\Model\Attribute $model1 */
$model1 = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Customer\Model\Attribute::class);
$model1->setName(
'custom_attribute1'
)->setEntityTypeId(
2
Expand All @@ -20,8 +21,9 @@
)->setIsUserDefined(
1
);
$model->save();
$model1->save();

/** @var \Magento\Customer\Model\Attribute $model2 */
$model2 = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Customer\Model\Attribute::class);
$model2->setName(
'custom_attribute2'
Expand All @@ -45,10 +47,10 @@
\Magento\Customer\Setup\CustomerSetup::class
);

$data = [['form_code' => 'customer_address_edit', 'attribute_id' => $model->getAttributeId()]];
$data1 = [['form_code' => 'customer_address_edit', 'attribute_id' => $model1->getAttributeId()]];
$setupResource->getSetup()->getConnection()->insertMultiple(
$setupResource->getSetup()->getTable('customer_form_attribute'),
$data
$data1
);

$data2 = [['form_code' => 'customer_address_edit', 'attribute_id' => $model2->getAttributeId()]];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* See COPYING.txt for license details.
*/

$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Customer\Model\Attribute::class);
$model->load('custom_attribute_test', 'attribute_code')->delete();

$model2 = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Customer\Model\Attribute::class);
$model2->load('custom_attributes_test', 'attribute_code')->delete();
/** @var \Magento\Customer\Model\Attribute $attributeModel */
$attributeModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Customer\Model\Attribute::class);
$attributeModel->load('custom_attribute1', 'attribute_code')->delete();
$attributeModel->load('custom_attribute2', 'attribute_code')->delete();

0 comments on commit bcdd17d

Please sign in to comment.