/** * Edit * * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect * @SuppressWarnings(PHPMD.NPathComplexity) */ public function execute() { // \Zend_Debug::dump($this->getRequest()->getFullActionName()); $_modelKey = 'Swissup\\Email\\Model\\Service'; $id = $this->getRequest()->getParam('id'); $model = $this->_objectManager->create($_modelKey); if ($id) { $model->load($id); if (!$model->getId()) { $this->messageManager->addError(__('This item no longer exists.')); /** \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('*/*/'); } } $data = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getFormData(true); if (!empty($data)) { $model->setData($data); } $this->coreRegistry->register('email_service', $model); /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->_initAction(); $resultPage->addBreadcrumb($id ? __('Edit') : __('New'), $id ? __('Edit') : __('New')); $resultPage->getConfig()->getTitle()->prepend(__('Emails Services')); $resultPage->getConfig()->getTitle()->prepend($model->getId() ? $model->getTitle() : __('New')); return $resultPage; }
/** * Build product based on user request * * @param RequestInterface $request * @return \Magento\Catalog\Model\Product */ public function build(RequestInterface $request) { $productId = (int) $request->getParam('id'); /** @var $product \Magento\Catalog\Model\Product */ $product = $this->productFactory->create(); $product->setStoreId($request->getParam('store', 0)); $typeId = $request->getParam('type'); if (!$productId && $typeId) { $product->setTypeId($typeId); } $product->setData('_edit_mode', true); if ($productId) { try { $product->load($productId); } catch (\Exception $e) { $product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE); $this->logger->critical($e); } } $setId = (int) $request->getParam('set'); if ($setId) { $product->setAttributeSetId($setId); } $this->registry->register('product', $product); $this->registry->register('current_product', $product); $this->wysiwygConfig->setStoreId($request->getParam('store')); return $product; }
/** * Get options. * * @return array */ public function toOptionArray() { $fields = []; $fields[] = ['value' => '0', 'label' => '-- Disabled --']; $websiteName = $this->request->getParam('website', false); $website = $websiteName ? $this->storeManager->getWebsite($websiteName) : 0; if ($this->helper->isEnabled($website)) { $savedPrograms = $this->registry->registry('programs'); //get saved datafileds from registry if (is_array($savedPrograms)) { $programs = $savedPrograms; } else { //grab the datafields request and save to register $client = $this->helper->getWebsiteApiClient($website); $programs = $client->getPrograms(); $this->registry->unregister('programs'); $this->registry->register('programs', $programs); } //set the api error message for the first option if (isset($programs->message)) { //message $fields[] = ['value' => 0, 'label' => $programs->message]; } elseif (!empty($programs)) { //loop for all programs option foreach ($programs as $program) { if (isset($program->id) && $program->status == 'Active') { //@codingStandardsIgnoreStart $fields[] = ['value' => $program->id, 'label' => addslashes($program->name)]; //@codingStandardsIgnoreEnd } } } } return $fields; }
/** * * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect * @SuppressWarnings(PHPMD.NPathComplexity) */ public function execute() { $id = $this->getRequest()->getParam('email_contact_id'); $model = $this->_contactFactory->create(); //check the param contact id if ($id) { //load the and check the contact model $model->load($id); if (!$model->getId()) { $this->messageManager->addError(__('This contact no longer exists.')); /** \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('*/*/'); } } $data = $this->_sessionFactory->create()->getFormData(true); if (!empty($data)) { $model->setData($data); } $this->_coreRegistry->register('email_contact', $model); /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->_initAction(); $resultPage->addBreadcrumb($id ? __('Edit Contact ') : __('New Contact'), $id ? __('Edit Contact ') : __('New Contact')); $resultPage->getConfig()->getTitle()->prepend(__('Contacts')); $resultPage->getConfig()->getTitle()->prepend($model->getId() ? $model->getTitle() : __('New Contacts')); return $resultPage; }
/** * Get associated grouped products grid popup * * @return void */ public function execute() { $productId = (int) $this->getRequest()->getParam('id'); /** @var $product \Magento\Catalog\Model\Product */ $product = $this->factory->create(); $product->setStoreId($this->getRequest()->getParam('store', 0)); $typeId = $this->getRequest()->getParam('type'); if (!$productId && $typeId) { $product->setTypeId($typeId); } $product->setData('_edit_mode', true); if ($productId) { try { $product->load($productId); } catch (\Exception $e) { $product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE); $this->logger->critical($e); } } $setId = (int) $this->getRequest()->getParam('set'); if ($setId) { $product->setAttributeSetId($setId); } $this->registry->register('current_product', $product); $this->_view->loadLayout(false); $this->_view->renderLayout(); }
public function replaceCodeInRegistry($code) { if ($this->_registry->registry(static::REG_REFERRAL_CODE)) { $this->_registry->unregister(static::REG_REFERRAL_CODE); } $this->_registry->register(static::REG_REFERRAL_CODE, $code); }
/** * Save order into registry to use it in the overloaded controller. * * @param \Magento\Framework\Event\Observer $observer * @return $this */ public function execute(\Magento\Framework\Event\Observer $observer) { /* @var $order Order */ $order = $observer->getEvent()->getData('order'); $this->coreRegistry->register('directpost_order', $order, true); return $this; }
/** * Edit Synonym Group * * @return \Magento\Framework\Controller\ResultInterface * @SuppressWarnings(PHPMD.NPathComplexity) */ public function execute() { // 1. Get ID and create model $groupId = $this->getRequest()->getParam('group_id'); /** @var \Magento\Search\Api\Data\SynonymGroupInterface $synGroup */ $synGroup = $this->synGroupRepository->get($groupId); // 2. Initial checking if ($groupId && !$synGroup->getGroupId()) { $this->messageManager->addError(__('This synonyms group no longer exists.')); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('*/*/'); } // 3. Set entered data if was error when we do save $data = $this->_session->getFormData(true); if (!empty($data)) { $synGroup->setGroupId($data['group_id']); $synGroup->setStoreId($data['store_id']); $synGroup->setWebsiteId($data['website_id']); $synGroup->setSynonymGroup($data['synonyms']); } // 4. Register model to use later in save $this->registry->register(\Magento\Search\Controller\RegistryConstants::SEARCH_SYNONYMS, $synGroup); // 5. Build edit synonyms group form $resultPage = $this->pageBuilder->build(); $resultPage->addBreadcrumb($groupId ? __('Edit Synonym Group') : __('New Synonym Group'), $groupId ? __('Edit Synonym Group') : __('New Synonym Group')); $resultPage->getConfig()->getTitle()->prepend(__('Synonym Group')); $resultPage->getConfig()->getTitle()->prepend($synGroup->getGroupId() ? $synGroup->getSynonymGroup() : __('New Synonym Group')); return $resultPage; }
/** * Datafields option. * * @return array */ public function toOptionArray() { $fields = []; //default data option $fields[] = ['value' => '0', 'label' => '-- Please Select --']; $apiEnabled = $this->helper->isEnabled($this->helper->getWebsite()); if ($apiEnabled) { $savedDatafields = $this->registry->registry('datafields'); //get saved datafileds from registry if ($savedDatafields) { $datafields = $savedDatafields; } else { //grab the datafields request and save to register $client = $this->helper->getWebsiteApiClient(); $datafields = $client->getDatafields(); $this->registry->register('datafields', $datafields); } //set the api error message for the first option if (isset($datafields->message)) { //message $fields[] = ['value' => 0, 'label' => $datafields->message]; } else { //loop for all datafields option foreach ($datafields as $datafield) { if (isset($datafield->name)) { $fields[] = ['value' => $datafield->name, 'label' => $datafield->name]; } } } } return $fields; }
/** * Edit grid record * * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect * @SuppressWarnings(PHPMD.NPathComplexity) */ public function execute() { $id = $this->getRequest()->getParam('element_id'); $model = $this->_objectManager->create('OuterEdge\\Layout\\Model\\Elements'); if ($id) { $model->load($id); if (!$model->getId()) { $this->messageManager->addError(__('This element record no longer exists.')); /** \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('*/*/'); } } //Set entered data if was error when we do save $data = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getFormData(true); if (!empty($data)) { $model->setData($data); } //Register model to use later in blocks $this->_coreRegistry->register('layout_elements_form_data', $model); //Build edit form /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->_initAction(); $resultPage->addBreadcrumb($id ? __('Edit Element') : __('New Element'), $id ? __('Edit Element') : __('New Element')); $resultPage->getConfig()->getTitle()->prepend(__('Element')); $resultPage->getConfig()->getTitle()->prepend($model->getId() ? $model->getTitle() : __('New Element')); return $resultPage; }
/** * Retrieve list of options. * * @return array */ public function toOptionArray() { $fields = []; // Add a "Do Not Map" Option $fields[] = ['value' => 0, 'label' => '-- Please Select --']; $apiEnabled = $this->helper->isEnabled($this->helper->getWebsite()); if ($apiEnabled) { $savedAddressbooks = $this->registry->registry('addressbooks'); if ($savedAddressbooks) { $addressBooks = $savedAddressbooks; } else { $client = $this->helper->getWebsiteApiClient(); //make an api call an register the addressbooks $addressBooks = $client->getAddressBooks(); if ($addressBooks) { $this->registry->register('addressbooks', $addressBooks); } } //set up fields with book id and label foreach ($addressBooks as $book) { if (isset($book->id)) { $fields[] = ['value' => (string) $book->id, 'label' => (string) $book->name]; } } } return $fields; }
/** * Edit Newsletter Template * * @return void */ public function execute() { $model = $this->_objectManager->create('Magento\\Newsletter\\Model\\Template'); $id = $this->getRequest()->getParam('id'); if ($id) { $model->load($id); } $this->_coreRegistry->register('_current_template', $model); $this->_view->loadLayout(); $this->_setActiveMenu('Magento_Newsletter::newsletter_template'); if ($model->getId()) { $breadcrumbTitle = __('Edit Template'); $breadcrumbLabel = $breadcrumbTitle; } else { $breadcrumbTitle = __('New Template'); $breadcrumbLabel = __('Create Newsletter Template'); } $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Newsletter Templates')); $this->_view->getPage()->getConfig()->getTitle()->prepend($model->getId() ? $model->getTemplateCode() : __('New Template')); $this->_addBreadcrumb($breadcrumbLabel, $breadcrumbTitle); // restore data $values = $this->_getSession()->getData('newsletter_template_form_data', true); if ($values) { $model->addData($values); } $this->_view->renderLayout(); }
/** * Execute method. * * @param \Magento\Framework\Event\Observer $observer * * @return $this */ public function execute(\Magento\Framework\Event\Observer $observer) { try { if (!$this->registry->registry('core_config_data_save_after_done')) { if ($groups = $observer->getEvent()->getConfigData()->getGroups()) { if (isset($groups['catalog_sync']['fields']['catalog_values']['value'])) { $configAfter = $groups['catalog_sync']['fields']['catalog_values']['value']; $configBefore = $this->registry->registry('core_config_data_save_before'); if ($configAfter != $configBefore) { //reset catalog to re-import $this->connectorCatalogFactory->create()->reset(); } $this->registry->register('core_config_data_save_after_done', true); } } } if (!$this->registry->registry('core_config_data_save_after_done_status')) { if ($groups = $observer->getEvent()->getConfigData()->getGroups()) { if (isset($groups['data_fields']['fields']['order_statuses']['value'])) { $configAfter = $groups['data_fields']['fields']['order_statuses']['value']; $configBefore = $this->registry->registry('core_config_data_save_before_status'); if ($configAfter != $configBefore) { //reset all contacts $this->connectorContactFactory->create()->resetAllContacts(); } $this->registry->register('core_config_data_save_after_done_status', true); } } } } catch (\Exception $e) { $this->helper->debug((string) $e, []); } return $this; }
/** * Print Invoice Action * * @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\View\Result\Page */ public function execute() { $invoiceId = (int) $this->getRequest()->getParam('invoice_id'); if ($invoiceId) { $invoice = $this->_objectManager->create('Magento\\Sales\\Model\\Order\\Invoice')->load($invoiceId); $order = $invoice->getOrder(); } else { $orderId = (int) $this->getRequest()->getParam('order_id'); $order = $this->_objectManager->create('Magento\\Sales\\Model\\Order')->load($orderId); } if ($this->orderAuthorization->canView($order)) { $this->_coreRegistry->register('current_order', $order); if (isset($invoice)) { $this->_coreRegistry->register('current_invoice', $invoice); } /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->addHandle('print'); return $resultPage; } else { /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); if ($this->_objectManager->get('Magento\\Customer\\Model\\Session')->isLoggedIn()) { $resultRedirect->setPath('*/*/history'); } else { $resultRedirect->setPath('sales/guest/form'); } return $resultRedirect; } }
/** * After generate Xml * * @param \Magento\Framework\View\LayoutInterface $subject * @param \Magento\Framework\View\LayoutInterface $result * @return \Magento\Framework\View\LayoutInterface */ public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result) { if (!$this->registry->registry(self::REGISTRY_KEY)) { $this->registry->register(self::REGISTRY_KEY, $this->customerSession->getCustomer()); } return $result; }
/** * @return array */ public function toOptionArray() { $fields = []; $fields[] = ['value' => '0', 'label' => '-- Please Select --']; $apiEnabled = $this->helper->isEnabled($this->helper->getWebsite()); if ($apiEnabled) { $savedCampaigns = $this->registry->registry('campaigns'); if (is_array($savedCampaigns)) { $campaigns = $savedCampaigns; } else { //grab the datafields request and save to register $client = $this->helper->getWebsiteApiClient(); $campaigns = $client->getCampaigns(); $this->registry->register('campaigns', $campaigns); } //set the api error message for the first option if (isset($campaigns->message)) { //message $fields[] = ['value' => 0, 'label' => $campaigns->message]; } elseif (!empty($campaigns)) { //loop for all campaing options foreach ($campaigns as $campaign) { if (isset($campaign->name)) { //@codingStandardsIgnoreStart $fields[] = ['value' => $campaign->id, 'label' => addslashes($campaign->name)]; //@codingStandardsIgnoreEnd } } } } return $fields; }
/** * Edit Testimonial * * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect * @SuppressWarnings(PHPMD.NPathComplexity) */ public function execute() { $id = $this->getRequest()->getParam('testimonial_id'); $model = $this->_objectManager->create('V3N0m21\\Testimonials\\Model\\Testimonial'); if ($id) { $model->load($id); if (!$model->getId()) { $this->messageManager->addError(__('This testimonial no longer exists.')); /** \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('*/*/'); } } $data = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getFormData(true); if (!empty($data)) { $model->setData($data); } $this->_coreRegistry->register('testimonials_testimonial', $model); /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->_initAction(); $resultPage->addBreadcrumb($id ? __('Edit Testimonial') : __('New Testimonial'), $id ? __('Edit Testimonial') : __('New Testimonial')); $resultPage->getConfig()->getTitle()->prepend(__('Testimonials')); $resultPage->getConfig()->getTitle()->prepend($model->getId() ? $model->getTitle() : __('New Testimonial')); return $resultPage; }
public function testCanShowTabPositive() { $integrationData = $this->getFixtureIntegration()->getData(); $integrationData[Integration::SETUP_TYPE] = Integration::TYPE_CONFIG; $this->registry->register(IntegrationController::REGISTRY_KEY_CURRENT_INTEGRATION, $integrationData); $this->assertTrue($this->createApiTabBlock()->canShowTab()); }
/** * Print Invoice Action * * @return void */ public function execute() { $invoiceId = (int) $this->getRequest()->getParam('invoice_id'); if ($invoiceId) { $invoice = $this->_objectManager->create('Magento\\Sales\\Model\\Order\\Invoice')->load($invoiceId); $order = $invoice->getOrder(); } else { $orderId = (int) $this->getRequest()->getParam('order_id'); $order = $this->_objectManager->create('Magento\\Sales\\Model\\Order')->load($orderId); } if ($this->orderAuthorization->canView($order)) { $this->_coreRegistry->register('current_order', $order); if (isset($invoice)) { $this->_coreRegistry->register('current_invoice', $invoice); } $this->_view->loadLayout('print'); $this->_view->renderLayout(); } else { if ($this->_objectManager->get('Magento\\Customer\\Model\\Session')->isLoggedIn()) { $this->_redirect('*/*/history'); } else { $this->_redirect('sales/guest/form'); } } }
/** * Edit CMS page * * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect * @SuppressWarnings(PHPMD.NPathComplexity) */ public function execute() { // 1. Get ID and create model $id = $this->getRequest()->getParam('page_id'); $model = $this->_objectManager->create('Magento\\Cms\\Model\\Page'); // 2. Initial checking if ($id) { $model->load($id); if (!$model->getId()) { $this->messageManager->addError(__('This page no longer exists.')); /** \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('*/*/'); } } // 3. Set entered data if was error when we do save $data = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getFormData(true); if (!empty($data)) { $model->setData($data); } // 4. Register model to use later in blocks $this->_coreRegistry->register(RegistryConstants::CMS_PAGE, $model); // 5. Build edit form /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->_initAction(); $resultPage->addBreadcrumb($id ? __('Edit Page') : __('New Page'), $id ? __('Edit Page') : __('New Page')); $resultPage->getConfig()->getTitle()->prepend(__('Pages')); $resultPage->getConfig()->getTitle()->prepend($model->getId() ? $model->getTitle() : __('New Page')); return $resultPage; }
/** * @return \Magento\Framework\Controller\ResultInterface * @SuppressWarnings(PHPMD.NPathComplexity) */ public function execute() { $id = $this->getRequest()->getParam('id'); $model = $this->_objectManager->create('Magento\\Search\\Model\\Query'); if ($id) { $model->load($id); if (!$model->getId()) { $this->messageManager->addError(__('This search no longer exists.')); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $resultRedirect->setPath('search/*'); return $resultRedirect; } } // set entered data if was error when we do save $data = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getPageData(true); if (!empty($data)) { $model->addData($data); } $this->coreRegistry->register('current_catalog_search', $model); $resultPage = $this->createPage(); $resultPage->getConfig()->getTitle()->prepend(__('Search Terms')); $resultPage->getConfig()->getTitle()->prepend($id ? $model->getQueryText() : __('New Search')); $resultPage->getLayout()->getBlock('adminhtml.search.term.edit')->setData('action', $this->getUrl('search/term/save')); $resultPage->addBreadcrumb($id ? __('Edit Search') : __('New Search'), $id ? __('Edit Search') : __('New Search')); return $resultPage; }
/** * Edit sitemap * * @return void * @SuppressWarnings(PHPMD.NPathComplexity) */ public function execute() { // 1. Get ID and create model $id = $this->getRequest()->getParam('sitemap_id'); $model = $this->_objectManager->create('Magento\\Sitemap\\Model\\Sitemap'); // 2. Initial checking if ($id) { $model->load($id); if (!$model->getId()) { $this->messageManager->addError(__('This sitemap no longer exists.')); $this->_redirect('adminhtml/*/'); return; } } // 3. Set entered data if was error when we do save $data = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getFormData(true); if (!empty($data)) { $model->setData($data); } // 4. Register model to use later in blocks $this->_coreRegistry->register('sitemap_sitemap', $model); // 5. Build edit form $this->_initAction()->_addBreadcrumb($id ? __('Edit Sitemap') : __('New Sitemap'), $id ? __('Edit Sitemap') : __('New Sitemap'))->_addContent($this->_view->getLayout()->createBlock('Magento\\Sitemap\\Block\\Adminhtml\\Edit')); $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Site Map')); $this->_view->getPage()->getConfig()->getTitle()->prepend($model->getId() ? $model->getSitemapFilename() : __('New Site Map')); $this->_view->renderLayout(); }
/** * @return void */ public function execute() { $ipId = $this->getRequest()->getParam('id'); /** @var \Rapidmage\Firewall\Model\Ip $model */ $model = $this->_ipFactory->create(); if ($ipId) { $model->load($ipId); if (!$model->getId()) { $this->messageManager->addError(__('This Ip no longer exists.')); $this->_redirect('*/*/'); return; } } // Restore previously entered form data from session $data = $this->_session->getIpData(true); if (!empty($data)) { $model->setData($data); } $this->_coreRegistry->register('firewall_blackip', $model); /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->_resultPageFactory->create(); $resultPage->setActiveMenu('Rapidmage_Firewall::main_menu'); $resultPage->getConfig()->getTitle()->prepend(__('Firewall')); return $resultPage; }
/** * @return void */ public function execute() { $this->_title->add(__('Search Terms')); $id = $this->getRequest()->getParam('id'); $model = $this->_objectManager->create('Magento\\CatalogSearch\\Model\\Query'); if ($id) { $model->load($id); if (!$model->getId()) { $this->messageManager->addError(__('This search no longer exists.')); $this->_redirect('catalog/*'); return; } } // set entered data if was error when we do save $data = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getPageData(true); if (!empty($data)) { $model->addData($data); } $this->_coreRegistry->register('current_catalog_search', $model); $this->_initAction(); $this->_title->add($id ? $model->getQueryText() : __('New Search')); $this->_view->getLayout()->getBlock('head')->setCanLoadRulesJs(true); $this->_view->getLayout()->getBlock('adminhtml.catalog.search.edit')->setData('action', $this->getUrl('catalog/search/save')); $this->_addBreadcrumb($id ? __('Edit Search') : __('New Search'), $id ? __('Edit Search') : __('New Search')); $this->_view->renderLayout(); }
/** * Save order into registry to use it in the overloaded controller. * * @param EventObserver $observer * @return $this */ public function execute(EventObserver $observer) { /* @var $order \Magento\Sales\Model\Order */ $order = $observer->getEvent()->getData('order'); $this->_coreRegistry->register('hss_order', $order, true); return $this; }
/** * Get associated grouped products grid popup * * @return \Magento\Framework\View\Result\Layout */ public function execute() { $productId = (int) $this->getRequest()->getParam('id'); /** @var $product \Magento\Catalog\Model\Product */ $product = $this->factory->create(); $product->setStoreId($this->getRequest()->getParam('store', 0)); $typeId = $this->getRequest()->getParam('type'); if (!$productId && $typeId) { $product->setTypeId($typeId); } $product->setData('_edit_mode', true); if ($productId) { try { $product->load($productId); } catch (\Exception $e) { $product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE); $this->logger->critical($e); } } $setId = (int) $this->getRequest()->getParam('set'); if ($setId) { $product->setAttributeSetId($setId); } $this->registry->register('current_product', $product); /** @var \Magento\Framework\View\Result\Layout $resultLayout */ $resultLayout = $this->resultFactory->create(ResultFactory::TYPE_LAYOUT); return $resultLayout; }
public function execute() { // 1. Get ID and create model $id = $this->getRequest()->getParam("cat_id"); $model = $this->_objectManager->create("OsmanSorkar\\Blog\\Model\\Category"); if ($id) { $model->load($id); if (!$model->getId()) { $this->messageManager->addError(__("This Category no longer exists")); /** \Magento\Backend\Model\View\Result\Redirct $resultRedirct */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('*/*/'); } } // 3. Set entered data if was error when we do save $data = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getFormData(true); if (!empty($data)) { $model->setData($data); } // 4. Register model to use later in blocks $this->_coreRegistry->register('blog_category', $model); // 5. Build edit form /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->setActiveMenu('Ashsmith_Blog::category'); $resultPage->addBreadcrumb(__('Blog Category Edit'), __('Blog Category Edit')); $resultPage->addBreadcrumb(__('Manage Blog Category'), __('Manage Blog Category')); $resultPage->getConfig()->getTitle()->prepend(__('Blog Category Edit')); return $resultPage; }
/** * @return \Magento\Framework\Controller\Result\Forward|\Magento\Framework\View\Result\Page */ public function execute() { $articleId = (int) $this->getRequest()->getParam('id'); $article = $this->articleFactory->create(); $article->load($articleId); if (!$article->isActive()) { $resultForward = $this->resultForwardFactory->create(); $resultForward->forward('noroute'); return $resultForward; } $this->coreRegistry->register('current_article', $article); $resultPage = $this->resultPageFactory->create(); $title = $article->getMetaTitle() ?: $article->getName(); $resultPage->getConfig()->getTitle()->set($title); $resultPage->getConfig()->setDescription($article->getMetaDescription()); $resultPage->getConfig()->setKeywords($article->getMetaKeywords()); if ($this->scopeConfig->isSetFlag(self::BREADCRUMBS_CONFIG_PATH, ScopeInterface::SCOPE_STORE)) { /** @var \Magento\Theme\Block\Html\Breadcrumbs $breadcrumbsBlock */ $breadcrumbsBlock = $resultPage->getLayout()->getBlock('breadcrumbs'); if ($breadcrumbsBlock) { $breadcrumbsBlock->addCrumb('home', ['label' => __('Home'), 'link' => $this->_url->getUrl('')]); $breadcrumbsBlock->addCrumb('articles', ['label' => __('Articles'), 'link' => $this->urlModel->getListUrl()]); $breadcrumbsBlock->addCrumb('article-' . $article->getId(), ['label' => $article->getName()]); } } return $resultPage; }
/** * If it's configured to capture on shipment - do this. * * @param \Magento\Framework\Event\Observer $observer * * @return $this */ public function execute(\Magento\Framework\Event\Observer $observer) { $customer = $observer->getEvent()->getCustomer(); $email = $customer->getEmail(); $websiteId = $customer->getWebsiteId(); $customerId = $customer->getEntityId(); $isSubscribed = $customer->getIsSubscribed(); try { // fix for a multiple hit of the observer $emailReg = $this->registry->registry($email . '_customer_save'); if ($emailReg) { return $this; } $this->registry->register($email . '_customer_save', $email); $emailBefore = $this->customerFactory->create()->load($customer->getId())->getEmail(); $contactModel = $this->contactFactory->create()->loadByCustomerEmail($emailBefore, $websiteId); //email change detection if ($email != $emailBefore) { $this->helper->log('email change detected : ' . $email . ', after : ' . $emailBefore . ', website id : ' . $websiteId); $data = ['emailBefore' => $emailBefore, 'email' => $email, 'isSubscribed' => $isSubscribed]; $this->importerFactory->registerQueue(\Dotdigitalgroup\Email\Model\Importer::IMPORT_TYPE_CONTACT_UPDATE, $data, \Dotdigitalgroup\Email\Model\Importer::MODE_CONTACT_EMAIL_UPDATE, $websiteId); } elseif (!$emailBefore) { //for new contacts update email $contactModel->setEmail($email); } $contactModel->setEmailImported(\Dotdigitalgroup\Email\Model\Contact::EMAIL_CONTACT_NOT_IMPORTED)->setCustomerId($customerId)->save(); } catch (\Exception $e) { $this->helper->debug((string) $e, []); } return $this; }
/** * Execute per test initialization. */ public function setUp() { $objectManager = Bootstrap::getObjectManager(); $objectManager->get('Magento\\Framework\\App\\State')->setAreaCode('adminhtml'); $this->coreRegistry = $objectManager->get('Magento\\Framework\\Registry'); $this->coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, self::$customerId); $this->block = $objectManager->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Customer\\Block\\Adminhtml\\Edit', '', ['coreRegistry' => $this->coreRegistry]); }