jsLayout = array_merge_recursive($jsLayoutDataProvider->getData(), $data['jsLayout']); unset($data['jsLayout']); } else { $this->jsLayout = $jsLayoutDataProvider->getData(); } parent::__construct($context, $customerSession, $checkoutSession, $data); $this->_isScopePrivate = false; $this->imageHelper = $imageHelper; $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance() ->get(\Magento\Framework\Serialize\Serializer\Json::class); } /** * Returns minicart config * * @return array */ public function getConfig() { return [ 'shoppingCartUrl' => $this->getShoppingCartUrl(), 'checkoutUrl' => $this->getCheckoutUrl(), 'updateItemQtyUrl' => $this->getUpdateItemQtyUrl(), 'removeItemUrl' => $this->getRemoveItemUrl(), 'imageTemplate' => $this->getImageHtmlTemplate(), 'baseUrl' => $this->getBaseUrl(), 'minicartMaxItemsVisible' => $this->getMiniCartMaxItemsCount(), 'websiteId' => $this->_storeManager->getStore()->getWebsiteId(), 'maxItemsToDisplay' => $this->getMaxItemsToDisplay(), 'storeId' => $this->_storeManager->getStore()->getId() ]; } /** * Get serialized config * * @return string * @since 100.2.0 */ public function getSerializedConfig() { return $this->serializer->serialize($this->getConfig()); } /** * Get image html template * * @return string */ public function getImageHtmlTemplate() { return 'Magento_Catalog/product/image_with_borders'; } /** * Get one page checkout page url * * @codeCoverageIgnore * @return string */ public function getCheckoutUrl() { return $this->getUrl('checkout'); } /** * Get shopping cart page url * * @return string * @codeCoverageIgnore */ public function getShoppingCartUrl() { return $this->getUrl('checkout/cart'); } /** * Get update cart item url * * @return string * @codeCoverageIgnore * @SuppressWarnings(PHPMD.RequestAwareBlockMethod) */ public function getUpdateItemQtyUrl() { return $this->getUrl('checkout/sidebar/updateItemQty', ['_secure' => $this->getRequest()->isSecure()]); } /** * Get remove cart item url * * @return string * @codeCoverageIgnore * @SuppressWarnings(PHPMD.RequestAwareBlockMethod) */ public function getRemoveItemUrl() { return $this->getUrl('checkout/sidebar/removeItem', ['_secure' => $this->getRequest()->isSecure()]); } /** * Define if Mini Shopping Cart Pop-Up Menu enabled * * @return bool * @codeCoverageIgnore * @SuppressWarnings(PHPMD.BooleanGetMethodName) */ public function getIsNeedToDisplaySideBar() { return (bool)$this->_scopeConfig->getValue( self::XML_PATH_CHECKOUT_SIDEBAR_DISPLAY, ScopeInterface::SCOPE_STORE ); } /** * Return totals from custom quote if needed * * @return array */ public function getTotalsCache() { if (empty($this->_totals)) { $quote = $this->getCustomQuote() ? $this->getCustomQuote() : $this->getQuote(); $this->_totals = $quote->getTotals(); } return $this->_totals; } /** * Retrieve subtotal block html * * @codeCoverageIgnore * @return string */ public function getTotalsHtml() { return $this->getLayout()->getBlock('checkout.cart.minicart.totals')->toHtml(); } /** * Return base url. * * @codeCoverageIgnore * @return string */ public function getBaseUrl() { return $this->_storeManager->getStore()->getBaseUrl(); } /** * Return max visible item count for minicart * * @return int */ private function getMiniCartMaxItemsCount() { return (int)$this->_scopeConfig->getValue('checkout/sidebar/count', ScopeInterface::SCOPE_STORE); } /** * Returns maximum cart items to display * * This setting regulates how many items will be displayed in minicart * * @return int */ private function getMaxItemsToDisplay() { return (int)$this->_scopeConfig->getValue( 'checkout/sidebar/max_items_display_count', ScopeInterface::SCOPE_STORE ); } }