Skip to content

Commit

Permalink
Fix conflict entity_id with special product condition
Browse files Browse the repository at this point in the history
  • Loading branch information
magiccart committed May 26, 2021
1 parent 17cf256 commit 04dcc0a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Block/Adminhtml/Sizechart/Edit/Tab/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ protected function _prepareForm()
'base_fieldset',
['legend' => __('Edit Size Chart Rule'), 'class' => 'fieldset-wide']
);
$fieldset->addField('entity_id', 'hidden', ['name' => 'entity_id']);
// $fieldset->addField('entity_id', 'hidden', ['name' => 'entity_id']); // not use will conflict entity_id ofcondition product
$fieldset->addField('sizechart_id', 'hidden', ['name' => 'sizechart_id']);
} else {
$fieldset = $form->addFieldset(
'base_fieldset',
Expand Down
3 changes: 2 additions & 1 deletion Controller/Adminhtml/Sizechart/AddRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function execute()
$rowId = (int) $this->getRequest()->getParam('id');
$storeViewId = $this->getRequest()->getParam('stores');
$rowData = $this->sizechartFactory->create();

if ($rowId) {
// $rowData->setStoreViewId($storeViewId)->load($rowId);
$rowData = $rowData->setStoreViewId($storeViewId)->load($rowId);
Expand All @@ -45,13 +44,15 @@ public function execute()
unset($tmp['entity_id']);
$rowData->addData($tmp);
}
$rowData->setData('sizechart_id', $rowData->getEntityId()); // fix conflict entity_id in product condition
}
}

$this->coreRegistry->register('row_data', $rowData);
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$title = $rowId ? __('Edit Size chart') . $rowTitle : __('Add Size chart');
$resultPage->getConfig()->getTitle()->prepend($title);

return $resultPage;
}
}
3 changes: 2 additions & 1 deletion Controller/Adminhtml/Sizechart/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public function execute()
$data = $this->getRequest()->getPostValue();

if ($data) {
$id = $this->getRequest()->getParam('entity_id');
$id = $this->getRequest()->getParam('sizechart_id');
if($id) $data['entity_id'] = $id; // fix conflict entity_id in product condition
$model = $this->_sizechartFactory->create();
$storeViewId = $this->getRequest()->getParam('stores');
$model->load($id);
Expand Down

0 comments on commit 04dcc0a

Please sign in to comment.