_shareConfig = $shareConfig; $this->customerDataFactory = $customerDataFactory; $this->dataObjectHelper = $dataObjectHelper; parent::__construct($context, $data); } /** * Add shopping cart grid of each website * * @return $this */ protected function _prepareLayout() { $sharedWebsiteIds = $this->_shareConfig->getSharedWebsiteIds($this->_getCustomer()->getWebsiteId()); $isShared = count($sharedWebsiteIds) > 1; foreach ($sharedWebsiteIds as $websiteId) { $blockName = 'customer_cart_' . $websiteId; $block = $this->getLayout()->createBlock( \Magento\Customer\Block\Adminhtml\Edit\Tab\Cart::class, $blockName, ['data' => ['website_id' => $websiteId]] ); if ($isShared) { $websiteName = $this->_storeManager->getWebsite($websiteId)->getName(); $block->setCartHeader(__('Shopping Cart from %1', $websiteName)); } $this->setChild($blockName, $block); } return parent::_prepareLayout(); } /** * Just get child blocks html * * @return string */ protected function _toHtml() { $this->_eventManager->dispatch('adminhtml_block_html_before', ['block' => $this]); return $this->getChildHtml(); } /** * @return \Magento\Customer\Api\Data\CustomerInterface */ protected function _getCustomer() { $customerDataObject = $this->customerDataFactory->create(); $this->dataObjectHelper->populateWithArray( $customerDataObject, $this->_backendSession->getCustomerData()['account'], \Magento\Customer\Api\Data\CustomerInterface::class ); return $customerDataObject; } }