-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
80 changed files
with
2,764 additions
and
151 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
50 changes: 50 additions & 0 deletions
50
Block/Adminhtml/Ebay/Settings/Tabs/AttributeMapping/GroupedAttributesFieldsetFill.php
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,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ess\M2ePro\Block\Adminhtml\Ebay\Settings\Tabs\AttributeMapping; | ||
|
||
class GroupedAttributesFieldsetFill | ||
{ | ||
private \Ess\M2ePro\Helper\Magento\Attribute $attributeHelper; | ||
private \Ess\M2ePro\Model\Ebay\AttributeMapping\GroupedService $groupedProductService; | ||
|
||
public function __construct( | ||
\Ess\M2ePro\Helper\Magento\Attribute $attributeHelper, | ||
\Ess\M2ePro\Model\Ebay\AttributeMapping\GroupedService $groupedProductService | ||
) { | ||
$this->attributeHelper = $attributeHelper; | ||
$this->groupedProductService = $groupedProductService; | ||
} | ||
|
||
public function fill(\Magento\Framework\Data\Form\Element\Fieldset $fieldset): void | ||
{ | ||
$attributesTextType = $this->attributeHelper->filterAllAttrByInputTypes(['text', 'select']); | ||
|
||
$preparedAttributes = []; | ||
foreach ($attributesTextType as $attribute) { | ||
$preparedAttributes[] = [ | ||
'value' => $attribute['code'], | ||
'label' => $attribute['label'], | ||
]; | ||
} | ||
|
||
foreach ($this->groupedProductService->getAll() as $pair) { | ||
$config = [ | ||
'label' => $pair->channelAttributeTitle, | ||
'title' => $pair->channelAttributeTitle, | ||
'name' => sprintf('grouped_attributes[%s]', $pair->channelAttributeCode), | ||
'values' => [ | ||
'' => __('None'), | ||
[ | ||
'label' => __('Magento Attributes'), | ||
'value' => $preparedAttributes, | ||
], | ||
], | ||
'value' => $pair->value ?? '', | ||
]; | ||
|
||
$fieldset->addField($pair->channelAttributeCode, 'select', $config); | ||
} | ||
} | ||
} |
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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ess\M2ePro\Block\Adminhtml\Magento\Form\Element; | ||
|
||
class Multiselect extends \Magento\Framework\Data\Form\Element\Multiselect | ||
{ | ||
public function __construct( | ||
\Magento\Framework\Data\Form\Element\Factory $factoryElement, | ||
\Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection, | ||
\Magento\Framework\Escaper $escaper, | ||
$data = [], | ||
?\Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer = null, | ||
?\Magento\Framework\Math\Random $random = null | ||
) { | ||
parent::__construct( | ||
$factoryElement, | ||
$factoryCollection, | ||
$escaper, | ||
$data, | ||
$secureRenderer, | ||
$random | ||
); | ||
|
||
$this->setSize($data['size'] ?? 10); | ||
} | ||
} |
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
70 changes: 70 additions & 0 deletions
70
Block/Adminhtml/Walmart/Settings/Tabs/AttributeMapping.php
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,70 @@ | ||
<?php | ||
|
||
namespace Ess\M2ePro\Block\Adminhtml\Walmart\Settings\Tabs; | ||
|
||
class AttributeMapping extends \Ess\M2ePro\Block\Adminhtml\Magento\Form\AbstractForm | ||
{ | ||
private \Ess\M2ePro\Block\Adminhtml\Walmart\Settings\Tabs\AttributeMapping\VariationAttributesFieldsetFill $variationAttributesFieldsetFill; | ||
|
||
public function __construct( | ||
\Ess\M2ePro\Block\Adminhtml\Walmart\Settings\Tabs\AttributeMapping\VariationAttributesFieldsetFill $variationAttributesFieldsetFill, | ||
\Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context, | ||
\Magento\Framework\Registry $registry, | ||
\Magento\Framework\Data\FormFactory $formFactory, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $registry, $formFactory, $data); | ||
$this->variationAttributesFieldsetFill = $variationAttributesFieldsetFill; | ||
} | ||
|
||
protected function _prepareForm() | ||
{ | ||
$form = $this->_formFactory->create([ | ||
'data' => [ | ||
'method' => 'post', | ||
'action' => $this->getUrl('*/*/save'), | ||
], | ||
]); | ||
|
||
// ---------------------------------------- | ||
|
||
$this->addVariationAttributesFieldset($form); | ||
|
||
// ---------------------------------------- | ||
|
||
$form->setUseContainer(true); | ||
$this->setForm($form); | ||
|
||
return parent::_prepareForm(); | ||
} | ||
|
||
protected function _beforeToHtml() | ||
{ | ||
$this->jsUrl->add( | ||
$this->getUrl('*/walmart_settings_attributeMapping/save'), | ||
\Ess\M2ePro\Block\Adminhtml\Walmart\Settings\Tabs::TAB_ID_ATTRIBUTE_MAPPING | ||
); | ||
|
||
return parent::_beforeToHtml(); | ||
} | ||
|
||
private function addVariationAttributesFieldset(\Magento\Framework\Data\Form $form): void | ||
{ | ||
$tooltipMessage = __( | ||
'In the Variation Attributes section of the Attribute Mapping settings, ' . | ||
'you can set default mappings between your Magento variation attribute options and the valid ' . | ||
'variation options on Walmart. For example, if your product has a variation attribute like "Color," ' . | ||
'you can ensure that the specific variation options (e.g., "black," "white," "yellow," "blue") ' . | ||
'in Magento are accurately matched to the corresponding options on Walmart. This helps to ' . | ||
'streamline the listing and management of product variations across both platforms.' | ||
); | ||
|
||
$fieldset = $form->addFieldset('variation_attributes', [ | ||
'legend' => __('Variation Attributes'), | ||
'tooltip' => $tooltipMessage, | ||
'collapsable' => true, | ||
]); | ||
|
||
$this->variationAttributesFieldsetFill->fill($fieldset); | ||
} | ||
} |
Oops, something went wrong.