magento / magento/data-migration-tool
Undefined offset in Migration/Handler/VisualMerchandiser/SmartAttribute.php on line 30
- Dominant language
- PHP
- Stars
- 339
- Forks
- 195
- PR merge metrics
- No merged PRs in 30d
Description
## Environment Information:
**Data Migration Tool Version:** 2.1.3
**Mode:** data
**Step:** VisualMerchandiser Step
**Sub-step:** data
**Source Database Version:** Magento EE 1.14.2.0
**Destination Database Version:** Magento EE 2.1.3
## Summary:
If a category's visual merchandiser has been configured to use the same attribute code more than once for that category, the data migration tool will pass the integrity check but fail in data migration due to undefined index.
## Additional Information:
Consider the following setup on a category:

The values for this configuration in the `merchandiser_category_values` table of the `MapInterface::TYPE_SOURCE` database will be as follows:
attribute_codes: name
smart_attributes: a:2:{s:18:"_1484069909215_215";a:3:{s:9:"attribute";s:2:"65";s:5:"value";s:3:"Foo";s:4:"link";s:2:"OR";}s:18:"_1484069916735_735";a:3:{s:9:"attribute";s:2:"65";s:5:"value";s:3:"Bar";s:4:"link";s:2:"OR";}}
Come migration time, the data migration tool expects the number of comma separated attribute_codes and the size of the serialized array to match. However because the attribute_codes are only stored uniquely in the source database, they will not match if used more than once.
**Migration\Handler\VisualMerchandiser\SmartAttribute::handle()**
The size of [$attributeCodeArr](https://github.com/magento/data-migration-tool/blob/master/src/Migration/Handler/VisualMerchandiser/SmartAttribute.php#L25) and [$attributeValues](https://github.com/magento/data-migration-tool/blob/master/src/Migration/Handler/VisualMerchandiser/SmartAttribute.php#L26) will not match, causing an error to be thrown on [line 30](https://github.com/magento/data-migration-tool/blob/master/src/Migration/Handler/VisualMerchandiser/SmartAttribute.php#L30).
[Exception]
Notice: Undefined offset: 1 in /path/to/install/vendor/magento/data-migration-tool/src/Migration/Handler/VisualMerchandiser/SmartAttribute.php on line 30
Contributor guide
Research direction
Start in src/Migration/Handler/VisualMerchandiser/SmartAttribute.php, especially handle() and the attributeCodeArr and attributeValues handling around line 30. Trace how duplicate attribute codes are read from merchandiser_category_values and verify the migration no longer raises an undefined offset when the serialized values contain repeated attributes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100