本文整理汇总了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();
}
}
}