本文整理匯總了PHP中Magento\Quote\Model\Quote::setItemsCount方法的典型用法代碼示例。如果您正苦於以下問題:PHP Quote::setItemsCount方法的具體用法?PHP Quote::setItemsCount怎麽用?PHP Quote::setItemsCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Quote\Model\Quote
的用法示例。
在下文中一共展示了Quote::setItemsCount方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: initializeQuoteItems
private function initializeQuoteItems()
{
foreach ($this->proxyOrder->getItems() as $item) {
$this->clearQuoteItemsCache();
/** @var $quoteItemBuilder \Ess\M2ePro\Model\Magento\Quote\Item */
$quoteItemBuilder = $this->modelFactory->getObject('Magento\\Quote\\Item', ['quote' => $this->quote, 'proxyItem' => $item]);
$product = $quoteItemBuilder->getProduct();
$request = $quoteItemBuilder->getRequest();
// ---------------------------------------
$productOriginalPrice = (double) $product->getPrice();
$price = $item->getBasePrice();
$product->setPrice($price);
$product->setSpecialPrice($price);
// ---------------------------------------
// see Mage_Sales_Model_Observer::substractQtyFromQuotes
$this->quote->setItemsCount($this->quote->getItemsCount() + 1);
$this->quote->setItemsQty((double) $this->quote->getItemsQty() + $request->getQty());
$result = $this->quote->addProduct($product, $request);
if (is_string($result)) {
throw new \Ess\M2ePro\Model\Exception($result);
}
$quoteItem = $this->quote->getItemByProduct($product);
if ($quoteItem !== false) {
$quoteItem->setStoreId($this->quote->getStoreId());
$quoteItem->setOriginalCustomPrice($item->getPrice());
$quoteItem->setOriginalPrice($productOriginalPrice);
$quoteItem->setBaseOriginalPrice($productOriginalPrice);
$quoteItem->setNoDiscount(1);
$giftMessageId = $quoteItemBuilder->getGiftMessageId();
if (!empty($giftMessageId)) {
$quoteItem->setGiftMessageId($giftMessageId);
}
$quoteItem->setAdditionalData($quoteItemBuilder->getAdditionalData($quoteItem));
}
}
}
示例2: _collectItemsQtys
/**
* Collect items qty
*
* @param \Magento\Quote\Model\Quote $quote
* @return $this
*/
protected function _collectItemsQtys(\Magento\Quote\Model\Quote $quote)
{
$quote->setItemsCount(0);
$quote->setItemsQty(0);
$quote->setVirtualItemsQty(0);
foreach ($quote->getAllVisibleItems() as $item) {
if ($item->getParentItem()) {
continue;
}
$children = $item->getChildren();
if ($children && $item->isShipSeparately()) {
foreach ($children as $child) {
if ($child->getProduct()->getIsVirtual()) {
$quote->setVirtualItemsQty($quote->getVirtualItemsQty() + $child->getQty() * $item->getQty());
}
}
}
if ($item->getProduct()->getIsVirtual()) {
$quote->setVirtualItemsQty($quote->getVirtualItemsQty() + $item->getQty());
}
$quote->setItemsCount($quote->getItemsCount() + 1);
$quote->setItemsQty((double) $quote->getItemsQty() + $item->getQty());
}
return $this;
}