/** * Update product(s) status action * * @return \Magento\Backend\Model\View\Result\Redirect */ public function execute() { $collection = $this->filter->getCollection($this->collectionFactory->create()); $productIds = $collection->getAllIds(); $storeId = (int) $this->getRequest()->getParam('store', 0); $attributeSetId = (int) $this->getRequest()->getParam('changeattributeset'); try { foreach ($collection->getItems() as $product) { //echo get_class($product->getTypeInstance());die(); if ($this->validateConfigurable($product, $attributeSetId, $storeId) == false) { $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('catalog/*/', ['store' => $storeId]); break; } $product->setAttributeSetId($attributeSetId)->setStoreId($storeId); } $collection->save(); //$product->getTypeInstance(); $this->messageManager->addSuccess(__('A total of %1 record(s) have been updated.', count($productIds))); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->_getSession()->addException($e, __('Something went wrong while updating the product(s) atrribute set.')); } /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('catalog/*/', ['store' => $storeId]); }
/** * @return \Magento\Framework\Controller\ResultInterface */ public function executeInternal() { $collection = $this->filter->getCollection($this->collectionFactory->create()); $this->attributeHelper->setProductIds($collection->getAllIds()); if (!$this->_validateProducts()) { return $this->resultRedirectFactory->create()->setPath('catalog/product/', ['_current' => true]); } $resultPage = $this->resultPageFactory->create(); $resultPage->getConfig()->getTitle()->prepend(__('Update Attributes')); return $resultPage; }
/** * @return \Magento\Backend\Model\View\Result\Redirect */ public function execute() { $collection = $this->filter->getCollection($this->collectionFactory->create()); $productDeleted = 0; foreach ($collection->getItems() as $product) { $product->delete(); $productDeleted++; } $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $productDeleted)); return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)->setPath('catalog/*/index'); }
/** * Dispatch request * * @return \Magento\Framework\Controller\ResultInterface|ResponseInterface * @throws \Magento\Framework\Exception\NotFoundException */ public function execute() { $collection = $this->filter->getCollection($this->collectionFactory->create()); $collectionSize = $collection->getSize(); foreach ($collection as $item) { $item->delete(); } $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.'), $collectionSize); $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); }
/** * Execute action * * @return \Magento\Backend\Model\View\Result\Redirect * @throws \Magento\Framework\Exception\LocalizedException|\Exception */ public function execute() { $collection = $this->filter->getCollection($this->collectionFactory->create()); foreach ($collection as $item) { $item->setStatus(false); $item->save(); } $this->messageManager->addSuccess(__('A total of %1 record(s) have been disabled.', $collection->getSize())); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); }
/** * Execute action * * @return \Magento\Backend\Model\View\Result\Redirect * @throws \Magento\Framework\Exception\LocalizedException|\Exception */ public function executeInternal() { $collection = $this->filter->getCollection($this->collectionFactory->create()); $collectionSize = $collection->getSize(); foreach ($collection as $page) { $page->delete(); } $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $collectionSize)); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); }
/** * Execute action * * @return \Magento\Backend\Model\View\Result\Redirect * @throws \Magento\Framework\Exception\LocalizedException|\Exception */ public function execute() { try { $collection = $this->filter->getCollection($this->collectionFactory->create()); return $this->massAction($collection); } catch (\Exception $e) { $this->messageManager->addError($e->getMessage()); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath($this->redirectUrl); } }
/** * Dispatch request * * @return \Magento\Framework\Controller\ResultInterface|ResponseInterface * @throws \Magento\Framework\Exception\NotFoundException */ public function execute() { /** @var Collection $collection */ $collection = $this->filter->getCollection($this->teaserItemCollectionFactory->create()); /** @var TeaserItem $teaserItem */ foreach ($collection as $teaserItem) { $teaserItem->delete(); } $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $collection->getSize())); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); }
/** * execute action * * @return \Magento\Backend\Model\View\Result\Redirect */ public function execute() { $collection = $this->filter->getCollection($this->collectionFactory->create()); $delete = 0; foreach ($collection as $item) { /** @var \Mageplaza\Blog\Model\Topic $item */ $item->delete(); $delete++; } $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $delete)); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); }
/** * Execute action * * @return \Magento\Backend\Model\View\Result\Redirect * @throws \Magento\Framework\Exception\LocalizedException|\Exception */ public function execute() { $key = 'status'; $value = 1; $collection = $this->filter->getCollection($this->collectionFactory->create()); $collectionSize = $collection->getSize(); foreach ($collection as $row) { $row->setData($key, $value); $row->save(); } $this->messageManager->addSuccess(__('A total of %1 record(s) have been changed.', $collectionSize)); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); }
/** * @return mixed */ public function execute() { try { $collection = $this->filter->getCollection($this->collectionFactory->create()); $collectionSize = $collection->getSize(); foreach ($collection as $article) { $this->doTheAction($article); } $this->messageManager->addSuccess(__($this->successMessage, $collectionSize)); } catch (LocalizedException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __($this->errorMessage)); } $redirectResult = $this->resultRedirectFactory->create(); $redirectResult->setPath('gemtoo_blog/*/index'); return $redirectResult; }
/** * Update product(s) status action * * @return \Magento\Backend\Model\View\Result\Redirect */ public function execute() { $collection = $this->filter->getCollection($this->collectionFactory->create()); $productIds = $collection->getAllIds(); $storeId = (int) $this->getRequest()->getParam('store', 0); $status = (int) $this->getRequest()->getParam('status'); try { $this->_validateMassStatus($productIds, $status); $this->_objectManager->get('Magento\\Catalog\\Model\\Product\\Action')->updateAttributes($productIds, ['status' => $status], $storeId); $this->messageManager->addSuccess(__('A total of %1 record(s) have been updated.', count($productIds))); $this->_productPriceIndexerProcessor->reindexList($productIds); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->_getSession()->addException($e, __('Something went wrong while updating the product(s) status.')); } /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('catalog/*/', ['store' => $storeId]); }
/** * Execute action * * @return \Magento\Backend\Model\View\Result\Redirect * @throws \Magento\Framework\Exception\LocalizedException|\Exception */ public function execute() { $collection = $this->filter->getCollection($this->collectionFactory->create()); $collectionSize = $collection->getSize(); $deletedItems = 0; foreach ($collection as $synonymGroup) { try { $this->synGroupRepository->delete($synonymGroup); $deletedItems++; } catch (\Exception $e) { $this->messageManager->addError($e->getMessage()); } } if ($deletedItems != 0) { if ($collectionSize != $deletedItems) { $this->messageManager->addError(__('Failed to delete %1 synonym group(s).', $collectionSize - $deletedItems)); } $this->messageManager->addSuccess(__('A total of %1 synonym group(s) have been deleted.', $deletedItems)); } /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); }