Magento2 Magento 2.1 Can';不要像2.0.x那样创建观察者
Magento2 Magento 2.1 Can';不要像2.0.x那样创建观察者,magento2,magento-2.0,Magento2,Magento 2.0,$actionsSelect=$observer->getForm()->getElement('simple_action') Magento 2.0.x变量$actionsSelect正在工作 在新版本magento 2.1上: 变量$actionselectusevar\u dump()返回空值 public function execute(\Magento\Framework\Event\Observer $observer) { $actionsSelect = $obser
$actionsSelect=$observer->getForm()->getElement('simple_action')代码>
Magento 2.0.x变量$actionsSelect
正在工作
在新版本magento 2.1上:
变量$actionselect
usevar\u dump()
返回空值
public function execute(\Magento\Framework\Event\Observer $observer)
{
$actionsSelect = $observer->getForm()->getElement('simple_action');
if ($actionsSelect){
$vals = $actionsSelect->getValues();
$vals[] = [
'value' => 'freegift_items',
'label' => __('Free gifts with products'),
];
$vals[] = [
'value' => 'freegift_cart',
'label' => __('Free gifts for the whole cart'),
];
$vals[] = [
'value' => 'freegift_product',
'label' => __('Free gift with same product'),
];
$vals[] = [
'value' => 'freegift_spent',
'label' => __('Free gifts with amount $X spent'),
];
$actionsSelect->setValues($vals);
$fldSet = $observer->getForm()->getElement('action_fieldset');
$fldSet->addField('freegift_type', 'select', [
'name' => 'freegiftrule[type]',
'label' => __('Type'),
'values' => [
0 => __('All SKUs Below'),
1 => __('One of the SKUs Below')
],
],
'discount_amount'
);
$fldSet->addField('freegift_sku', 'text', [
'name' => 'freegiftrule[sku]',
'label' => __('SKUs as Free gift'),
'note' => __('Comma separated list of the SKUs'),
],
'freegift_type'
);
}
}
嗨,你能提供活动代码吗?