6 declare(strict_types=1);
38 parent::__construct($context);
50 $categoryId = $this->resolveCategoryId();
52 $category = $this->_objectManager->create(\
Magento\Catalog\Model\Category::class);
58 $rootId = $this->_objectManager->get(
62 )->getRootCategoryId();
63 if (!in_array($rootId,
$category->getPathIds())) {
65 if ($getRootInstead) {
74 $this->_objectManager->get(\
Magento\Framework\Registry::class)->register(
'category',
$category);
75 $this->_objectManager->get(\
Magento\Framework\Registry::class)->register(
'current_category',
$category);
76 $this->_objectManager->get(\
Magento\Cms\Model\Wysiwyg\Config::class)
86 private function resolveCategoryId() : int
88 $categoryId = (int)$this->
getRequest()->getParam(
'id',
false);
90 return $categoryId ?: (int)$this->
getRequest()->getParam(
'entity_id',
false);
101 private function resolveStoreId() : int
118 protected function ajaxRequestResponse(
$category, $resultPage)
122 if (empty($breadcrumbsPath)) {
124 $breadcrumbsPath = $this->_objectManager->get(
125 \
Magento\Backend\Model\Auth\Session::class
129 if (!empty($breadcrumbsPath)) {
130 $breadcrumbsPath = explode(
'/', $breadcrumbsPath);
132 if (count($breadcrumbsPath) <= 1) {
133 $breadcrumbsPath =
'';
135 array_pop($breadcrumbsPath);
136 $breadcrumbsPath = implode(
'/', $breadcrumbsPath);
141 $eventResponse = new \Magento\Framework\DataObject([
142 'content' => $resultPage->getLayout()->getUiComponent(
'category_form')->getFormHtml()
143 . $resultPage->getLayout()->getBlock(
'category.tree')
144 ->getBreadcrumbsJavascript($breadcrumbsPath,
'editingCategoryBreadcrumbs'),
145 'messages' => $resultPage->getLayout()->getMessagesBlock()->getGroupedHtml(),
146 'toolbar' => $resultPage->getLayout()->getBlock(
'page.actions.toolbar')->toHtml()
148 $this->_eventManager->dispatch(
149 'category_prepare_ajax_response',
150 [
'response' => $eventResponse,
'controller' => $this]
153 $resultJson = $this->_objectManager->get(\
Magento\Framework\Controller\Result\Json::class);
154 $resultJson->setHeader(
'Content-type',
'application/json',
true);
155 $resultJson->setData($eventResponse->getData());
169 $dateFieldFilters = [];
172 if (
$attribute->getBackend()->getType() ==
'datetime') {
178 $inputFilter = new \Zend_Filter_Input($dateFieldFilters, [],
$postData);
179 return $inputFilter->getUnescaped();
dateTimePreprocessing($category, $postData)
__construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter=null)
_initCategory($getRootInstead=false)