Skip to content

Commit e7d5bcf

Browse files
Merge pull request #31 from magmodules/release/1.11.0
Release/1.11.0
2 parents f506905 + 7083be3 commit e7d5bcf

File tree

15 files changed

+524
-54
lines changed

15 files changed

+524
-54
lines changed

.github/workflows/linting.yml

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,22 @@ name: Lint PHP files
22
on: [push, pull_request]
33

44
jobs:
5-
php-71:
6-
runs-on: ubuntu-latest
7-
steps:
8-
- uses: StephaneBour/[email protected]
9-
with:
10-
dir: './'
11-
12-
php-72:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- uses: StephaneBour/[email protected]
16-
with:
17-
dir: './'
18-
19-
php-73:
5+
php-74:
206
runs-on: ubuntu-latest
217
steps:
22-
- uses: StephaneBour/[email protected]
23-
with:
24-
dir: './'
8+
- uses: prestashop/github-action-php-lint/[email protected]
259

26-
php-74:
10+
php-81:
2711
runs-on: ubuntu-latest
2812
steps:
29-
- uses: StephaneBour/[email protected]
30-
with:
31-
dir: './'
13+
- uses: prestashop/github-action-php-lint/[email protected]
3214

33-
php-80:
15+
php-82:
3416
runs-on: ubuntu-latest
3517
steps:
36-
- uses: StephaneBour/[email protected]
37-
with:
38-
dir: './'
18+
- uses: prestashop/github-action-php-lint/[email protected]
3919

40-
php-81:
20+
php-83:
4121
runs-on: ubuntu-latest
4222
steps:
43-
- uses: StephaneBour/[email protected]
44-
with:
45-
dir: './'
23+
- uses: prestashop/github-action-php-lint/[email protected]

.github/workflows/setup-di-compile.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ jobs:
66
strategy:
77
matrix:
88
include:
9-
- PHP_VERSION: php73-fpm
10-
MAGENTO_VERSION: 2.3.7
119
- PHP_VERSION: php74-fpm
12-
MAGENTO_VERSION: 2.4.0
13-
- PHP_VERSION: php81-fpm
1410
MAGENTO_VERSION: 2.4.4
1511
- PHP_VERSION: php82-fpm
1612
MAGENTO_VERSION: 2.4.6
13+
- PHP_VERSION: php83-fpm
14+
MAGENTO_VERSION: 2.4.7
1715
runs-on: ubuntu-latest
1816
steps:
1917
- uses: actions/checkout@v1

Api/Config/RepositoryInterface.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ interface RepositoryInterface
2828
public const XML_PATH_SKU = '%s/attributes/sku';
2929
public const XML_PATH_BRAND = '%s/attributes/brand';
3030
public const XML_PATH_DESCRIPTION = '%s/attributes/description';
31+
public const XPATH_EXTRA_FIELDS = '%s/attributes/extra_fields';
3132

3233
/**
3334
* Get extension version
@@ -113,6 +114,13 @@ public function getBrand(int $storeId = null): string;
113114
*/
114115
public function getDescription(int $storeId = null): string;
115116

117+
/**
118+
* Get extra fields
119+
*
120+
* @return array
121+
*/
122+
public function getExtraFields(): array;
123+
116124
/**
117125
* Get current store
118126
*
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
/**
3+
* Copyright © Magmodules.eu. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magmodules\Reloadify\Block\Adminhtml\System\Config\Form\Field;
9+
10+
use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray;
11+
use Magento\Framework\DataObject;
12+
use Magento\Framework\Exception\LocalizedException;
13+
14+
/**
15+
* Class ExtraFields
16+
* System config field renderer for Extra Fields (feed)
17+
*/
18+
class ExtraFields extends AbstractFieldArray
19+
{
20+
21+
/**
22+
* @var Renderer\Attributes
23+
*/
24+
private $attributeRenderer;
25+
26+
/**
27+
* Prepare to render method
28+
*
29+
* @throws LocalizedException
30+
*/
31+
public function _prepareToRender()
32+
{
33+
$this->addColumn(
34+
'name',
35+
[
36+
'label' => __('Field name'),
37+
]
38+
);
39+
$this->addColumn(
40+
'attribute',
41+
[
42+
'label' => __('Attribute'),
43+
'renderer' => $this->getAttributeRenderer()
44+
]
45+
);
46+
$this->_addAfter = false;
47+
$this->_addButtonLabel = __('Add');
48+
}
49+
50+
/**
51+
* Retrieve attribute column renderer
52+
*
53+
* @return Renderer\Attributes
54+
* @throws LocalizedException
55+
*/
56+
public function getAttributeRenderer(): Renderer\Attributes
57+
{
58+
if (!$this->attributeRenderer) {
59+
$this->attributeRenderer = $this->getLayout()->createBlock(
60+
Renderer\Attributes::class,
61+
'',
62+
['data' => ['is_render_to_js_template' => true]]
63+
);
64+
}
65+
66+
return $this->attributeRenderer;
67+
}
68+
69+
/**
70+
* Prepare existing row data object
71+
*
72+
* @param DataObject $row
73+
* @throws LocalizedException
74+
*/
75+
public function _prepareArrayRow(DataObject $row)
76+
{
77+
$options = [];
78+
if ($attribute = $row->getData('attribute')) {
79+
$options['option_' . $this->getAttributeRenderer()->calcOptionHash($attribute)] = 'selected="selected"';
80+
}
81+
82+
$row->setData(
83+
'option_extra_attrs',
84+
$options
85+
);
86+
}
87+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
/**
3+
* Copyright © Magmodules.eu. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magmodules\Reloadify\Block\Adminhtml\System\Config\Form\Field\Renderer;
9+
10+
use Magento\Framework\View\Element\Context;
11+
use Magento\Framework\View\Element\Html\Select;
12+
use Magmodules\Reloadify\Model\System\Config\Source\Attributes as AttributesSource;
13+
14+
class Attributes extends Select
15+
{
16+
17+
/**
18+
* @var array
19+
*/
20+
private $attribute = [];
21+
/**
22+
* @var AttributesSource
23+
*/
24+
private $attributes;
25+
26+
/**
27+
* Attributes constructor.
28+
*
29+
* @param Context $context
30+
* @param AttributesSource $attributes
31+
* @param array $data
32+
*/
33+
public function __construct(
34+
Context $context,
35+
AttributesSource $attributes,
36+
array $data = []
37+
) {
38+
parent::__construct($context, $data);
39+
$this->attributes = $attributes;
40+
}
41+
42+
/**
43+
* Render block HTML
44+
*
45+
* @return string
46+
*/
47+
public function _toHtml()
48+
{
49+
if (!$this->getOptions()) {
50+
foreach ($this->getAttributeSource() as $attribute) {
51+
$this->addOption($attribute['value'], $attribute['label']);
52+
}
53+
}
54+
55+
return parent::_toHtml();
56+
}
57+
58+
/**
59+
* Get all attributes
60+
*
61+
* @return array
62+
*/
63+
public function getAttributeSource(): array
64+
{
65+
if (!$this->attribute) {
66+
$this->attribute = $this->attributes->toOptionArray();
67+
$this->attribute[] = $this->getPriceAttributeSource();
68+
}
69+
70+
return $this->attribute;
71+
}
72+
73+
/**
74+
* @return array
75+
*/
76+
private function getPriceAttributeSource(): array
77+
{
78+
$optionArray = [];
79+
$optionArray[] = [
80+
'label' => __('Price with base currency'),
81+
'value' => 'rendered_price__price'
82+
];
83+
$optionArray[] = [
84+
'label' => __('Min. price with base currency'),
85+
'value' => 'rendered_price__min_price'
86+
];
87+
$optionArray[] = [
88+
'label' => __('Max. price with base currency'),
89+
'value' => 'rendered_price__max_price'
90+
];
91+
92+
return [
93+
'label' => __('Price Attributes'),
94+
'value' => $optionArray,
95+
'optgroup-name' => __('Price Attributes')
96+
];
97+
}
98+
99+
/**
100+
* Sets name for input element
101+
*
102+
* @param $value
103+
*
104+
* @return Attributes
105+
*/
106+
public function setInputName($value)
107+
{
108+
return $this->setData('name', $value);
109+
}
110+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* Copyright © Magmodules.eu. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magmodules\Reloadify\Model\Config\Backend\Serialized;
9+
10+
use Magento\Config\Model\Config\Backend\Serialized\ArraySerialized;
11+
12+
/**
13+
* Class ExtraFields
14+
*/
15+
class ExtraFields extends ArraySerialized
16+
{
17+
18+
/**
19+
* @return \Magento\Config\Model\Config\Backend\Serialized\ArraySerialized
20+
*/
21+
public function beforeSave()
22+
{
23+
$data = $this->getValue();
24+
if (is_array($data)) {
25+
foreach ($data as $key => $row) {
26+
if (empty($row['name']) || empty($row['attribute'])) {
27+
unset($data[$key]);
28+
continue;
29+
}
30+
}
31+
}
32+
$this->setValue($data);
33+
return parent::beforeSave();
34+
}
35+
}

0 commit comments

Comments
 (0)