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


PHP Collection\AbstractCollection类代码示例

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


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

示例1: 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:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:Collection.php

示例2: massAction

 /**
  * Print credit memos for selected orders
  *
  * @param AbstractCollection $collection
  * @return ResponseInterface|\Magento\Backend\Model\View\Result\Redirect
  */
 protected function massAction(AbstractCollection $collection)
 {
     $resultRedirect = $this->resultRedirectFactory->create();
     $flag = false;
     /** @var \Magento\Sales\Model\Order $order */
     foreach ($collection->getItems() as $order) {
         $creditmemos = $order->getCreditmemosCollection();
         if ($creditmemos->getSize()) {
             $flag = true;
             if (!isset($pdf)) {
                 $pdf = $this->_objectManager->create('Magento\\Sales\\Model\\Order\\Pdf\\Creditmemo')->getPdf($creditmemos);
             } else {
                 $pages = $this->_objectManager->create('Magento\\Sales\\Model\\Order\\Pdf\\Creditmemo')->getPdf($creditmemos);
                 $pdf->pages = array_merge($pdf->pages, $pages->pages);
             }
         }
     }
     if ($flag) {
         $date = $this->_objectManager->get('Magento\\Framework\\Stdlib\\DateTime\\DateTime')->date('Y-m-d_H-i-s');
         return $this->_fileFactory->create('creditmemo' . $date . '.pdf', $pdf->render(), DirectoryList::VAR_DIR, 'application/pdf');
     } else {
         $this->messageManager->addError(__('There are no printable documents related to selected orders.'));
         $resultRedirect->setPath('sales/*/');
         return $resultRedirect;
     }
 }
开发者ID:nja78,项目名称:magento2,代码行数:32,代码来源:Pdfcreditmemos.php

示例3: massAction

 /**
  * Batch print shipping labels for whole shipments.
  * Push pdf document with shipping labels to user browser
  *
  * @param AbstractCollection $collection
  * @return ResponseInterface|void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function massAction(AbstractCollection $collection)
 {
     $request = $this->getRequest();
     $ids = $collection->getAllIds();
     $createdFromOrders = !empty($ids);
     $shipments = null;
     $labelsContent = [];
     switch ($request->getParam('massaction_prepare_key')) {
         case 'shipment_ids':
             $ids = $request->getParam('shipment_ids');
             array_filter($ids, 'intval');
             if (!empty($ids)) {
                 $shipments = $this->_objectManager->create('Magento\\Sales\\Model\\Resource\\Order\\Shipment\\Collection')->addFieldToFilter('entity_id', ['in' => $ids]);
             }
             break;
         case 'order_ids':
             $ids = $request->getParam('order_ids');
             array_filter($ids, 'intval');
             if (!empty($ids)) {
                 $shipments = $this->_objectManager->create('Magento\\Sales\\Model\\Resource\\Order\\Shipment\\Collection')->setOrderFilter(['in' => $ids]);
             }
             break;
     }
     if ($shipments && $shipments->getSize()) {
         foreach ($shipments 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');
     }
     if ($createdFromOrders) {
         $this->messageManager->addError(__('There are no shipping labels related to selected orders.'));
         $this->_redirect('sales/order/index');
     } else {
         $this->messageManager->addError(__('There are no shipping labels related to selected shipments.'));
         $this->_redirect('sales/shipment/index');
     }
 }
开发者ID:nja78,项目名称:magento2,代码行数:51,代码来源:MassPrintShippingLabel.php

示例4: massAction

 /**
  * Hold selected orders
  *
  * @param AbstractCollection $collection
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 protected function massAction(AbstractCollection $collection)
 {
     $countHoldOrder = 0;
     foreach ($collection->getItems() as $order) {
         if (!$order->canHold()) {
             continue;
         }
         $order->hold();
         $order->save();
         $countHoldOrder++;
     }
     $countNonHoldOrder = $collection->count() - $countHoldOrder;
     if ($countNonHoldOrder && $countHoldOrder) {
         $this->messageManager->addError(__('%1 order(s) were not put on hold.', $countNonHoldOrder));
     } elseif ($countNonHoldOrder) {
         $this->messageManager->addError(__('No order(s) were put on hold.'));
     }
     if ($countHoldOrder) {
         $this->messageManager->addSuccess(__('You have put %1 order(s) on hold.', $countHoldOrder));
     }
     $resultRedirect = $this->resultRedirectFactory->create();
     $resultRedirect->setPath('sales/*/');
     return $resultRedirect;
 }
开发者ID:nja78,项目名称:magento2,代码行数:30,代码来源:MassHold.php

示例5: massAction

 /**
  * Cancel selected orders
  *
  * @param AbstractCollection $collection
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 protected function massAction(AbstractCollection $collection)
 {
     $countCancelOrder = 0;
     foreach ($collection->getItems() as $order) {
         if (!$order->canCancel()) {
             continue;
         }
         $order->cancel();
         $order->save();
         $countCancelOrder++;
     }
     $countNonCancelOrder = $collection->count() - $countCancelOrder;
     if ($countNonCancelOrder && $countCancelOrder) {
         $this->messageManager->addError(__('%1 order(s) cannot be canceled.', $countNonCancelOrder));
     } elseif ($countNonCancelOrder) {
         $this->messageManager->addError(__('You cannot cancel the order(s).'));
     }
     if ($countCancelOrder) {
         $this->messageManager->addSuccess(__('We canceled %1 order(s).', $countCancelOrder));
     }
     $resultRedirect = $this->resultRedirectFactory->create();
     $resultRedirect->setPath('sales/*/');
     return $resultRedirect;
 }
开发者ID:nja78,项目名称:magento2,代码行数:30,代码来源:MassCancel.php

示例6: setCollection

 /**
  * Set collection to pager
  *
  * @param \Magento\Framework\Data\Collection $collection
  * @return $this
  */
 public function setCollection($collection)
 {
     $this->_collection = $collection;
     $this->_collection->setCurPage($this->getCurrentPage());
     // we need to set pagination only if passed value integer and more that 0
     $limit = (int) $this->getLimit();
     if ($limit) {
         $this->_collection->setPageSize($limit);
     }
     if ($this->getCurrentOrder()) {
         $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
     }
     return $this;
 }
开发者ID:samitrimal,项目名称:Blog-Extension-for-Magento-2,代码行数:20,代码来源:Toolbar.php

示例7: getSelectCountSql

 /**
  * get select count sql
  *
  * @return \Zend_Db_Select
  */
 public function getSelectCountSql()
 {
     if (!$this->_countSelect instanceof \Zend_Db_Select) {
         $this->setSelectCountSql(parent::getSelectCountSql());
     }
     return $this->_countSelect;
 }
开发者ID:opexsw,项目名称:magento2,代码行数:12,代码来源:AbstractCollection.php

示例8: _afterLoad

 /**
  * Unserialize additional_information in each item
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     foreach ($this->_items as $item) {
         $this->getResource()->unserializeFields($item);
     }
     return parent::_afterLoad();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:Collection.php

示例9: addItem

 /**
  * Don't add item to the collection if only fixed are allowed and its carrier is not fixed
  *
  * @param \Magento\Quote\Model\Quote\Address\Rate $rate
  * @return $this
  */
 public function addItem(\Magento\Framework\Object $rate)
 {
     $carrier = $this->_carrierFactory->get($rate->getCarrier());
     if ($this->_allowFixedOnly && (!$carrier || !$carrier->isFixed())) {
         return $this;
     }
     return parent::addItem($rate);
 }
开发者ID:opexsw,项目名称:magento2,代码行数:14,代码来源:Collection.php

示例10: _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:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:Collection.php

示例11: _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:kid17,项目名称:magento2,代码行数:13,代码来源:Collection.php

示例12: fetchItem

 /**
  * @inheritdoc
  */
 public function fetchItem()
 {
     $item = parent::fetchItem();
     if ($item) {
         $this->entitySnapshot->registerSnapshot($item);
     }
     return $item;
 }
开发者ID:vasiljok,项目名称:magento2,代码行数:11,代码来源:Collection.php

示例13: _afterLoadData

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

示例14: _initSelect

 /**
  * Initialize select, add country iso3 code and region name
  *
  * @return void
  */
 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);
     $this->addOrder('condition_value', self::SORT_ORDER_ASC);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:Collection.php

示例15: _initSelect

 /**
  * Initialize select
  *
  * @return $this
  */
 protected function _initSelect()
 {
     parent::_initSelect();
     $this->addFieldToSelect(['path', 'value'])->addFieldToFilter('scope', $this->_scope);
     if ($this->_scopeId !== null) {
         $this->addFieldToFilter('scope_id', $this->_scopeId);
     }
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:Scoped.php


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