本文整理汇总了PHP中Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection::getAllIds方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractCollection::getAllIds方法的具体用法?PHP AbstractCollection::getAllIds怎么用?PHP AbstractCollection::getAllIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
的用法示例。
在下文中一共展示了AbstractCollection::getAllIds方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例2: 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 = [];
$shipments = $this->shipmentCollectionFactory->create()->setOrderFilter(['in' => $collection->getAllIds()]);
if ($shipments->getSize()) {
/** @var \Magento\Sales\Model\Order\Shipment $shipment */
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');
}
$this->messageManager->addError(__('There are no shipping labels related to selected orders.'));
return $this->resultRedirectFactory->create()->setPath('sales/order/');
}
示例3: 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();
}
}
示例4: testGetAllIdsWithBind
public function testGetAllIdsWithBind()
{
$this->_model->getSelect()->where('code = :code');
$this->_model->addBindParam('code', 'admin');
$this->assertEquals(['0'], $this->_model->getAllIds());
}
示例5: getAllIds
/**
* Retrieve all ids for collection
*
* @return array
*/
public function getAllIds()
{
if ($this->_itemIds === null) {
$this->_itemIds = parent::getAllIds();
}
return $this->_itemIds;
}
示例6: 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;
}
示例7: massAction
/**
* Print all documents for selected orders
*
* @param AbstractCollection $collection
* @return ResponseInterface|\Magento\Backend\Model\View\Result\Redirect
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function massAction(AbstractCollection $collection)
{
$orderIds = $collection->getAllIds();
$shipments = $this->shipmentCollectionFactory->create()->setOrderFilter(['in' => $orderIds]);
$invoices = $this->invoiceCollectionFactory->create()->setOrderFilter(['in' => $orderIds]);
$creditmemos = $this->creditmemoCollectionFactory->create()->setOrderFilter(['in' => $orderIds]);
$documents = [];
if ($invoices->getSize()) {
$documents[] = $this->pdfInvoice->getPdf($invoices);
}
if ($shipments->getSize()) {
$documents[] = $this->pdfShipment->getPdf($shipments);
}
if ($creditmemos->getSize()) {
$documents[] = $this->pdfCreditmemo->getPdf($creditmemos);
}
if (empty($documents)) {
$this->messageManager->addError(__('There are no printable documents related to selected orders.'));
return $this->resultRedirectFactory->create()->setPath($this->getComponentRefererUrl());
}
$pdf = array_shift($documents);
foreach ($documents as $document) {
$pdf->pages = array_merge($pdf->pages, $document->pages);
}
return $this->fileFactory->create(sprintf('docs%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')), $pdf->render(), DirectoryList::VAR_DIR, 'application/pdf');
}