Fix class NestedArrayAdapter in method convertToArray
This is my solution and work for me ;)
Model/Adapters/NestedArrayAdapter.php
protected function convertToArray(&$line)
{
$implodeStr = $this->multipleValueSeparator;
$arr = array_map(
function ($value, $key) use (&$implodeStr) {
if (is_array($value) && is_numeric($key)) {
$this->convertToArray($value);
$implodeStr = '|';
return $value;
}
//FIX
elseif(is_numeric($key) && !is_array($value)) {
return $value;
}
return sprintf("%s=%s", $key, $value);
//END FIX
},
$line,
array_keys($line)
);
$line = implode(
$implodeStr, $arr
);
}
@EliasKotlyar, since you wrote the NestedArrayAdapter, mind having a look here? For me, the NestedArrayAdapter also does not work due to this issue. I really wonder about that part:
return sprintf("%s=%s", $key, $value);
In which case does that lead to valid data?
In my case, I simply try to import a product with the following attribute:
'product_websites' => ['base', 'base2']
However, this currently leads to 0=base,1=base2, which is invalid data.
@avstudnitz, any experiences / thoughts?
@EliasKotlyar @avstudnitz mind giving feedback here? Thanks!
I think I never used the NestedArrayAdapter with Magento 2. What you write sounds reasonable, and if it fixes the problem, it's good for me.
I agree with @avstudnitz. Havent been using that import/export feature a lot.
Regarding this Problem: It seems that m2 expects this data-structure. So this "sprintf" is a dirty hack for generating it. It might have changed in newer magento2 versions. When it was developed(for m2 beta), it was "state of the art". Cannot tell you what exactly the "state of the art" is now, because i havent been using m2 for more than 2 years.