Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: error in admin edit cart rule #4493

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions app/code/core/Mage/Rule/Model/Action/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,52 +254,58 @@ public function getTypeElement()
*/
public function getAttributeElement()
{
$renderer = Mage::getBlockSingleton('rule/editable');
if ($renderer instanceof Varien_Data_Form_Element_Renderer_Interface) {
$this->getForm()::setFieldsetRenderer($renderer);
}

return $this->getForm()->addField('action:' . $this->getId() . ':attribute', 'select', [
$element = $this->getForm()->addField('action:' . $this->getId() . ':attribute', 'select', [
'name' => 'rule[actions][' . $this->getId() . '][attribute]',
'values' => $this->getAttributeSelectOptions(),
'value' => $this->getAttribute(),
'value_name' => $this->getAttributeName(),
]);

$renderer = Mage::getBlockSingleton('rule/editable');
if ($renderer instanceof Varien_Data_Form_Element_Renderer_Interface) {
$element->setRenderer($renderer);
}

return $element;
}

/**
* @return Varien_Data_Form_Element_Abstract
*/
public function getOperatorElement()
{
$renderer = Mage::getBlockSingleton('rule/editable');
if ($renderer instanceof Varien_Data_Form_Element_Renderer_Interface) {
$this->getForm()::setFieldsetRenderer($renderer);
}

return $this->getForm()->addField('action:' . $this->getId() . ':operator', 'select', [
$element = $this->getForm()->addField('action:' . $this->getId() . ':operator', 'select', [
'name' => 'rule[actions][' . $this->getId() . '][operator]',
'values' => $this->getOperatorSelectOptions(),
'value' => $this->getOperator(),
'value_name' => $this->getOperatorName(),
]);

$renderer = Mage::getBlockSingleton('rule/editable');
if ($renderer instanceof Varien_Data_Form_Element_Renderer_Interface) {
$element->setRenderer($renderer);
}

return $element;
}

/**
* @return Varien_Data_Form_Element_Abstract
*/
public function getValueElement()
{
$renderer = Mage::getBlockSingleton('rule/editable');
if ($renderer instanceof Varien_Data_Form_Element_Renderer_Interface) {
$this->getForm()::setFieldsetRenderer($renderer);
}

return $this->getForm()->addField('action:' . $this->getId() . ':value', 'text', [
$element = $this->getForm()->addField('action:' . $this->getId() . ':value', 'text', [
'name' => 'rule[actions][' . $this->getId() . '][value]',
'value' => $this->getValue(),
'value_name' => $this->getValueName(),
]);

$renderer = Mage::getBlockSingleton('rule/editable');
if ($renderer instanceof Varien_Data_Form_Element_Renderer_Interface) {
$element->setRenderer($renderer);
}

return $element;
}

/**
Expand Down
14 changes: 8 additions & 6 deletions app/code/core/Mage/Rule/Model/Action/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,18 @@ public function asHtml()
*/
public function getNewChildElement()
{
$renderer = Mage::getBlockSingleton('rule/newchild');
if ($renderer instanceof Varien_Data_Form_Element_Renderer_Interface) {
$this->getForm()::setFieldsetRenderer($renderer);
}

return $this->getForm()->addField('action:' . $this->getId() . ':new_child', 'select', [
$element = $this->getForm()->addField('action:' . $this->getId() . ':new_child', 'select', [
'name' => 'rule[actions][' . $this->getId() . '][new_child]',
'values' => $this->getNewChildSelectOptions(),
'value_name' => $this->getNewChildName(),
]);

$renderer = Mage::getBlockSingleton('rule/newchild');
if ($renderer instanceof Varien_Data_Form_Element_Renderer_Interface) {
$element->setRenderer($renderer);
}

return $element;
}

/**
Expand Down
14 changes: 8 additions & 6 deletions app/code/core/Mage/Rule/Model/Condition/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,17 +509,19 @@ public function getAttributeElement()
}
}

$renderer = Mage::getBlockSingleton('rule/editable');
if ($renderer instanceof Varien_Data_Form_Element_Renderer_Interface) {
$this->getForm()::setFieldsetRenderer($renderer);
}

return $this->getForm()->addField($this->getPrefix() . '__' . $this->getId() . '__attribute', 'select', [
$element = $this->getForm()->addField($this->getPrefix() . '__' . $this->getId() . '__attribute', 'select', [
'name' => 'rule[' . $this->getPrefix() . '][' . $this->getId() . '][attribute]',
'values' => $this->getAttributeSelectOptions(),
'value' => $this->getAttribute(),
'value_name' => $this->getAttributeName(),
]);

$renderer = Mage::getBlockSingleton('rule/editable');
if ($renderer instanceof Varien_Data_Form_Element_Renderer_Interface) {
$element->setRenderer($renderer);
}

return $element;
}

/**
Expand Down
28 changes: 16 additions & 12 deletions app/code/core/Mage/Rule/Model/Condition/Combine.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,19 @@ public function getAggregatorElement()
}
}

$renderer = Mage::getBlockSingleton('rule/editable');
if ($renderer instanceof Varien_Data_Form_Element_Renderer_Interface) {
$this->getForm()::setFieldsetRenderer($renderer);
}

return $this->getForm()->addField($this->getPrefix() . '__' . $this->getId() . '__aggregator', 'select', [
$element = $this->getForm()->addField($this->getPrefix() . '__' . $this->getId() . '__aggregator', 'select', [
'name' => 'rule[' . $this->getPrefix() . '][' . $this->getId() . '][aggregator]',
'values' => $this->getAggregatorSelectOptions(),
'value' => $this->getAggregator(),
'value_name' => $this->getAggregatorName(),
]);

$renderer = Mage::getBlockSingleton('rule/editable');
if ($renderer instanceof Varien_Data_Form_Element_Renderer_Interface) {
$element->setRenderer($renderer);
}

return $element;
}
/* end aggregator methods */

Expand Down Expand Up @@ -308,16 +310,18 @@ public function asHtml()
*/
public function getNewChildElement()
{
$renderer = Mage::getBlockSingleton('rule/newchild');
if ($renderer instanceof Varien_Data_Form_Element_Renderer_Interface) {
$this->getForm()::setFieldsetRenderer($renderer);
}

return $this->getForm()->addField($this->getPrefix() . '__' . $this->getId() . '__new_child', 'select', [
$element = $this->getForm()->addField($this->getPrefix() . '__' . $this->getId() . '__new_child', 'select', [
'name' => 'rule[' . $this->getPrefix() . '][' . $this->getId() . '][new_child]',
'values' => $this->getNewChildSelectOptions(),
'value_name' => $this->getNewChildName(),
]);

$renderer = Mage::getBlockSingleton('rule/newchild');
if ($renderer instanceof Varien_Data_Form_Element_Renderer_Interface) {
$element->setRenderer($renderer);
}

return $element;
}

/**
Expand Down
Loading