41 \
Magento\Framework\View\Asset\Repository $assetRepo,
42 \
Magento\Framework\View\LayoutInterface $layout,
45 $this->_assetRepo = $assetRepo;
46 $this->_layout = $layout;
48 parent::__construct(
$data);
58 $operators = $this->getOperatorOption();
61 $this->setOperator(key($operators));
70 return $this->getRule()->getForm();
78 public function asArray(array $arrAttributes = [])
81 'type' => $this->getType(),
82 'attribute' => $this->getAttribute(),
83 'operator' => $this->getOperator(),
84 'value' => $this->getValue(),
98 $this->getAttribute() .
101 $this->getOperator() .
117 'type' => $arr[
'type'],
118 'attribute' => $arr[
'attribute'],
119 'operator' => $arr[
'operator'],
120 'value' => $arr[
'value'],
134 $this->setAttributeOption([]);
144 foreach ($this->getAttributeOption() as $key =>
$value) {
145 $opt[] = [
'value' => $key,
'label' =>
$value];
155 return $this->getAttributeOption($this->getAttribute());
163 $this->setOperatorOption([
'=' =>
__(
'to'),
'+=' =>
__(
'by')]);
173 foreach ($this->getOperatorOption() as $k => $v) {
174 $opt[] = [
'value' => $k,
'label' => $v];
184 return $this->getOperatorOption($this->getOperator());
192 $this->setValueOption([]);
202 foreach ($this->getValueOption() as $key =>
$value) {
203 $opt[] = [
'value' => $key,
'label' =>
$value];
213 $value = $this->getValue();
222 return [[
'value' =>
'',
'label' =>
__(
'Please choose an action to add.')]];
255 return $this->
getForm()->addField(
256 'action:' . $this->getId() .
':type',
259 'name' => $this->elementName .
'[actions][' . $this->getId() .
'][type]',
260 'value' => $this->getType(),
271 return $this->
getForm()->addField(
272 'action:' . $this->getId() .
':attribute',
275 'name' => $this->elementName .
'[actions][' . $this->getId() .
'][attribute]',
277 'value' => $this->getAttribute(),
281 $this->_layout->getBlockSingleton(\
Magento\Rule\Block\Editable::class)
290 return $this->
getForm()->addField(
291 'action:' . $this->getId() .
':operator',
294 'name' => $this->elementName .
'[actions][' . $this->getId() .
'][operator]',
296 'value' => $this->getOperator(),
300 $this->_layout->getBlockSingleton(\
Magento\Rule\Block\Editable::class)
309 return $this->
getForm()->addField(
310 'action:' . $this->getId() .
':value',
313 'name' => $this->elementName .
'[actions][' . $this->getId() .
'][value]',
314 'value' => $this->getValue(),
318 $this->_layout->getBlockSingleton(\
Magento\Rule\Block\Editable::class)
327 $src = $this->_assetRepo->getUrl(
'images/rule_component_add.gif');
328 $html =
'<img src="' . $src .
'" alt="" class="rule-param-add v-middle" />';
337 $src = $this->_assetRepo->getUrl(
'images/rule_component_remove.gif');
338 $html =
'<span class="rule-param"><a href="javascript:void(0)" class="rule-param-remove"><img src="' .
340 '" alt="" class="v-middle" /></a></span>';
360 $str = str_pad(
'', $level * 3,
' ', STR_PAD_LEFT) . $this->
asString();
getOperatorSelectOptions()
asStringRecursive($level=0)
getAttributeSelectOptions()
getNewChildSelectOptions()
asArray(array $arrAttributes=[])
__construct(\Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\View\LayoutInterface $layout, array $data=[])