Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ php:
- 7.1
- 7.2
- 7.3
- 7.4

before_script:
- sudo apt-get install libxml2-utils
Expand Down
38 changes: 36 additions & 2 deletions Model/Product/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class Attribute implements \Mygento\ImportExport\Api\AttributeInterface
*/
private $repository;

/**
* @var \Magento\Catalog\Api\ProductAttributeRepositoryInterface
*/
private $productAttributeRepository;

/**
* @param \Magento\Catalog\Model\Product\Attribute\OptionManagement $repository
* @param \Magento\Eav\Api\Data\AttributeOptionLabelInterfaceFactory $optionLabelFactory
Expand All @@ -36,11 +41,13 @@ class Attribute implements \Mygento\ImportExport\Api\AttributeInterface
public function __construct(
\Magento\Catalog\Model\Product\Attribute\OptionManagement $repository,
\Magento\Eav\Api\Data\AttributeOptionLabelInterfaceFactory $optionLabelFactory,
\Magento\Eav\Api\Data\AttributeOptionInterfaceFactory $optionFactory
\Magento\Eav\Api\Data\AttributeOptionInterfaceFactory $optionFactory,
\Magento\Catalog\Api\ProductAttributeRepositoryInterface $productAttributeRepository
) {
$this->repository = $repository;
$this->optionLabelFactory = $optionLabelFactory;
$this->optionFactory = $optionFactory;
$this->productAttributeRepository = $productAttributeRepository;
}

/**
Expand Down Expand Up @@ -84,14 +91,41 @@ public function createDropdownAttributeOptions(
}

/**
* TODO
* @param \Magento\ImportExport\Model\Import\AbstractSource $source
* @param array $attibutes
*/
public function createMultiselectAttributeOptions(
\Magento\ImportExport\Model\Import\AbstractSource $source,
array $attibutes
) {
$source->rewind();

while ($source->valid()) {
$row = $source->current();

foreach ($attibutes as $attributeCode) {
$attribute = $this->productAttributeRepository->get($attributeCode);

if ($attribute->getFrontendInput() == 'multiselect') {
$options = $this->getAttributeOptions($attributeCode);
$newOptions = explode(\Magento\ImportExport\Model\Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $row[$attributeCode]);

foreach ($newOptions as $newOption) {
if (!isset($newOption) || !strlen(trim($newOption))) {
continue;
}
if (in_array($newOption, $options)) {
continue;
}
$this->createAttributeOption($attributeCode, $row[$attributeCode]);
}

}
}

$source->next();
}

unset($source);
unset($attibutes);
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Magento 2 Import Export Array Adapter
## Configuration

## Compability
The module is tested on magento version 2.3.x
The module is tested on magento version 2.4.x
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mygento/module-import-export",
"type": "magento2-module",
"version": "2.3.1",
"version": "2.4.0",
"license": "OSL-3.0",
"homepage": "https://github.com/mygento/module-import-export",
"description": "Magento 2 import export array adapter",
Expand All @@ -23,12 +23,11 @@
"mygento"
],
"require": {
"magento/module-catalog-import-export": "101.0.*",
"magento/module-configurable-import-export": "100.3.*"
"magento/module-catalog-import-export": "101.1.*",
"magento/module-configurable-import-export": "100.4.*"
},
"require-dev": {
"mygento/coding-standard": "~2.13.5",
"magento/magento-coding-standard": "~4.0.0"
"mygento/coding-standard": "~2.14.0-beta1"
},
"autoload": {
"files": [
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Mygento_ImportExport" setup_version="2.3.1" />
<module name="Mygento_ImportExport" />
</config>