PHP code example of honl / magento2-import
1. Go to this page and download the library: Download honl/magento2-import library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
honl / magento2-import example snippets
$items = [ ... ]; //Array of all products
/** @var \Ho\Import\RowModifier\ItemMapper $itemMapper */
$itemMapper = $this->itemMapperFactory->create([
'mapping' => [
'store_view_code' => \Ho\Import\RowModifier\ItemMapper::FIELD_EMPTY,
'sku' => function ($item) {
return $item['ItemCode'];
}
'name' => function ($item) {
return $item['NameField'] . $item['ColorCode'];
}
]
]);
$itemMapper->setItems($items);
$itemMapper->process($items); //The items array is modified with new values.