本文整理汇总了PHP中Magento\Quote\Model\Quote::getAllItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Quote::getAllItems方法的具体用法?PHP Quote::getAllItems怎么用?PHP Quote::getAllItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Quote\Model\Quote
的用法示例。
在下文中一共展示了Quote::getAllItems方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAllItems
/**
* {@inheritdoc}
*/
public function getAllItems()
{
$resultItems = [];
foreach ($this->_salesModel->getAllItems() as $item) {
$resultItems[] = new \Magento\Framework\DataObject(['parent_item' => $item->getParentItem(), 'name' => $item->getName(), 'qty' => (int) $item->getTotalQty(), 'price' => (double) $item->getBaseCalculationPrice(), 'original_item' => $item]);
}
return $resultItems;
}
示例2: _getQuoteItemIdByProductId
/**
* Gets \Magento\Quote\Model\Quote\Item from \Magento\Quote\Model\Quote by product id
*
* @param \Magento\Quote\Model\Quote $quote
* @param mixed $productId
* @return \Magento\Quote\Model\Quote\Item|null
*/
private function _getQuoteItemIdByProductId(\Magento\Quote\Model\Quote $quote, $productId)
{
/** @var $quoteItems \Magento\Quote\Model\Quote\Item[] */
$quoteItems = $quote->getAllItems();
foreach ($quoteItems as $quoteItem) {
if ($productId == $quoteItem->getProductId()) {
return $quoteItem;
}
}
return null;
}
示例3: testGetAllItems
public function testGetAllItems()
{
$itemOneMock = $this->getMockBuilder('Magento\\Quote\\Model\\Resource\\Quote\\Item')->setMethods(['isDeleted'])->disableOriginalConstructor()->getMock();
$itemOneMock->expects($this->once())->method('isDeleted')->willReturn(false);
$itemTwoMock = $this->getMockBuilder('Magento\\Quote\\Model\\Resource\\Quote\\Item')->setMethods(['isDeleted'])->disableOriginalConstructor()->getMock();
$itemTwoMock->expects($this->once())->method('isDeleted')->willReturn(true);
$items = [$itemOneMock, $itemTwoMock];
$itemResult = [$itemOneMock];
$this->quote->setData('items_collection', $items);
$this->assertEquals($itemResult, $this->quote->getAllItems());
}
示例4: resolveItems
/**
* @param Quote $quote
* @return array
*/
protected function resolveItems(QuoteEntity $quote)
{
$quoteItems = [];
foreach ($quote->getAllItems() as $quoteItem) {
/** @var \Magento\Quote\Model\Resource\Quote\Item $quoteItem */
$quoteItems[$quoteItem->getId()] = $quoteItem;
}
$orderItems = [];
foreach ($quoteItems as $quoteItem) {
$parentItem = isset($orderItems[$quoteItem->getParentItemId()]) ? $orderItems[$quoteItem->getParentItemId()] : null;
$orderItems[$quoteItem->getId()] = $this->quoteItemToOrderItem->convert($quoteItem, ['parent_item' => $parentItem]);
}
return array_values($orderItems);
}
示例5: getQuoteItemTotalsData
/**
* Fetch quote item totals data from quote
*
* @param \Magento\Quote\Model\Quote $quote
* @return array
*/
protected function getQuoteItemTotalsData(\Magento\Quote\Model\Quote $quote)
{
$items = $quote->getAllItems();
$item = array_shift($items);
return [ItemTotals::KEY_ITEM_ID => $item->getItemId(), ItemTotals::KEY_PRICE => intval($item->getPrice()), ItemTotals::KEY_BASE_PRICE => intval($item->getBasePrice()), ItemTotals::KEY_QTY => $item->getQty(), ItemTotals::KEY_ROW_TOTAL => intval($item->getRowTotal()), ItemTotals::KEY_BASE_ROW_TOTAL => intval($item->getBaseRowTotal()), ItemTotals::KEY_ROW_TOTAL_WITH_DISCOUNT => intval($item->getRowTotalWithDiscount()), ItemTotals::KEY_TAX_AMOUNT => intval($item->getTaxAmount()), ItemTotals::KEY_BASE_TAX_AMOUNT => intval($item->getBaseTaxAmount()), ItemTotals::KEY_TAX_PERCENT => intval($item->getTaxPercent()), ItemTotals::KEY_DISCOUNT_AMOUNT => intval($item->getDiscountAmount()), ItemTotals::KEY_BASE_DISCOUNT_AMOUNT => intval($item->getBaseDiscountAmount()), ItemTotals::KEY_DISCOUNT_PERCENT => intval($item->getDiscountPercent()), ItemTotals::KEY_PRICE_INCL_TAX => intval($item->getPriceInclTax()), ItemTotals::KEY_BASE_PRICE_INCL_TAX => intval($item->getBasePriceInclTax()), ItemTotals::KEY_ROW_TOTAL_INCL_TAX => intval($item->getRowTotalInclTax()), ItemTotals::KEY_BASE_ROW_TOTAL_INCL_TAX => intval($item->getBaseRowTotalInclTax()), ItemTotals::KEY_WEEE_TAX_APPLIED_AMOUNT => $item->getWeeeTaxAppliedAmount(), ItemTotals::KEY_WEEE_TAX_APPLIED => $item->getWeeeTaxApplied(), ItemTotals::KEY_NAME => $item->getName()];
}
示例6: resolveItems
/**
* @param Quote $quote
* @return array
*/
protected function resolveItems(QuoteEntity $quote)
{
$quoteItems = $quote->getAllItems();
for ($i = 0; $i < count($quoteItems) - 1; $i++) {
for ($j = 0; $j < count($quoteItems) - $i - 1; $j++) {
if ($quoteItems[$i]->getParentItemId() == $quoteItems[$j]->getId()) {
$tempItem = $quoteItems[$i];
$quoteItems[$i] = $quoteItems[$j];
$quoteItems[$j] = $tempItem;
}
}
}
$orderItems = [];
foreach ($quoteItems as $quoteItem) {
$parentItem = isset($orderItems[$quoteItem->getParentItemId()]) ? $orderItems[$quoteItem->getParentItemId()] : null;
$orderItems[$quoteItem->getId()] = $this->quoteItemToOrderItem->convert($quoteItem, ['parent_item' => $parentItem]);
}
return array_values($orderItems);
}
示例7: resolveItems
/**
* @param Quote $quote
* @return array
*/
protected function resolveItems(QuoteEntity $quote)
{
$quoteItems = $quote->getAllItems();
$orderItems = [];
foreach ($quoteItems as $quoteItem) {
$parentItem = isset($orderItems[$quoteItem->getParentItemId()]) ? $orderItems[$quoteItem->getParentItemId()] : null;
$orderItems[$quoteItem->getId()] = $this->quoteItemToOrderItem->convert($quoteItem, ['parent_item' => $parentItem]);
}
return array_values($orderItems);
}