|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright © Getnet. All rights reserved. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Bruno Elisei <[email protected]> |
|
6
|
|
|
* See LICENSE for license details. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
declare(strict_types=1); |
|
10
|
|
|
|
|
11
|
|
|
namespace Getnet\SplitExampleMagento\Block\Adminhtml\System\Form\Field\Column; |
|
12
|
|
|
|
|
13
|
|
|
use Getnet\SubSellerMagento\Api\SubSellerRepositoryInterface; |
|
|
|
|
|
|
14
|
|
|
use Magento\Framework\Api\FilterBuilder; |
|
15
|
|
|
use Magento\Framework\Api\SearchCriteriaBuilder; |
|
16
|
|
|
use Magento\Framework\View\Element\Context; |
|
17
|
|
|
use Magento\Framework\View\Element\Html\Select; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Class SubSellerIdColumn - Create Field to Sub Seller Id Column. |
|
21
|
|
|
*/ |
|
22
|
|
|
class SubSellerIdColumn extends Select |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @var SubSellerRepositoryInterface |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $subSellerRepository; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var SearchCriteriaBuilder |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $searchCriteria; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var FilterBuilder |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $filterBuilder; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Constructor. |
|
41
|
|
|
* |
|
42
|
|
|
* @param Context $context |
|
43
|
|
|
* @param SubSellerRepositoryInterface $subSellerRepository |
|
44
|
|
|
* @param SearchCriteriaBuilder $searchCriteria |
|
45
|
|
|
* @param FilterBuilder $filterBuilder |
|
46
|
|
|
* @param array $data |
|
47
|
|
|
*/ |
|
48
|
|
|
public function __construct( |
|
49
|
|
|
Context $context, |
|
50
|
|
|
SubSellerRepositoryInterface $subSellerRepository, |
|
51
|
|
|
SearchCriteriaBuilder $searchCriteria, |
|
52
|
|
|
FilterBuilder $filterBuilder, |
|
53
|
|
|
array $data = [] |
|
54
|
|
|
) { |
|
55
|
|
|
parent::__construct($context, $data); |
|
56
|
|
|
$this->subSellerRepository = $subSellerRepository; |
|
57
|
|
|
$this->searchCriteria = $searchCriteria; |
|
58
|
|
|
$this->filterBuilder = $filterBuilder; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Set "name" for <select> element. |
|
63
|
|
|
* |
|
64
|
|
|
* @param string $value |
|
65
|
|
|
* |
|
66
|
|
|
* @return void |
|
67
|
|
|
*/ |
|
68
|
|
|
public function setInputName($value) |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->setName($value); |
|
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Set "id" for <select> element. |
|
75
|
|
|
* |
|
76
|
|
|
* @param string $value |
|
77
|
|
|
* |
|
78
|
|
|
* @return void |
|
79
|
|
|
*/ |
|
80
|
|
|
public function setInputId($value) |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->setId($value); |
|
|
|
|
|
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Render block HTML. |
|
87
|
|
|
* |
|
88
|
|
|
* @return string |
|
89
|
|
|
*/ |
|
90
|
|
|
public function _toHtml(): string |
|
91
|
|
|
{ |
|
92
|
|
|
if (!$this->getOptions()) { |
|
93
|
|
|
$this->setOptions($this->getSourceOptions()); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
return parent::_toHtml(); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Get Options. |
|
101
|
|
|
* |
|
102
|
|
|
* @return array |
|
103
|
|
|
*/ |
|
104
|
|
|
public function getSourceOptions(): array |
|
105
|
|
|
{ |
|
106
|
|
|
$sellers = []; |
|
107
|
|
|
$sellers[] = [ |
|
108
|
|
|
'value' => 'any', |
|
109
|
|
|
'label' => __('Any Sub Seller'), |
|
110
|
|
|
]; |
|
111
|
|
|
$searchCriteria = $this->searchCriteria->addFilters( |
|
112
|
|
|
[ |
|
113
|
|
|
$this->filterBuilder->setField('status')->setValue(4)->setConditionType('neq')->create(), |
|
114
|
|
|
] |
|
115
|
|
|
)->create(); |
|
116
|
|
|
$subSellers = $this->subSellerRepository->getList($searchCriteria); |
|
117
|
|
|
|
|
118
|
|
|
foreach ($subSellers->getItems() as $subSeller) { |
|
119
|
|
|
$sellers[] = [ |
|
120
|
|
|
'value' => $subSeller->getIdExt(), |
|
121
|
|
|
'label' => sprintf( |
|
122
|
|
|
'%s - Code: %s - Email: %s', |
|
123
|
|
|
$subSeller->getLegalName(), |
|
124
|
|
|
$subSeller->getCode(), |
|
125
|
|
|
$subSeller->getEmail() |
|
126
|
|
|
), |
|
127
|
|
|
]; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
return $sellers; |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths