Пример #1
0
 /**
  * {@inheritdoc}
  */
 protected function _prepareLayout()
 {
     $this->setId('customerViewAccordion');
     $this->addItem('lastOrders', array('title' => __('Recent Orders'), 'ajax' => true, 'content_url' => $this->getUrl('customer/*/lastOrders', array('_current' => true))));
     $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
     $customer = $this->getCustomer($customerId);
     $websiteIds = $this->_shareConfig->getSharedWebsiteIds($customer->getWebsiteId());
     // add shopping cart block of each website
     foreach ($websiteIds as $websiteId) {
         $website = $this->_storeManager->getWebsite($websiteId);
         // count cart items
         $cartItemsCount = $this->_quoteFactory->create()->setWebsite($website)->loadByCustomer($customerId)->getItemsCollection(false)->addFieldToFilter('parent_item_id', array('null' => true))->getSize();
         // prepare title for cart
         $title = __('Shopping Cart - %1 item(s)', $cartItemsCount);
         if (count($websiteIds) > 1) {
             $title = __('Shopping Cart of %1 - %2 item(s)', $website->getName(), $cartItemsCount);
         }
         // add cart ajax accordion
         $this->addItem('shopingCart' . $websiteId, array('title' => $title, 'ajax' => true, 'content_url' => $this->getUrl('customer/*/viewCart', array('_current' => true, 'website_id' => $websiteId))));
     }
     // count wishlist items
     $wishlistCount = $this->_itemsFactory->create()->addCustomerIdFilter($customerId)->addStoreData()->getSize();
     // add wishlist ajax accordion
     $this->addItem('wishlist', array('title' => __('Wishlist - %1 item(s)', $wishlistCount), 'ajax' => true, 'content_url' => $this->getUrl('customer/*/viewWishlist', array('_current' => true))));
 }
Пример #2
0
 /**
  * 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', $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();
 }