18 class Cart extends \Magento\Backend\Block\Widget\Grid\Extended
63 \
Magento\Backend\Helper\Data $backendHelper,
65 \
Magento\Framework\Data\CollectionFactory $dataCollectionFactory,
66 \
Magento\Framework\Registry $coreRegistry,
70 $this->_dataCollectionFactory = $dataCollectionFactory;
71 $this->_coreRegistry = $coreRegistry;
74 parent::__construct($context, $backendHelper,
$data);
83 $this->setUseAjax(
true);
85 $this->
setTemplate(
'Magento_Customer::tab/cart.phtml');
95 $this->setId(
'customer_cart_grid' . $this->getWebsiteId());
96 parent::_prepareGrid();
111 $collection = $this->_dataCollectionFactory->create();
114 $collection->addFieldToFilter(
'parent_item_id', [
'null' =>
true]);
118 return parent::_prepareCollection();
126 $this->
addColumn(
'product_id', [
'header' =>
__(
'ID'),
'index' =>
'product_id',
'width' =>
'100px']);
131 'header' =>
__(
'Product'),
133 'renderer' => \
Magento\Customer\Block\Adminhtml\
Edit\Tab\
View\Grid\Renderer\Item::class
137 $this->
addColumn(
'sku', [
'header' =>
__(
'SKU'),
'index' =>
'sku',
'width' =>
'100px']);
141 [
'header' =>
__(
'Quantity'),
'index' =>
'qty',
'type' =>
'number',
'width' =>
'60px']
147 'header' =>
__(
'Price'),
149 'type' =>
'currency',
150 'currency_code' => $this->
getQuote()->getQuoteCurrencyCode(),
151 'rate' => $this->
getQuote()->getBaseToQuoteRate(),
158 'header' =>
__(
'Total'),
159 'index' =>
'row_total',
160 'type' =>
'currency',
161 'currency_code' => $this->
getQuote()->getQuoteCurrencyCode(),
169 'header' =>
__(
'Action'),
170 'index' =>
'quote_item_id',
171 'renderer' => \
Magento\Customer\Block\Adminhtml\Grid\Renderer\Multiaction::class,
176 'caption' =>
__(
'Configure'),
177 'url' =>
'javascript:void(0)',
178 'process' =>
'configurable',
182 'caption' =>
__(
'Delete'),
184 'onclick' =>
'return ' . $this->
getJsObjectName() .
'cartControl.removeItem($item_id);' 190 return parent::_prepareColumns();
208 return $this->
getUrl(
'customer/*/cart', [
'_current' =>
true,
'website_id' => $this->getWebsiteId()]);
218 $templateName = $this->resolver->getTemplateFileName($this->_parentTemplate, [
'_relative' =>
true]);
227 return $this->
getUrl(
'catalog/product/edit', [
'id' =>
$row->getProductId()]);
237 if (
null === $this->quote) {
239 $storeIds = $this->_storeManager->getWebsite($this->getWebsiteId())->getStoreIds();
242 $this->quote = $this->quoteRepository->getForCustomer(
$customerId, $storeIds);
244 $this->quote = $this->quoteFactory->create()->setSharedStoreIds($storeIds);
const CURRENT_CUSTOMER_ID
getUrl($route='', $params=[])
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\Backend\Helper\Data $backendHelper, \Magento\Quote\Api\CartRepositoryInterface $quoteRepository, \Magento\Framework\Data\CollectionFactory $dataCollectionFactory, \Magento\Framework\Registry $coreRegistry, \Magento\Quote\Model\QuoteFactory $quoteFactory, array $data=[])