Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
|
Public Member Functions | |
__construct (\Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Checkout\Model\ResourceModel\Cart $resourceCart, Session $checkoutSession, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Message\ManagerInterface $messageManager, \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, \Magento\CatalogInventory\Api\StockStateInterface $stockState, \Magento\Quote\Api\CartRepositoryInterface $quoteRepository, ProductRepositoryInterface $productRepository, array $data=[]) | |
getCheckoutSession () | |
getCustomerSession () | |
getItems () | |
getQuoteProductIds () | |
getQuote () | |
setQuote (\Magento\Quote\Model\Quote $quote) | |
addOrderItem ($orderItem, $qtyFlag=null) | |
addProduct ($productInfo, $requestInfo=null) | |
addProductsByIds ($productIds) | |
suggestItemsQty ($data) | |
updateItems ($data) | |
removeItem ($itemId) | |
save () | |
saveQuote () | |
truncate () | |
getProductIds () | |
getSummaryQty () | |
getItemsCount () | |
getItemsQty () | |
updateItem ($itemId, $requestInfo=null, $updatingParams=null) | |
![]() | |
__construct (array $data=[]) | |
addData (array $arr) | |
setData ($key, $value=null) | |
unsetData ($key=null) | |
getData ($key='', $index=null) | |
getDataByPath ($path) | |
getDataByKey ($key) | |
setDataUsingMethod ($key, $args=[]) | |
getDataUsingMethod ($key, $args=null) | |
hasData ($key='') | |
toArray (array $keys=[]) | |
convertToArray (array $keys=[]) | |
toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true) | |
convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true) | |
toJson (array $keys=[]) | |
convertToJson (array $keys=[]) | |
toString ($format='') | |
__call ($method, $args) | |
isEmpty () | |
serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"') | |
debug ($data=null, &$objects=[]) | |
offsetSet ($offset, $value) | |
offsetExists ($offset) | |
offsetUnset ($offset) | |
offsetGet ($offset) | |
![]() | |
setQuote (Quote $quote) | |
Protected Member Functions | |
_getResource () | |
reinitializeState () | |
_getProduct ($productInfo) | |
_getProductRequest ($requestInfo) | |
![]() | |
_getData ($key) | |
_underscore ($name) | |
Protected Attributes | |
$_summaryQty | |
$_productIds | |
$_eventManager | |
$_scopeConfig | |
$_storeManager | |
$_resourceCart | |
$_checkoutSession | |
$_customerSession | |
$messageManager | |
$stockRegistry | |
$stockState | |
$quoteRepository | |
$productRepository | |
![]() | |
$_data = [] | |
Additional Inherited Members | |
![]() | |
static | $_underscoreCache = [] |
Shopping cart model
@api @SuppressWarnings(PHPMD.CouplingBetweenObjects)
__construct | ( | \Magento\Framework\Event\ManagerInterface | $eventManager, |
\Magento\Framework\App\Config\ScopeConfigInterface | $scopeConfig, | ||
\Magento\Store\Model\StoreManagerInterface | $storeManager, | ||
\Magento\Checkout\Model\ResourceModel\Cart | $resourceCart, | ||
Session | $checkoutSession, | ||
\Magento\Customer\Model\Session | $customerSession, | ||
\Magento\Framework\Message\ManagerInterface | $messageManager, | ||
\Magento\CatalogInventory\Api\StockRegistryInterface | $stockRegistry, | ||
\Magento\CatalogInventory\Api\StockStateInterface | $stockState, | ||
\Magento\Quote\Api\CartRepositoryInterface | $quoteRepository, | ||
ProductRepositoryInterface | $productRepository, | ||
array | $data = [] |
||
) |
\Magento\Framework\Event\ManagerInterface | $eventManager | |
\Magento\Framework\App\Config\ScopeConfigInterface | $scopeConfig | |
\Magento\Store\Model\StoreManagerInterface | $storeManager | |
\Magento\Checkout\Model\ResourceModel\Cart | $resourceCart | |
Session | $checkoutSession | |
\Magento\Customer\Model\Session | $customerSession | |
\Magento\Framework\Message\ManagerInterface | $messageManager | |
\Magento\CatalogInventory\Api\StockRegistryInterface | $stockRegistry | |
\Magento\CatalogInventory\Api\StockStateInterface | $stockState | |
\Magento\Quote\Api\CartRepositoryInterface | $quoteRepository | |
ProductRepositoryInterface | $productRepository | |
array | $data | @codeCoverageIgnore @SuppressWarnings(PHPMD.ExcessiveParameterList) |
Definition at line 120 of file Cart.php.
|
protected |
|
protected |
Get request for product add to cart procedure
\Magento\Framework\DataObject | int | array | $requestInfo |
Definition at line 339 of file Cart.php.
|
protected |
addOrderItem | ( | $orderItem, | |
$qtyFlag = null |
|||
) |
Convert order item to quote item
\Magento\Sales\Model\Order\Item | $orderItem | |
true | null | $qtyFlag | if is null set product qty like in order |
We need to reload product in this place, because products with the same id may have different sets of order attributes.
Definition at line 264 of file Cart.php.
addProduct | ( | $productInfo, | |
$requestInfo = null |
|||
) |
Add product to shopping cart (quote)
int | Product | $productInfo | |
\Magento\Framework\DataObject | int | array | $requestInfo |
String we can get if prepare process has error
Implements CartInterface.
Definition at line 366 of file Cart.php.
addProductsByIds | ( | $productIds | ) |
getCheckoutSession | ( | ) |
getCustomerSession | ( | ) |
getItems | ( | ) |
getItemsCount | ( | ) |
getItemsQty | ( | ) |
getQuote | ( | ) |
Get quote object associated with cart. By default it is current customer session quote
Implements CartInterface.
Definition at line 217 of file Cart.php.
getQuoteProductIds | ( | ) |
getSummaryQty | ( | ) |
|
protected |
Reinitialize cart quote state
Definition at line 243 of file Cart.php.
removeItem | ( | $itemId | ) |
save | ( | ) |
saveQuote | ( | ) |
setQuote | ( | \Magento\Quote\Model\Quote | $quote | ) |
suggestItemsQty | ( | $data | ) |
Returns suggested quantities for items. Can be used to automatically fix user entered quantities before updating cart so that cart contains valid qty values
The $data is an array of ($quoteItemId => (item info array with 'qty' key), ...)
array | $data |
Definition at line 468 of file Cart.php.
truncate | ( | ) |
updateItem | ( | $itemId, | |
$requestInfo = null , |
|||
$updatingParams = null |
|||
) |
Update item in shopping cart (quote) $requestInfo - either qty (int) or buyRequest in form of array or \Magento\Framework\DataObject $updatingParams - information on how to perform update, passed to Quote->updateItem() method
int | $itemId | |
int | array | \Magento\Framework\DataObject | $requestInfo | |
null | array | \Magento\Framework\DataObject | $updatingParams |
We can get string if updating process had some errors
Definition at line 698 of file Cart.php.
updateItems | ( | $data | ) |