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


PHP AbstractCollection::getAllIds方法代码示例

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


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

示例1: 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

示例2: delete

 /**
  * Delete collection items
  *
  * @param AbstractCollection $collection
  * @return int
  */
 protected function delete(AbstractCollection $collection)
 {
     $count = 0;
     foreach ($collection->getAllIds() as $id) {
         /** @var \Magento\Framework\Model\AbstractModel $model */
         $model = $this->_objectManager->get($this->model);
         $model->load($id);
         $model->delete();
         ++$count;
     }
     return $count;
 }
开发者ID:refaelgold,项目名称:magento2_blog,代码行数:18,代码来源:AbstractMassDelete.php

示例3: testGetAllIdsWithBind

 public function testGetAllIdsWithBind()
 {
     $this->_model->getSelect()->where('code = :code');
     $this->_model->addBindParam('code', 'admin');
     $this->assertEquals(['0'], $this->_model->getAllIds());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:6,代码来源:AbstractTest.php

示例4: setStatus

 /**
  * Set status to collection items
  *
  * @param AbstractCollection $collection
  * @return void
  */
 protected function setStatus(AbstractCollection $collection)
 {
     foreach ($collection->getAllIds() as $id) {
         /** @var \Magento\Framework\Model\AbstractModel $model */
         $model = $this->_objectManager->get($this->model);
         $model->load($id);
         $model->setIsActive($this->status);
         $model->save();
     }
 }
开发者ID:refaelgold,项目名称:magento2_blog,代码行数:16,代码来源:AbstractMassStatus.php

示例5: getAllIds

 /**
  * Retrieve all ids for collection
  *
  * @return array
  */
 public function getAllIds()
 {
     if ($this->_itemIds === null) {
         $this->_itemIds = parent::getAllIds();
     }
     return $this->_itemIds;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:Collection.php

示例6: getAllIds

 /**
  * Retrieve all ids for collection
  *
  * @return array
  */
 public function getAllIds()
 {
     if (is_null($this->_itemIds)) {
         $this->_itemIds = parent::getAllIds();
     }
     return $this->_itemIds;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:Collection.php


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