/** * 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 = $this->coreRegistry->registry('directpost_order'); if (!$order || !$order->getId()) { return $this; } $payment = $order->getPayment(); if (!$payment || $payment->getMethod() != $this->payment->getCode()) { return $this; } $result = $observer->getData('result')->getData(); if (!empty($result['error'])) { return $this; } // if success, then set order to session and add new fields $this->session->addCheckoutOrderIncrementId($order->getIncrementId()); $this->session->setLastOrderIncrementId($order->getIncrementId()); $requestToAuthorizenet = $payment->getMethodInstance()->generateRequestFromOrder($order); $requestToAuthorizenet->setControllerActionName($observer->getData('action')->getRequest()->getControllerName()); $requestToAuthorizenet->setIsSecure((string) $this->storeManager->getStore()->isCurrentlySecure()); $result[$this->payment->getCode()] = ['fields' => $requestToAuthorizenet->getData()]; $observer->getData('result')->setData($result); return $this; }
/** * 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; }
/** * 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 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; }
/** * Get log model * * @return \ClassyLlama\AvaTax\Model\Log */ public function getLog() { if (null === $this->currentLog) { $this->currentLog = $this->coreRegistry->registry('current_log'); } return $this->currentLog; }
/** * @return string */ protected function _toHtml() { /** @var $rssObj \Magento\Rss\Model\Rss */ $rssObj = $this->_rssFactory->create(); $order = $this->_coreRegistry->registry('current_order'); if (!$order) { return ''; } $title = __('Order # %1 Notification(s)', $order->getIncrementId()); $newUrl = $this->_urlBuilder->getUrl('sales/order/view', array('order_id' => $order->getId())); $rssObj->_addHeader(array('title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8')); /** @var $resourceModel \Magento\Rss\Model\Resource\Order */ $resourceModel = $this->_orderFactory->create(); $results = $resourceModel->getAllCommentCollection($order->getId()); if ($results) { foreach ($results as $result) { $urlAppend = 'view'; $type = $result['entity_type_code']; if ($type && $type != 'order') { $urlAppend = $type; } $type = __(ucwords($type)); $title = __('Details for %1 #%2', $type, $result['increment_id']); $description = '<p>' . __('Notified Date: %1<br/>', $this->formatDate($result['created_at'])) . __('Comment: %1<br/>', $result['comment']) . '</p>'; $url = $this->_urlBuilder->getUrl('sales/order/' . $urlAppend, array('order_id' => $order->getId())); $rssObj->_addEntry(array('title' => $title, 'link' => $url, 'description' => $description)); } } $title = __('Order #%1 created at %2', $order->getIncrementId(), $this->formatDate($order->getCreatedAt())); $url = $this->_urlBuilder->getUrl('sales/order/view', array('order_id' => $order->getId())); $description = '<p>' . __('Current Status: %1<br/>', $order->getStatusLabel()) . __('Total: %1<br/>', $order->formatPrice($order->getGrandTotal())) . '</p>'; $rssObj->_addEntry(array('title' => $title, 'link' => $url, 'description' => $description)); return $rssObj->createRssXml(); }
/** * Execute before toHtml() code. * * @return $this */ public function _beforeToHtml() { $this->_currency = $this->_currencyFactory->create()->load($this->_scopeConfig->getValue(Currency::XML_PATH_CURRENCY_BASE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)); $this->_collection = $this->_collectionFactory->create()->setCustomerIdFilter((int) $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID))->setOrderStateFilter(Order::STATE_CANCELED, true)->load(); $this->_groupedCollection = []; foreach ($this->_collection as $sale) { if ($sale->getStoreId() !== null) { $store = $this->_storeManager->getStore($sale->getStoreId()); $websiteId = $store->getWebsiteId(); $groupId = $store->getGroupId(); $storeId = $store->getId(); $sale->setWebsiteId($store->getWebsiteId()); $sale->setWebsiteName($store->getWebsite()->getName()); $sale->setGroupId($store->getGroupId()); $sale->setGroupName($store->getGroup()->getName()); } else { $websiteId = 0; $groupId = 0; $storeId = 0; $sale->setStoreName(__('Deleted Stores')); } $this->_groupedCollection[$websiteId][$groupId][$storeId] = $sale; $this->_websiteCounts[$websiteId] = isset($this->_websiteCounts[$websiteId]) ? $this->_websiteCounts[$websiteId] + 1 : 1; } return parent::_beforeToHtml(); }
/** * 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; }
/** * 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; }
/** * 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; }
/** * {@inheritdoc} */ protected function _prepareLayout() { $this->setId('customerViewAccordion'); $this->addItem('lastOrders', array('title' => __('Recent Orders'), 'ajax' => true, 'content_url' => $this->getUrl('customer/*/lastOrders', array('_current' => true)))); $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); $customer = $this->getCustomer($customerId); $websiteIds = $this->_shareConfig->getSharedWebsiteIds($customer->getWebsiteId()); // add shopping cart block of each website foreach ($websiteIds as $websiteId) { $website = $this->_storeManager->getWebsite($websiteId); // count cart items $cartItemsCount = $this->_quoteFactory->create()->setWebsite($website)->loadByCustomer($customerId)->getItemsCollection(false)->addFieldToFilter('parent_item_id', array('null' => true))->getSize(); // prepare title for cart $title = __('Shopping Cart - %1 item(s)', $cartItemsCount); if (count($websiteIds) > 1) { $title = __('Shopping Cart of %1 - %2 item(s)', $website->getName(), $cartItemsCount); } // add cart ajax accordion $this->addItem('shopingCart' . $websiteId, array('title' => $title, 'ajax' => true, 'content_url' => $this->getUrl('customer/*/viewCart', array('_current' => true, 'website_id' => $websiteId)))); } // count wishlist items $wishlistCount = $this->_itemsFactory->create()->addCustomerIdFilter($customerId)->addStoreData()->getSize(); // add wishlist ajax accordion $this->addItem('wishlist', array('title' => __('Wishlist - %1 item(s)', $wishlistCount), 'ajax' => true, 'content_url' => $this->getUrl('customer/*/viewWishlist', array('_current' => true)))); }
/** * {@inheritdoc} */ protected function _prepareForm() { /** @var \Mirasvit\Search\Model\Index $model */ $model = $this->registry->registry('current_model'); $form = $this->formFactory->create(); $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('General Information'), 'class' => 'fieldset-wide']); if ($model->getId()) { $fieldset->addField('index_id', 'hidden', ['name' => 'id']); } $fieldset->addField('title', 'text', ['name' => 'title', 'label' => __('Title'), 'required' => true]); if ($model->getId()) { $model->setData('index_label', $model->getIndexInstance()->toString()); $fieldset->addField('index_label', 'label', ['label' => __('Index')]); } else { $fieldset->addField('code', 'select', ['label' => __('Index'), 'name' => 'code', 'required' => true, 'values' => $this->sourceIndex->toOptionArray(true)]); } $fieldset->addField('position', 'text', ['name' => 'position', 'label' => __('Position'), 'required' => true]); $fieldset->addField('is_active', 'select', ['label' => __('Status'), 'name' => 'is_active', 'required' => true, 'options' => ['1' => __('Enabled'), '0' => __('Disabled')]]); if (!$model->getId()) { $model->setData('is_active', '1'); } $form->setValues($model->getData()); $this->setForm($form); return parent::_prepareForm(); }
/** * Retrieve currently viewed product object * * @return \Magento\Catalog\Model\Product */ public function getProduct() { if (!$this->hasData('product')) { $this->setData('product', $this->_coreRegistry->registry('product')); } return $this->getData('product'); }
/** * 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; }
/** * Apply catalog price rules to product in admin * * @param \Magento\Framework\Event\Observer $observer * @return $this */ public function execute(\Magento\Framework\Event\Observer $observer) { $product = $observer->getEvent()->getProduct(); $storeId = $product->getStoreId(); $date = $this->localeDate->scopeDate($storeId); $key = false; $ruleData = $this->coreRegistry->registry('rule_data'); if ($ruleData) { $wId = $ruleData->getWebsiteId(); $gId = $ruleData->getCustomerGroupId(); $pId = $product->getId(); $key = "{$date->format('Y-m-d H:i:s')}|{$wId}|{$gId}|{$pId}"; } elseif ($product->getWebsiteId() !== null && $product->getCustomerGroupId() !== null) { $wId = $product->getWebsiteId(); $gId = $product->getCustomerGroupId(); $pId = $product->getId(); $key = "{$date->format('Y-m-d H:i:s')}|{$wId}|{$gId}|{$pId}"; } if ($key) { if (!$this->rulePricesStorage->hasRulePrice($key)) { $rulePrice = $this->resourceRuleFactory->create()->getRulePrice($date, $wId, $gId, $pId); $this->rulePricesStorage->setRulePrice($key, $rulePrice); } if ($this->rulePricesStorage->getRulePrice($key) !== false) { $finalPrice = min($product->getData('final_price'), $this->rulePricesStorage->getRulePrice($key)); $product->setFinalPrice($finalPrice); } } return $this; }
/** * Action for reorder * * @return void */ public function execute() { if (!$this->orderLoader->load($this->_request, $this->_response)) { return; } $order = $this->_coreRegistry->registry('current_order'); /* @var $cart \Magento\Checkout\Model\Cart */ $cart = $this->_objectManager->get('Magento\\Checkout\\Model\\Cart'); $items = $order->getItemsCollection(); foreach ($items as $item) { try { $cart->addOrderItem($item); } catch (\Magento\Framework\Model\Exception $e) { if ($this->_objectManager->get('Magento\\Checkout\\Model\\Session')->getUseNotice(true)) { $this->messageManager->addNotice($e->getMessage()); } else { $this->messageManager->addError($e->getMessage()); } $this->_redirect('*/*/history'); } catch (\Exception $e) { $this->messageManager->addException($e, __('We cannot add this item to your shopping cart.')); $this->_redirect('checkout/cart'); } } $cart->save(); $this->_redirect('checkout/cart'); }
/** * Forms script response * * @return string */ public function _toHtml() { $updateResult = $this->_coreRegistry->registry('composite_update_result'); $resultJson = $this->_jsonEncoder->encode($updateResult); $jsVarname = $updateResult->getJsVarName(); return $this->_jsHelper->getScript(sprintf('var %s = %s', $jsVarname, $resultJson)); }
/** * save product data * * @param $observer * * @return $this */ public function execute(EventObserver $observer) { $downloads = $this->context->getRequest()->getFiles('downloads', -1); if ($downloads != '-1') { // Get current product $product = $this->coreRegistry->registry('product'); $productId = $product->getId(); // Loop through uploaded downlaods foreach ($downloads as $download) { // Upload file $uploadedDownload = $this->upload->uploadFile($download); if ($uploadedDownload) { $objectManager = $this->context->getObjectManager(); // Store date in database $download = $objectManager->create('Sebwite\\ProductDownloads\\Model\\Download'); $download->setDownloadUrl($uploadedDownload['file']); $download->setDownloadFile($uploadedDownload['name']); $download->setDownloadType($uploadedDownload['type']); $download->setProductId($productId); $download->save(); } } } return $this; }
/** * Retrieve text for header element depending on loaded page * * @return string */ public function getHeaderText() { $process = $this->_coreRegistry->registry('current_index_process'); if ($process && $process->getId()) { return __("'%1' Index Process Information", $process->getIndexer()->getName()); } }
/** * Change default JavaScript templates for options rendering * * @param \Magento\Framework\Event\Observer $observer * @return $this * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function execute(\Magento\Framework\Event\Observer $observer) { $response = $observer->getEvent()->getResponseObject(); $options = $response->getAdditionalOptions(); /** @var \Magento\Catalog\Model\Product $product */ $product = $this->registry->registry('current_product'); if (!$product) { return $this; } if ($this->weeeData->isEnabled() && !$this->weeeData->geDisplayIncl($product->getStoreId()) && !$this->weeeData->geDisplayExcl($product->getStoreId())) { // only do processing on bundle product if ($product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) { if (!array_key_exists('optionTemplate', $options)) { $calcPrice = $this->getWhichCalcPriceToUse($product->getStoreId()); $options['optionTemplate'] = '<%- data.label %>' . '<% if (data.' . $calcPrice . '.value) { %>' . ' +<%- data.' . $calcPrice . '.formatted %>' . '<% } %>'; } foreach ($this->weeeData->getWeeeAttributesForBundle($product) as $weeeAttributes) { foreach ($weeeAttributes as $weeeAttribute) { if (!preg_match('/' . $weeeAttribute->getCode() . '/', $options['optionTemplate'])) { $options['optionTemplate'] .= sprintf(' <%% if (data.weeePrice' . $weeeAttribute->getCode() . ') { %%>' . ' (' . $weeeAttribute->getName() . ': <%%- data.weeePrice' . $weeeAttribute->getCode() . '.formatted %%>)' . '<%% } %%>'); } } } if ($this->weeeData->geDisplayExlDescIncl($product->getStoreId())) { $options['optionTemplate'] .= sprintf(' <%% if (data.weeePrice) { %%>' . '<%%- data.weeePrice.formatted %%>' . '<%% } %%>'); } } } $response->setAdditionalOptions($options); return $this; }
/** * Action for reorder * * @return \Magento\Framework\Controller\ResultInterface */ public function executeInternal() { $result = $this->orderLoader->load($this->_request); if ($result instanceof \Magento\Framework\Controller\ResultInterface) { return $result; } $order = $this->_coreRegistry->registry('current_order'); /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); /* @var $cart \Magento\Checkout\Model\Cart */ $cart = $this->_objectManager->get('Magento\Checkout\Model\Cart'); $items = $order->getItemsCollection(); foreach ($items as $item) { try { $cart->addOrderItem($item); } catch (\Magento\Framework\Exception\LocalizedException $e) { if ($this->_objectManager->get('Magento\Checkout\Model\Session')->getUseNotice(true)) { $this->messageManager->addNotice($e->getMessage()); } else { $this->messageManager->addError($e->getMessage()); } return $resultRedirect->setPath('*/*/history'); } catch (\Exception $e) { $this->messageManager->addException($e, __('We can\'t add this item to your shopping cart right now.')); return $resultRedirect->setPath('checkout/cart'); } } $cart->save(); return $resultRedirect->setPath('checkout/cart'); }
/** * @return \Magento\Framework\Phrase */ public function getHeaderText() { if ($this->_coreRegistry->registry('blog_post')->getId()) { return __('Edit post "%1"', $this->escapeHtml($this->_coreRegistry->registry('blog_post')->getTitle())); } return __('New post'); }
/** * Get current product instance * * @return \Magento\Catalog\Model\Product */ public function getProduct() { if (!is_null($this->_product)) { return $this->_product; } return $this->_coreRegistry->registry('product'); }
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); }
/** * @return Product */ public function getProduct() { if (!$this->_product) { $this->_product = $this->_coreRegistry->registry('product'); } return $this->_product; }
/** * @param \Magento\Framework\Controller\ResultInterface $subject * @param callable $proceed * @param ResponseHttp $response * @return \Magento\Framework\Controller\ResultInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundRenderResult(\Magento\Framework\Controller\ResultInterface $subject, \Closure $proceed, ResponseHttp $response) { $result = $proceed($response); $usePlugin = $this->registry->registry('use_page_cache_plugin'); if (!$usePlugin || !$this->config->isEnabled() || $this->config->getType() != \Magento\PageCache\Model\Config::BUILT_IN) { return $result; } if ($this->state->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) { $cacheControlHeader = $response->getHeader('Cache-Control'); if ($cacheControlHeader instanceof \Zend\Http\Header\HeaderInterface) { $response->setHeader('X-Magento-Cache-Control', $cacheControlHeader->getFieldValue()); } $response->setHeader('X-Magento-Cache-Debug', 'MISS', true); } $tagsHeader = $response->getHeader('X-Magento-Tags'); $tags = []; if ($tagsHeader) { $tags = explode(',', $tagsHeader->getFieldValue()); $response->clearHeader('X-Magento-Tags'); } $tags = array_unique(array_merge($tags, [\Magento\PageCache\Model\Cache\Type::CACHE_TAG])); $response->setHeader('X-Magento-Tags', implode(',', $tags)); $this->kernel->process($response); return $result; }
public function getDemoId() { if (!$this->demoId) { $this->demoId = $this->coreRegistry->registry('current_demo_id'); } return $this->demoId; }
/** * @return $this */ protected function _prepareCollection() { /** @var $collection \Magento\Newsletter\Model\Resource\Queue\Collection */ $collection = $this->_collectionFactory->create()->addTemplateInfo()->addSubscriberFilter($this->_coreRegistry->registry('subscriber')->getId()); $this->setCollection($collection); return parent::_prepareCollection(); }
/** * Retrieve currently edited product object * * @return \Magento\Catalog\Model\Product|boolean */ protected function getProduct() { $product = $this->_registry->registry('current_product'); if ($product && $product->getId()) { return $product; } return false; }
/** * Retrieve text for header element depending on loaded post * * @return \Magento\Framework\Phrase */ public function getHeaderText() { if ($this->_coreRegistry->registry('blog_post')->getId()) { return __("Edit Post '%1'", $this->escapeHtml($this->_coreRegistry->registry('blog_post')->getTitle())); } else { return __('New Post'); } }