-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mbouchottbd/fixes/201811
Fixes/201811
- Loading branch information
Showing
12 changed files
with
418 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Monext\Payline\Model\Category\Attribute\Source; | ||
|
||
use Magento\Framework\Component\ComponentRegistrar; | ||
use Magento\Framework\File\Csv; | ||
use Monext\Payline\Helper\Constants as HelperConstants; | ||
|
||
/** | ||
* This class serve to map Magento Categories to Payline Categories : https://payline.atlassian.net/wiki/spaces/DT/pages/28901389/Codes+Category | ||
*/ | ||
class CategoryMapping extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource | ||
{ | ||
/** | ||
* @var \Magento\Framework\Component\ComponentRegistrar | ||
*/ | ||
protected $componentRegistrar; | ||
|
||
/** | ||
* @var \Magento\Framework\File\Csv | ||
*/ | ||
protected $csvReader; | ||
|
||
public function __construct( | ||
ComponentRegistrar $componentRegistrar, | ||
Csv $csvReader | ||
) | ||
{ | ||
$this->componentRegistrar = $componentRegistrar; | ||
$this->csvReader = $csvReader; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* @codeCoverageIgnore | ||
*/ | ||
public function getAllOptions() | ||
{ | ||
if (!$this->_options) { | ||
$this->_options = []; | ||
|
||
$csvFile = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, HelperConstants::MODULE_NAME) . '/fixtures/category_mapping.csv'; | ||
$rows = $this->csvReader->getData($csvFile); | ||
|
||
foreach ($rows as $row) { | ||
$this->_options[] = ['value' => $row[0], 'label' => __($row[1])]; | ||
} | ||
|
||
array_unshift($this->_options, ['value' => '', 'label' => __('Please select a category mapping...')]); | ||
} | ||
return $this->_options; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.