Skip to content

Commit 736a766

Browse files
committed
1.73.0 (FINAL RELEASE)
1 parent f8ddf86 commit 736a766

File tree

80 files changed

+2764
-151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2764
-151
lines changed

Block/Adminhtml/Ebay/Settings/Tabs/AttributeMapping.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,22 @@ class AttributeMapping extends \Ess\M2ePro\Block\Adminhtml\Magento\Form\Abstract
1010
private AttributeMapping\BundleAttributesFieldsetFill $variationOptionFieldsetFill;
1111
/** @var \Ess\M2ePro\Block\Adminhtml\Ebay\Settings\Tabs\AttributeMapping\GpsrAttributesFieldsetFill */
1212
private AttributeMapping\GpsrAttributesFieldsetFill $gpsrAttributesFieldsetFill;
13+
/** @var \Ess\M2ePro\Block\Adminhtml\Ebay\Settings\Tabs\AttributeMapping\GroupedAttributesFieldsetFill */
14+
private AttributeMapping\GroupedAttributesFieldsetFill $groupedAttributesFieldsetFill;
1315

1416
public function __construct(
1517
AttributeMapping\BundleAttributesFieldsetFill $variationOptionFieldsetFill,
1618
AttributeMapping\GpsrAttributesFieldsetFill $gpsrAttributesFieldsetFill,
19+
AttributeMapping\GroupedAttributesFieldsetFill $groupedAttributesFieldsetFill,
1720
\Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context,
1821
\Magento\Framework\Registry $registry,
1922
\Magento\Framework\Data\FormFactory $formFactory,
2023
array $data = []
2124
) {
2225
$this->variationOptionFieldsetFill = $variationOptionFieldsetFill;
2326
$this->gpsrAttributesFieldsetFill = $gpsrAttributesFieldsetFill;
27+
$this->groupedAttributesFieldsetFill = $groupedAttributesFieldsetFill;
28+
2429
parent::__construct($context, $registry, $formFactory, $data);
2530
}
2631

@@ -36,6 +41,7 @@ protected function _prepareForm()
3641
// ----------------------------------------
3742
$this->addGpsrAttributesFieldset($form);
3843
$this->addBundleAttributesFieldset($form);
44+
$this->addGroupedAttributesFieldset($form);
3945
// ----------------------------------------
4046

4147
$form->setUseContainer(true);
@@ -72,10 +78,22 @@ private function addBundleAttributesFieldset(\Magento\Framework\Data\Form $form)
7278
$fieldset = $form->addFieldset(
7379
'bundle_attributes',
7480
[
75-
'legend' => __('Bundle Attributes'),
81+
'legend' => __('Bundle Product Attributes'),
7682
'collapsable' => true,
7783
]
7884
);
7985
$this->variationOptionFieldsetFill->fill($fieldset);
8086
}
87+
88+
private function addGroupedAttributesFieldset(\Magento\Framework\Data\Form $form): void
89+
{
90+
$fieldset = $form->addFieldset(
91+
'grouped_attributes',
92+
[
93+
'legend' => __('Grouped Product Attributes'),
94+
'collapsable' => true,
95+
]
96+
);
97+
$this->groupedAttributesFieldsetFill->fill($fieldset);
98+
}
8199
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Ess\M2ePro\Block\Adminhtml\Ebay\Settings\Tabs\AttributeMapping;
6+
7+
class GroupedAttributesFieldsetFill
8+
{
9+
private \Ess\M2ePro\Helper\Magento\Attribute $attributeHelper;
10+
private \Ess\M2ePro\Model\Ebay\AttributeMapping\GroupedService $groupedProductService;
11+
12+
public function __construct(
13+
\Ess\M2ePro\Helper\Magento\Attribute $attributeHelper,
14+
\Ess\M2ePro\Model\Ebay\AttributeMapping\GroupedService $groupedProductService
15+
) {
16+
$this->attributeHelper = $attributeHelper;
17+
$this->groupedProductService = $groupedProductService;
18+
}
19+
20+
public function fill(\Magento\Framework\Data\Form\Element\Fieldset $fieldset): void
21+
{
22+
$attributesTextType = $this->attributeHelper->filterAllAttrByInputTypes(['text', 'select']);
23+
24+
$preparedAttributes = [];
25+
foreach ($attributesTextType as $attribute) {
26+
$preparedAttributes[] = [
27+
'value' => $attribute['code'],
28+
'label' => $attribute['label'],
29+
];
30+
}
31+
32+
foreach ($this->groupedProductService->getAll() as $pair) {
33+
$config = [
34+
'label' => $pair->channelAttributeTitle,
35+
'title' => $pair->channelAttributeTitle,
36+
'name' => sprintf('grouped_attributes[%s]', $pair->channelAttributeCode),
37+
'values' => [
38+
'' => __('None'),
39+
[
40+
'label' => __('Magento Attributes'),
41+
'value' => $preparedAttributes,
42+
],
43+
],
44+
'value' => $pair->value ?? '',
45+
];
46+
47+
$fieldset->addField($pair->channelAttributeCode, 'select', $config);
48+
}
49+
}
50+
}

Block/Adminhtml/Ebay/Template/Description/Edit/Form/ComplianceDocuments/FormElement.php

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,23 @@ public function getSavedComplianceDocuments()
1515
{
1616
$documents = $this->getData('saved_compliance_documents');
1717
if (empty($documents)) {
18-
return [
19-
['document_type' => '', 'document_attribute' => ''],
20-
];
18+
return $this->getEmptyDocuments();
2119
}
2220

2321
return $documents;
2422
}
2523

24+
public function getEmptyDocuments(): array
25+
{
26+
return [
27+
[
28+
'document_type' => '',
29+
'document_attribute' => '',
30+
'document_languages' => [],
31+
],
32+
];
33+
}
34+
2635
public function renderTypesDropdown(int $index, string $selectedType)
2736
{
2837
$values = [
@@ -103,6 +112,34 @@ public function renderAttributesDropdown(int $index, string $selectedAttribute)
103112
return $select->toHtml();
104113
}
105114

115+
public function renderLanguagesDropdown(int $index, array $selectedLanguages)
116+
{
117+
$languages = \Ess\M2ePro\Model\Ebay\ComplianceDocuments::getDocumentLanguages();
118+
119+
$values = [];
120+
foreach ($languages as $language => $label) {
121+
$values[] = ['label' => $label, 'value' => $language];
122+
}
123+
124+
$select = $this->_factoryElement->create(
125+
\Ess\M2ePro\Block\Adminhtml\Magento\Form\Element\Multiselect::class,
126+
[
127+
'data' => [
128+
'name' => "description[compliance_documents][$index][document_languages]",
129+
'values' => $values,
130+
'value' => $selectedLanguages,
131+
'size' => 3,
132+
'class' => 'M2ePro-compliance-document-language-validator'
133+
],
134+
]
135+
);
136+
137+
$select->setId('document-languages-' . $index);
138+
$select->setForm($this->getForm());
139+
140+
return $select->toHtml();
141+
}
142+
106143
public function renderRemoveRowButton(int $index): string
107144
{
108145
$style = '';
@@ -127,17 +164,15 @@ public function renderAddRowButton(): string
127164
);
128165
}
129166

130-
public function getTooltipHtml()
167+
public function getTooltipHtml(string $text): string
131168
{
132-
//$directionToRightClass = $directionToRight ? 'm2epro-field-tooltip-right' : '';
133-
134169
$content = __('Choose an Attribute containing a valid URL for the selected Document Type');
135170

136171
return <<<HTML
137172
<div class="m2epro-field-tooltip admin__field-tooltip">
138173
<a class="admin__field-tooltip-action" href="javascript://"></a>
139174
<div class="admin__field-tooltip-content">
140-
{$content}
175+
{$text}
141176
</div>
142177
</div>
143178
HTML;

Block/Adminhtml/Listing/Switcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(
2828

2929
public function getLabel(): string
3030
{
31-
return (string)__('View Listing:');
31+
return (string)__('Switch Listing');
3232
}
3333

3434
public function hasDefaultOption(): bool
@@ -55,7 +55,7 @@ protected function loadItems(): void
5555
foreach ($listings as $listing) {
5656
$listingTitle = $this->filterManager->truncate(
5757
$listing->getTitle(),
58-
['length' => 70]
58+
['length' => 50]
5959
);
6060

6161
$items[] = [
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Ess\M2ePro\Block\Adminhtml\Magento\Form\Element;
6+
7+
class Multiselect extends \Magento\Framework\Data\Form\Element\Multiselect
8+
{
9+
public function __construct(
10+
\Magento\Framework\Data\Form\Element\Factory $factoryElement,
11+
\Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection,
12+
\Magento\Framework\Escaper $escaper,
13+
$data = [],
14+
?\Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer = null,
15+
?\Magento\Framework\Math\Random $random = null
16+
) {
17+
parent::__construct(
18+
$factoryElement,
19+
$factoryCollection,
20+
$escaper,
21+
$data,
22+
$secureRenderer,
23+
$random
24+
);
25+
26+
$this->setSize($data['size'] ?? 10);
27+
}
28+
}

Block/Adminhtml/Walmart/Settings/Tabs.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
class Tabs extends \Ess\M2ePro\Block\Adminhtml\Settings\Tabs
66
{
77
public const TAB_ID_GENERAL = 'general';
8+
public const TAB_ID_ATTRIBUTE_MAPPING = 'mapping';
89

910
//########################################
1011

@@ -38,6 +39,19 @@ protected function _prepareLayout()
3839

3940
// ---------------------------------------
4041

42+
$attributeMappingTabContent = $this
43+
->getLayout()
44+
->createBlock(\Ess\M2ePro\Block\Adminhtml\Walmart\Settings\Tabs\AttributeMapping::class)
45+
->toHtml();
46+
47+
$this->addTab(self::TAB_ID_ATTRIBUTE_MAPPING, [
48+
'label' => __('Attribute Mapping'),
49+
'title' => __('Attribute Mapping'),
50+
'content' => $attributeMappingTabContent,
51+
]);
52+
53+
// ----------------------------------------
54+
4155
return parent::_prepareLayout();
4256
}
4357

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
namespace Ess\M2ePro\Block\Adminhtml\Walmart\Settings\Tabs;
4+
5+
class AttributeMapping extends \Ess\M2ePro\Block\Adminhtml\Magento\Form\AbstractForm
6+
{
7+
private \Ess\M2ePro\Block\Adminhtml\Walmart\Settings\Tabs\AttributeMapping\VariationAttributesFieldsetFill $variationAttributesFieldsetFill;
8+
9+
public function __construct(
10+
\Ess\M2ePro\Block\Adminhtml\Walmart\Settings\Tabs\AttributeMapping\VariationAttributesFieldsetFill $variationAttributesFieldsetFill,
11+
\Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context,
12+
\Magento\Framework\Registry $registry,
13+
\Magento\Framework\Data\FormFactory $formFactory,
14+
array $data = []
15+
) {
16+
parent::__construct($context, $registry, $formFactory, $data);
17+
$this->variationAttributesFieldsetFill = $variationAttributesFieldsetFill;
18+
}
19+
20+
protected function _prepareForm()
21+
{
22+
$form = $this->_formFactory->create([
23+
'data' => [
24+
'method' => 'post',
25+
'action' => $this->getUrl('*/*/save'),
26+
],
27+
]);
28+
29+
// ----------------------------------------
30+
31+
$this->addVariationAttributesFieldset($form);
32+
33+
// ----------------------------------------
34+
35+
$form->setUseContainer(true);
36+
$this->setForm($form);
37+
38+
return parent::_prepareForm();
39+
}
40+
41+
protected function _beforeToHtml()
42+
{
43+
$this->jsUrl->add(
44+
$this->getUrl('*/walmart_settings_attributeMapping/save'),
45+
\Ess\M2ePro\Block\Adminhtml\Walmart\Settings\Tabs::TAB_ID_ATTRIBUTE_MAPPING
46+
);
47+
48+
return parent::_beforeToHtml();
49+
}
50+
51+
private function addVariationAttributesFieldset(\Magento\Framework\Data\Form $form): void
52+
{
53+
$tooltipMessage = __(
54+
'In the Variation Attributes section of the Attribute Mapping settings, ' .
55+
'you can set default mappings between your Magento variation attribute options and the valid ' .
56+
'variation options on Walmart. For example, if your product has a variation attribute like "Color," ' .
57+
'you can ensure that the specific variation options (e.g., "black," "white," "yellow," "blue") ' .
58+
'in Magento are accurately matched to the corresponding options on Walmart. This helps to ' .
59+
'streamline the listing and management of product variations across both platforms.'
60+
);
61+
62+
$fieldset = $form->addFieldset('variation_attributes', [
63+
'legend' => __('Variation Attributes'),
64+
'tooltip' => $tooltipMessage,
65+
'collapsable' => true,
66+
]);
67+
68+
$this->variationAttributesFieldsetFill->fill($fieldset);
69+
}
70+
}

0 commit comments

Comments
 (0)