• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP MassAction\Filter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Magento\Ui\Component\MassAction\Filter的典型用法代码示例。如果您正苦于以下问题:PHP Filter类的具体用法?PHP Filter怎么用?PHP Filter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Filter类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: setUp

 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', [], [], '', false);
     $this->responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', ['create'], [], '', false);
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\Manager', [], [], '', false);
     $this->customerCollectionMock = $this->getMockBuilder('Magento\\Customer\\Model\\ResourceModel\\Customer\\Collection')->disableOriginalConstructor()->getMock();
     $this->customerCollectionFactoryMock = $this->getMockBuilder('Magento\\Customer\\Model\\ResourceModel\\Customer\\CollectionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $redirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $resultFactoryMock->expects($this->any())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($redirectMock);
     $this->resultRedirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock);
     $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock);
     $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock);
     $this->contextMock->expects($this->any())->method('getResultRedirectFactory')->willReturn($resultRedirectFactory);
     $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($resultFactoryMock);
     $this->filterMock = $this->getMock('Magento\\Ui\\Component\\MassAction\\Filter', [], [], '', false);
     $this->filterMock->expects($this->once())->method('getCollection')->with($this->customerCollectionMock)->willReturnArgument(0);
     $this->customerCollectionFactoryMock->expects($this->once())->method('create')->willReturn($this->customerCollectionMock);
     $this->customerRepositoryMock = $this->getMockBuilder('Magento\\Customer\\Api\\CustomerRepositoryInterface')->getMockForAbstractClass();
     $this->massAction = $objectManagerHelper->getObject('Magento\\Customer\\Controller\\Adminhtml\\Index\\MassAssignGroup', ['context' => $this->contextMock, 'filter' => $this->filterMock, 'collectionFactory' => $this->customerCollectionFactoryMock, 'customerRepository' => $this->customerRepositoryMock]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:28,代码来源:MassAssignGroupTest.php


示例2: setUp

 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', [], [], '', false);
     $this->responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', [], [], '', false);
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\Manager', [], [], '', false);
     $this->orderCollectionMock = $this->getMockBuilder('Magento\\Sales\\Model\\ResourceModel\\Order\\Collection')->disableOriginalConstructor()->getMock();
     $orderCollection = 'Magento\\Sales\\Model\\ResourceModel\\Order\\CollectionFactory';
     $this->orderCollectionFactoryMock = $this->getMockBuilder($orderCollection)->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->sessionMock = $this->getMock('Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
     $this->actionFlagMock = $this->getMock('Magento\\Framework\\App\\ActionFlag', ['get', 'set'], [], '', false);
     $this->helperMock = $this->getMock('\\Magento\\Backend\\Helper\\Data', ['getUrl'], [], '', false);
     $this->resultRedirectMock = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock);
     $redirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $resultFactoryMock->expects($this->any())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($redirectMock);
     $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock);
     $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock);
     $this->contextMock->expects($this->once())->method('getSession')->willReturn($this->sessionMock);
     $this->contextMock->expects($this->once())->method('getActionFlag')->willReturn($this->actionFlagMock);
     $this->contextMock->expects($this->once())->method('getHelper')->willReturn($this->helperMock);
     $this->contextMock->expects($this->once())->method('getResultRedirectFactory')->willReturn($resultRedirectFactory);
     $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($resultFactoryMock);
     $this->filterMock = $this->getMock('Magento\\Ui\\Component\\MassAction\\Filter', [], [], '', false);
     $this->filterMock->expects($this->once())->method('getCollection')->with($this->orderCollectionMock)->willReturn($this->orderCollectionMock);
     $this->orderCollectionFactoryMock->expects($this->once())->method('create')->willReturn($this->orderCollectionMock);
     $this->massAction = $objectManagerHelper->getObject('Magento\\Sales\\Controller\\Adminhtml\\Order\\MassUnhold', ['context' => $this->contextMock, 'filter' => $this->filterMock, 'collectionFactory' => $this->orderCollectionFactoryMock]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:34,代码来源:MassUnholdTest.php


示例3: getOptions

 /**
  * Returns Filters with options
  *
  * @return array
  */
 public function getOptions()
 {
     $options = [];
     $component = $this->filter->getComponent();
     $childComponents = $component->getChildComponents();
     $listingTop = $childComponents['listing_top'];
     foreach ($listingTop->getChildComponents() as $child) {
         if ($child instanceof Filters) {
             foreach ($child->getChildComponents() as $filter) {
                 if ($filter instanceof Select) {
                     $options[$filter->getName()] = $this->getFilterOptions($filter);
                 }
             }
         }
     }
     return $options;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:22,代码来源:MetadataProvider.php


示例4: execute

 /**
  * 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]);
 }
开发者ID:salelsol,项目名称:magento2-extension-change-attribute-set,代码行数:33,代码来源:MassChangeattributeset.php


示例5: executeInternal

 /**
  * @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;
 }
开发者ID:nblair,项目名称:magescotch,代码行数:14,代码来源:Edit.php


示例6: execute

 /**
  * 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('*/*/');
 }
开发者ID:pyvil,项目名称:magento2-blog-module,代码行数:17,代码来源:MassDelete.php


示例7: execute

 /**
  * @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');
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:MassDelete.php


示例8: execute

 /**
  * 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('*/*/');
 }
开发者ID:vasuscoin,项目名称:brand,代码行数:18,代码来源:MassDisable.php


示例9: executeInternal

 /**
  * 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('*/*/');
 }
开发者ID:nblair,项目名称:magescotch,代码行数:18,代码来源:MassDelete.php


示例10: execute

 /**
  * Execute controller.
  *
  * @return $this
  */
 public function execute()
 {
     $collection = $this->filter->getCollection($this->collectionFactory->create());
     try {
         $this->_allAction($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(static::REDIRECT_URL);
 }
开发者ID:swnsma,项目名称:practice,代码行数:17,代码来源:MassActionAbstract.php


示例11: execute

 /**
  * 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('*/*/');
 }
开发者ID:davidverholen,项目名称:magento2-teaser,代码行数:19,代码来源:MassDelete.php


示例12: execute

 /**
  * 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('*/*/');
 }
开发者ID:mageplaza,项目名称:magento-2-blog-extension,代码行数:19,代码来源:MassDelete.php


示例13: execute

 /**
  * 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('*/*/');
 }
开发者ID:swissup,项目名称:email,代码行数:21,代码来源:MassEnable.php


示例14: testExecutePageRequested

 public function testExecutePageRequested()
 {
     $this->request->expects($this->any())->method('getParam')->with('filters')->willReturn(['placeholder' => true]);
     $this->request->expects($this->any())->method('getParams')->willReturn(['namespace' => 'product_listing', 'exclude' => true, 'filters' => ['placeholder' => true]]);
     $this->attributeHelper->expects($this->any())->method('getProductIds')->willReturn([1, 2, 3]);
     $this->attributeHelper->expects($this->any())->method('setProductIds')->with([1, 2, 3]);
     $collection = $this->getMockBuilder('Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection')->setMethods(['getAllIds'])->disableOriginalConstructor()->getMock();
     $collection->expects($this->any())->method('getAllIds')->willReturn([1, 2, 3]);
     $this->filter->expects($this->any())->method('getCollection')->with($collection)->willReturn($collection);
     $this->collectionFactory->expects($this->any())->method('create')->willReturn($collection);
     $title = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->setMethods(['prepend'])->disableOriginalConstructor()->getMock();
     $config = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->setMethods(['getTitle'])->disableOriginalConstructor()->getMock();
     $config->expects($this->any())->method('getTitle')->willReturn($title);
     $this->resultPage->expects($this->any())->method('getConfig')->willReturn($config);
     $this->assertSame($this->resultPage, $this->object->execute());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:EditTest.php


示例15: execute

 /**
  * @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;
 }
开发者ID:pleminh,项目名称:Gemtoo,代码行数:21,代码来源:MassAction.php


示例16: execute

 /**
  * 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]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:25,代码来源:MassStatus.php


示例17: execute

 /**
  * 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('*/*/');
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:29,代码来源:MassDelete.php


示例18: getComponentRefererUrl

 /**
  * Return component referer url
  * TODO: Technical dept referer url should be implement as a part of Action configuration in in appropriate way
  *
  * @return null|string
  */
 protected function getComponentRefererUrl()
 {
     return $this->filter->getComponentRefererUrl() ?: 'sales/*/';
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:10,代码来源:AbstractMassAction.php



注:本文中的Magento\Ui\Component\MassAction\Filter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Helper\Data类代码示例发布时间:2022-05-23
下一篇:
PHP Columns\Column类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap