本文整理匯總了PHP中Magento\Sales\Model\Order::getCollection方法的典型用法代碼示例。如果您正苦於以下問題:PHP Order::getCollection方法的具體用法?PHP Order::getCollection怎麽用?PHP Order::getCollection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Sales\Model\Order
的用法示例。
在下文中一共展示了Order::getCollection方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onOrderSuccessPageView
/**
* @param $event
* @throws \Exception
*/
private function onOrderSuccessPageView($event)
{
try {
$orders = $this->order->getCollection()->setOrder('entity_id', 'DESC')->setPageSize(1)->setCurPage(1);
$order = $orders->getFirstItem();
$orderData = $order->getData();
$transactionId = $orderData['entity_id'];
$products = array();
foreach ($order->getAllItems() as $item) {
if ($item->getPrice() > 0) {
$products[] = array('product' => $item->getProduct()->getId(), 'quantity' => $item->getData('qty_ordered'), 'price' => $item->getPrice());
}
}
$fullPrice = $orderData['grand_total'];
$currency = $orderData['base_currency_code'];
$script = $this->bxHelperData->reportPurchase($products, $transactionId, $fullPrice, $currency);
$this->addScript($script);
} catch (\Exception $e) {
$this->_logger->critical($e);
}
}
示例2: updateOrderEditIncrements
/**
* Update all child and parent order's edit increment numbers.
* Needed for Admin area.
*
* @param \Magento\Sales\Model\Order $order
* @return void
*/
public function updateOrderEditIncrements(\Magento\Sales\Model\Order $order)
{
if ($order->getId() && $order->getOriginalIncrementId()) {
$collection = $order->getCollection();
$quotedIncrId = $collection->getConnection()->quote($order->getOriginalIncrementId());
$collection->getSelect()->where("original_increment_id = {$quotedIncrId} OR increment_id = {$quotedIncrId}");
foreach ($collection as $orderToUpdate) {
$orderToUpdate->setEditIncrement($order->getEditIncrement());
$orderToUpdate->save();
}
}
}