From cbe1e1e6c43c44faf387175d507e8eabe4a1e576 Mon Sep 17 00:00:00 2001 From: ernestsverins Date: Thu, 21 Nov 2019 14:26:04 +0200 Subject: [PATCH] Update cms page identifier --- src/Block/Adminhtml/Item/Edit/Form.php | 12 ------ src/Observer/UpdatePageIdentifier.php | 55 ++++++++++++++++++++++++++ src/etc/adminhtml/events.xml | 16 ++++++++ 3 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 src/Observer/UpdatePageIdentifier.php create mode 100644 src/etc/adminhtml/events.xml diff --git a/src/Block/Adminhtml/Item/Edit/Form.php b/src/Block/Adminhtml/Item/Edit/Form.php index 990143b..095ce40 100644 --- a/src/Block/Adminhtml/Item/Edit/Form.php +++ b/src/Block/Adminhtml/Item/Edit/Form.php @@ -195,18 +195,6 @@ protected function _prepareForm() ] ); - $fieldset->addField( - 'open_type', - 'select', - [ - 'label' => __('Open Type'), - 'title' => __('Open Type'), - 'name' => 'open_type', - 'required' => true, - 'options' => $this->_menumanagerHelper->getOpenTypes(), - ] - ); - $fieldset->addField( 'is_active', 'select', diff --git a/src/Observer/UpdatePageIdentifier.php b/src/Observer/UpdatePageIdentifier.php new file mode 100644 index 0000000..ddaa9cd --- /dev/null +++ b/src/Observer/UpdatePageIdentifier.php @@ -0,0 +1,55 @@ +collection = $collection; + $this->data = $data; + } + + /** + * @param \Magento\Framework\Event\Observer $observer + * @throws \Magento\Framework\Exception\AlreadyExistsException + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + $identifier = $observer->getData('object')->getData('identifier'); + $originData = $observer->getData('object')->getOrigData('identifier'); + $items = $this->collection->create() + ->addFieldToFilter('cms_page_identifier', ['eq' => $originData])->getItems(); + + foreach ($items as $item) { + $item->setData('cms_page_identifier', $identifier); + $this->data->save($item); + } + } +} diff --git a/src/etc/adminhtml/events.xml b/src/etc/adminhtml/events.xml new file mode 100644 index 0000000..5857dbf --- /dev/null +++ b/src/etc/adminhtml/events.xml @@ -0,0 +1,16 @@ + + + + + + + +