当前位置: 首页>>代码示例>>PHP>>正文


PHP Collection\AbstractCollection类代码示例

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


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

示例1: massAction

 /**
  * Unhold selected orders
  *
  * @param AbstractCollection $collection
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 protected function massAction(AbstractCollection $collection)
 {
     $countUnHoldOrder = 0;
     /** @var \Magento\Sales\Model\Order $order */
     foreach ($collection->getItems() as $order) {
         $order->load($order->getId());
         if (!$order->canUnhold()) {
             continue;
         }
         $order->unhold();
         $order->save();
         $countUnHoldOrder++;
     }
     $countNonUnHoldOrder = $collection->count() - $countUnHoldOrder;
     if ($countNonUnHoldOrder && $countUnHoldOrder) {
         $this->messageManager->addError(__('%1 order(s) were not released from on hold status.', $countNonUnHoldOrder));
     } elseif ($countNonUnHoldOrder) {
         $this->messageManager->addError(__('No order(s) were released from on hold status.'));
     }
     if ($countUnHoldOrder) {
         $this->messageManager->addSuccess(__('%1 order(s) have been released from on hold status.', $countUnHoldOrder));
     }
     $resultRedirect = $this->resultRedirectFactory->create();
     $resultRedirect->setPath($this->getComponentRefererUrl());
     return $resultRedirect;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:32,代码来源:MassUnhold.php

示例2: addIsUsedFilterCallback

 /**
  * Callback function that filters collection by field "Used" from grid
  *
  * @param AbstractCollection $collection
  * @param Column $column
  * @return void
  */
 public function addIsUsedFilterCallback($collection, $column)
 {
     $filterValue = $column->getFilter()->getCondition();
     $expression = $this->getConnection()->getCheckSql('main_table.times_used > 0', 1, 0);
     $conditionSql = $this->_getConditionSql($expression, $filterValue);
     $collection->getSelect()->where($conditionSql);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:Collection.php

示例3: massAction

 /**
  * Print shipments for selected orders
  *
  * @param AbstractCollection $collection
  * @return ResponseInterface|\Magento\Backend\Model\View\Result\Redirect
  */
 protected function massAction(AbstractCollection $collection)
 {
     $shipmentsCollection = $this->shipmentCollectionFactotory->create()->setOrderFilter(['in' => $collection->getAllIds()]);
     if (!$shipmentsCollection->getSize()) {
         $this->messageManager->addError(__('There are no printable documents related to selected orders.'));
         return $this->resultRedirectFactory->create()->setPath($this->getComponentRefererUrl());
     }
     return $this->fileFactory->create(sprintf('packingslip%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')), $this->pdfShipment->getPdf($shipmentsCollection->getItems())->render(), DirectoryList::VAR_DIR, 'application/pdf');
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:Pdfshipments.php

示例4: _processAction

 /**
  * Delete all records in collection. Return count of successful operations.
  *
  * @param AbstractCollection $collection
  *
  * @return int
  */
 protected function _processAction(AbstractCollection $collection)
 {
     $count = 0;
     /** @var \ISM\Blog\Model\Post $model */
     foreach ($collection->getItems() as $model) {
         $model->delete();
         ++$count;
     }
     return $count;
 }
开发者ID:swnsma,项目名称:practice,代码行数:17,代码来源:MassDelete.php

示例5: _processAction

 protected function _processAction(AbstractCollection $collection)
 {
     $count = 0;
     foreach ($collection->getItems() as $model) {
         /** @var \ISM\Blog\Model\Post $model */
         $model->setIsActive(false);
         $model->save();
         ++$count;
     }
     return $count;
 }
开发者ID:swnsma,项目名称:practice,代码行数:11,代码来源:MassDisable.php

示例6: massAction

 /**
  * Batch print shipping labels for whole shipments.
  * Push pdf document with shipping labels to user browser
  *
  * @param AbstractCollection $collection
  * @return ResponseInterface|ResultInterface
  */
 protected function massAction(AbstractCollection $collection)
 {
     $labelsContent = [];
     if ($collection->getSize()) {
         /** @var \Magento\Sales\Model\Order\Shipment $shipment */
         foreach ($collection as $shipment) {
             $labelContent = $shipment->getShippingLabel();
             if ($labelContent) {
                 $labelsContent[] = $labelContent;
             }
         }
     }
     if (!empty($labelsContent)) {
         $outputPdf = $this->labelGenerator->combineLabelsPdf($labelsContent);
         return $this->fileFactory->create('ShippingLabels.pdf', $outputPdf->render(), DirectoryList::VAR_DIR, 'application/pdf');
     }
     $this->messageManager->addError(__('There are no shipping labels related to selected shipments.'));
     return $this->resultRedirectFactory->create()->setPath('sales/shipment/');
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:26,代码来源:MassPrintShippingLabel.php

示例7: massAction

 public function massAction(AbstractCollection $collection)
 {
     foreach ($collection->getItems() as $order) {
         try {
             // Check if case already exists for this order
             if ($this->_helper->doesCaseExist($order)) {
                 continue;
             }
             $orderData = $this->_helper->processOrderData($order);
             // Add order to database
             $this->_helper->createNewCase($order);
             // Post case to signifyd service
             $this->_helper->postCaseToSignifyd($orderData, $order);
         } catch (\Exception $ex) {
             $this->_logger->error($ex->getMessage());
         }
     }
     $this->messageManager->addSuccessMessage(__('Success.'));
     $resultRedirect = $this->resultRedirectFactory->create();
     $resultRedirect->setPath($this->getComponentRefererUrl());
     return $resultRedirect;
 }
开发者ID:signifyd,项目名称:magento2,代码行数:22,代码来源:Send.php

示例8: addFieldToFilter

 /**
  * @inheritdoc
  */
 public function addFieldToFilter($field, $condition = null)
 {
     if (in_array($field, ['created_at', 'updated_at'], true)) {
         $field = 'main_table.' . $field;
     }
     return parent::addFieldToFilter($field, $condition);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:Collection.php

示例9: _afterLoad

 /**
  * {@inheritdoc}
  */
 protected function _afterLoad()
 {
     foreach ($this->_items as $item) {
         $item->setIndex($this->index);
     }
     return parent::_afterLoad();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:10,代码来源:Collection.php

示例10: __construct

 /**
  * @param EntityFactory $entityFactory
  * @param Logger $logger
  * @param FetchStrategy $fetchStrategy
  * @param EventManager $eventManager
  * @param string $mainTable
  * @param string $resourceModel
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function __construct(EntityFactory $entityFactory, Logger $logger, FetchStrategy $fetchStrategy, EventManager $eventManager, $mainTable, $resourceModel)
 {
     $this->_init('Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\Document', $resourceModel);
     $this->setMainTable(true);
     $this->setMainTable($this->_resource->getTable($mainTable));
     parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, null, null);
     $this->_setIdFieldName($this->getResource()->getIdFieldName());
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:17,代码来源:SearchResult.php

示例11: _beforeLoad

 /**
  * Load collection data
  *
  * @return $this
  */
 public function _beforeLoad()
 {
     if (!$this->getLoadDefault()) {
         $this->setWithoutDefaultFilter();
     }
     $this->addOrder('main_table.name', self::SORT_ORDER_ASC);
     return parent::_beforeLoad();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:13,代码来源:Collection.php

示例12: __construct

 /**
  * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
  * @param \Psr\Log\LoggerInterface $logger
  * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
  * @param \Magento\Framework\Event\ManagerInterface $eventManager
  * @param null|\Zend_Db_Adapter_Abstract $mainTable
  * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $eventPrefix
  * @param string $eventObject
  * @param string $resourceModel
  * @param string $model
  * @param string|null $connection
  * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, $mainTable, $eventPrefix, $eventObject, $resourceModel, $model = 'Magento\\Sales\\Model\\ResourceModel\\Grid\\Document', $connection = null, \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null)
 {
     $this->_eventPrefix = $eventPrefix;
     $this->_eventObject = $eventObject;
     $this->_init($model, $resourceModel);
     $this->setMainTable($mainTable);
     parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:23,代码来源:Collection.php

示例13: _afterLoadData

 /**
  * Process loaded collection data
  *
  * @return $this
  */
 protected function _afterLoadData()
 {
     parent::_afterLoadData();
     $this->addCustomerTaxClassesToResult();
     $this->addProductTaxClassesToResult();
     $this->addRatesToResult();
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:Collection.php

示例14: _initSelect

 /**
  * Initialize select object
  *
  * @return $this
  */
 protected function _initSelect()
 {
     parent::_initSelect();
     $locale = $this->_localeResolver->getLocale();
     $this->addBindParam(':region_locale', $locale);
     $this->getSelect()->joinLeft(['rname' => $this->_regionNameTable], 'main_table.region_id = rname.region_id AND rname.locale = :region_locale', ['name']);
     return $this;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:Collection.php

示例15: _initSelect

 public function _initSelect()
 {
     parent::_initSelect();
     $this->_select->joinLeft(['country_table' => $this->_countryTable], 'country_table.country_id = main_table.dest_country_id', ['dest_country' => 'iso3_code'])->joinLeft(['region_table' => $this->_regionTable], 'region_table.region_id = main_table.dest_region_id', ['dest_region' => 'code']);
     $this->addOrder('dest_country', self::SORT_ORDER_ASC);
     $this->addOrder('dest_region', self::SORT_ORDER_ASC);
     $this->addOrder('dest_zip', self::SORT_ORDER_ASC);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:8,代码来源:Collection.php


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