예제 #1
0
 /**
  * Return back title for logged in and guest users
  *
  * @return \Magento\Framework\Phrase
  */
 public function getBackTitle()
 {
     if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {
         return __('Back to My Orders');
     }
     return __('View Another Order');
 }
예제 #2
0
파일: Link.php 프로젝트: aiesh/magento2
 /**
  * @return string
  */
 protected function _toHtml()
 {
     if ($this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH)) {
         return '';
     }
     return parent::_toHtml();
 }
예제 #3
0
 /**
  * @return string
  */
 protected function _toHtml()
 {
     if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {
         return '';
     }
     return parent::_toHtml();
 }
예제 #4
0
 /**
  * Get url for reorder action
  *
  * @param \Magento\Sales\Model\Order $order
  * @return string
  */
 public function getReorderUrl($order)
 {
     if (!$this->httpContext->getValue(Context::CONTEXT_AUTH)) {
         return $this->getUrl('sales/guest/reorder', ['order_id' => $order->getId()]);
     }
     return $this->getUrl('sales/order/reorder', ['order_id' => $order->getId()]);
 }
예제 #5
0
 /**
  * {@inheritdoc}
  */
 protected function _toHtml()
 {
     if (!$this->_customerHelper->isRegistrationAllowed() || $this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH)) {
         return '';
     }
     return parent::_toHtml();
 }
예제 #6
0
 /**
  * {@inheritdoc}
  */
 protected function _toHtml()
 {
     if (!$this->_registration->isAllowed() || $this->httpContext->getValue(Context::CONTEXT_AUTH)) {
         return '';
     }
     return parent::_toHtml();
 }
예제 #7
0
 /**
  * Get customer group id
  *
  * @return int
  */
 protected function getCustomerGroupId()
 {
     $customerGroupId = (int) $this->getRequest()->getParam('cid');
     if ($customerGroupId == null) {
         $customerGroupId = $this->httpContext->getValue(Context::CONTEXT_GROUP);
     }
     return $customerGroupId;
 }
예제 #8
0
 /**
  * Retrieve welcome text
  *
  * @return string
  */
 public function getWelcome()
 {
     if (empty($this->_data['welcome'])) {
         if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {
             $customerName = $this->_customerViewHelper->getCustomerName($this->_customerSession->getCustomerDataObject());
             $this->_data['welcome'] = __('Welcome, %1!', $this->escapeHtml($customerName));
         } else {
             $this->_data['welcome'] = $this->_scopeConfig->getValue('design/header/welcome', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
         }
     }
     return $this->_data['welcome'];
 }
예제 #9
0
파일: Buttons.php 프로젝트: aiesh/magento2
 /**
  * Get url for reorder action
  *
  * @param \Magento\Sales\Model\Order $order
  * @return string
  */
 public function getReorderUrl($order)
 {
     if (!$this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH)) {
         return $this->getUrl('sales/guest/reorder', array('order_id' => $order->getId()));
     }
     return $this->getUrl('sales/order/reorder', array('order_id' => $order->getId()));
 }
예제 #10
0
파일: Invoice.php 프로젝트: aiesh/magento2
 /**
  * Return back title for logged in and guest users
  *
  * @return string
  */
 public function getBackTitle()
 {
     if ($this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH)) {
         return __('Back to My Orders');
     }
     return __('View Another Order');
 }
예제 #11
0
파일: Inline.php 프로젝트: aiesh/magento2
 /**
  * Get default value for From field
  *
  * @return string
  */
 public function getDefaultFrom()
 {
     if ($this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH)) {
         return $this->_customerSession->getCustomer()->getName();
     } else {
         return $this->getEntity()->getBillingAddress()->getName();
     }
 }
예제 #12
0
파일: Cart.php 프로젝트: aiesh/magento2
 /**
  * @return bool
  */
 public function isWishlistActive()
 {
     $isActive = $this->_getData('is_wishlist_active');
     if ($isActive === null) {
         $isActive = $this->_scopeConfig->getValue('wishlist/general/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) && $this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH);
         $this->setIsWishlistActive($isActive);
     }
     return $isActive;
 }
예제 #13
0
 /**
  * Initialize review form
  *
  * @return void
  */
 protected function _construct()
 {
     parent::_construct();
     $this->setAllowWriteReviewFlag($this->httpContext->getValue(Context::CONTEXT_AUTH) || $this->_reviewData->getIsGuestAllowToWrite());
     if (!$this->getAllowWriteReviewFlag()) {
         $queryParam = $this->urlEncoder->encode($this->getUrl('*/*/*', ['_current' => true]) . '#review-form');
         $this->setLoginLink($this->getUrl('customer/account/login/', [Url::REFERER_QUERY_PARAM_NAME => $queryParam]));
     }
     $this->setTemplate('form.phtml');
 }
예제 #14
0
 /**
  * Get Key pieces for caching block content
  *
  * @return array
  */
 public function getCacheKeyInfo()
 {
     $shortCacheId = ['CATALOG_NAVIGATION', $this->_storeManager->getStore()->getId(), $this->_design->getDesignTheme()->getId(), $this->httpContext->getValue(Context::CONTEXT_GROUP), 'template' => $this->getTemplate(), 'name' => $this->getNameInLayout(), $this->getCurrentCategoryKey()];
     $cacheId = $shortCacheId;
     $shortCacheId = array_values($shortCacheId);
     $shortCacheId = implode('|', $shortCacheId);
     $shortCacheId = md5($shortCacheId);
     $cacheId['category_path'] = $this->getCurrentCategoryKey();
     $cacheId['short_cache_id'] = $shortCacheId;
     return $cacheId;
 }
예제 #15
0
 /**
  * Get last order ID from session, fetch it and check whether it can be viewed, printed etc
  *
  * @return void
  */
 protected function _prepareLastOrder()
 {
     $orderId = $this->_checkoutSession->getLastOrderId();
     if ($orderId) {
         $order = $this->_orderFactory->create()->load($orderId);
         if ($order->getId()) {
             $isVisible = !in_array($order->getStatus(), $this->_orderConfig->getInvisibleOnFrontStatuses());
             $canView = $this->httpContext->getValue(Context::CONTEXT_AUTH) && $isVisible;
             $this->addData(['is_order_visible' => $isVisible, 'view_order_url' => $this->getUrl('sales/order/view/', ['order_id' => $orderId]), 'print_url' => $this->getUrl('sales/order/print', ['order_id' => $orderId]), 'can_print_order' => $isVisible, 'can_view_order' => $canView, 'order_id' => $order->getIncrementId()]);
         }
     }
 }
예제 #16
0
파일: Send.php 프로젝트: aiesh/magento2
 /**
  * Retrieve sender email address
  *
  * @return string
  */
 public function getEmail()
 {
     $email = $this->getFormData()->getData('sender/email');
     if (!empty($email)) {
         return trim($email);
     }
     /* @var $session \Magento\Customer\Model\Session */
     $session = $this->_customerSession;
     if ($this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH)) {
         return $session->getCustomerDataObject()->getEmail();
     }
     return '';
 }
예제 #17
0
 /**
  * Retrieve Product Compare items collection
  *
  * @return \Magento\Catalog\Model\ResourceModel\Product\Compare\Item\Collection
  */
 public function getItems()
 {
     if ($this->_items === null) {
         $this->_compareProduct->setAllowUsedFlat(false);
         $this->_items = $this->_itemCollectionFactory->create();
         $this->_items->useProductItem(true)->setStoreId($this->_storeManager->getStore()->getId());
         if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {
             $this->_items->setCustomerId($this->currentCustomer->getCustomerId());
         } elseif ($this->_customerId) {
             $this->_items->setCustomerId($this->_customerId);
         } else {
             $this->_items->setVisitorId($this->_customerVisitor->getId());
         }
         $this->_items->addAttributeToSelect($this->_catalogConfig->getProductAttributes())->loadComparableAttributes()->addMinimalPrice()->addTaxPercents()->setVisibility($this->_catalogProductVisibility->getVisibleInSiteIds());
     }
     return $this->_items;
 }
예제 #18
0
파일: Form.php 프로젝트: opexsw/magento2
 /**
  * Initialize review form
  *
  * @return void
  */
 protected function _construct()
 {
     parent::_construct();
     $data = $this->_reviewSession->getFormData(true);
     $data = new \Magento\Framework\Object((array) $data);
     // add logged in customer name as nickname
     if (!$data->getNickname()) {
         $customer = $this->_customerSession->getCustomerDataObject();
         if ($customer && $customer->getId()) {
             $data->setNickname($customer->getFirstname());
         }
     }
     $this->setAllowWriteReviewFlag($this->httpContext->getValue(Context::CONTEXT_AUTH) || $this->_reviewData->getIsGuestAllowToWrite());
     if (!$this->getAllowWriteReviewFlag()) {
         $queryParam = $this->urlEncoder->encode($this->getUrl('*/*/*', ['_current' => true]) . '#review-form');
         $this->setLoginLink($this->getUrl('customer/account/login/', [Url::REFERER_QUERY_PARAM_NAME => $queryParam]));
     }
     $this->setTemplate('form.phtml')->assign('data', $data);
 }
 /**
  * Is logged in
  *
  * @return bool
  */
 public function isLoggedIn()
 {
     return $this->httpContext->getValue(Context::CONTEXT_AUTH);
 }
예제 #20
0
 /**
  * Checking customer login status
  *
  * @return bool
  */
 public function customerLoggedIn()
 {
     return (bool) $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);
 }
예제 #21
0
 /**
  * Get current store currency code
  *
  * @return string
  */
 public function getCurrentCurrencyCode()
 {
     // try to get currently set code among allowed
     $code = $this->_httpContext->getValue(Context::CONTEXT_CURRENCY);
     $code = $code === null ? $this->_getSession()->getCurrencyCode() : $code;
     if (empty($code)) {
         $code = $this->getDefaultCurrencyCode();
     }
     if (in_array($code, $this->getAvailableCurrencyCodes(true))) {
         return $code;
     }
     // take first one of allowed codes
     $codes = array_values($this->getAvailableCurrencyCodes(true));
     if (empty($codes)) {
         // return default code, if no codes specified at all
         return $this->getDefaultCurrencyCode();
     }
     return array_shift($codes);
 }
예제 #22
0
파일: Footer.php 프로젝트: nja78/magento2
 /**
  * Get cache key informative items
  *
  * @return array
  */
 public function getCacheKeyInfo()
 {
     return ['PAGE_FOOTER', $this->_storeManager->getStore()->getId(), (int) $this->_storeManager->getStore()->isCurrentlySecure(), $this->_design->getDesignTheme()->getId(), $this->httpContext->getValue(Context::CONTEXT_AUTH)];
 }
예제 #23
0
 public function testSetUnsetGetValue()
 {
     $this->object->setValue('key', 'value', 'default');
     $this->object->unsValue('key');
     $this->assertEquals('default', $this->object->getValue('key'));
 }
예제 #24
0
 /**
  * Get key pieces for caching block content
  *
  * @return array
  */
 public function getCacheKeyInfo()
 {
     $conditions = $this->getData('conditions') ? $this->getData('conditions') : $this->getData('conditions_encoded');
     return ['CATALOG_PRODUCTS_LIST_WIDGET', $this->_storeManager->getStore()->getId(), $this->_design->getDesignTheme()->getId(), $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_GROUP), intval($this->getRequest()->getParam(self::PAGE_VAR_NAME, 1)), $this->getProductsPerPage(), $conditions];
 }
예제 #25
0
 /**
  * Is logged in
  *
  * @return bool
  */
 public function isLoggedIn()
 {
     return $this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH);
 }
예제 #26
0
 /**
  * Can view order
  *
  * @param Order $order
  * @return bool
  */
 protected function canViewOrder(Order $order)
 {
     return $this->httpContext->getValue(Context::CONTEXT_AUTH) && $this->isVisible($order);
 }
예제 #27
0
 /**
  * Get current customer group id
  *
  * @return int
  */
 public function getCurrentCustomerGroupId()
 {
     return $this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_GROUP);
 }
예제 #28
0
 /**
  * Get Key pieces for caching block content
  *
  * @return array
  */
 public function getCacheKeyInfo()
 {
     return ['CATALOG_PRODUCT_NEW', $this->_storeManager->getStore()->getId(), $this->_design->getDesignTheme()->getId(), $this->httpContext->getValue(CustomerContext::CONTEXT_GROUP), 'template' => $this->getTemplate(), $this->getProductsCount()];
 }
예제 #29
0
파일: Footer.php 프로젝트: aiesh/magento2
 /**
  * Get cache key informative items
  *
  * @return array
  */
 public function getCacheKeyInfo()
 {
     return array('PAGE_FOOTER', $this->_storeManager->getStore()->getId(), (int) $this->_storeManager->getStore()->isCurrentlySecure(), $this->_design->getDesignTheme()->getId(), $this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH));
 }
예제 #30
0
파일: Sidebar.php 프로젝트: aiesh/magento2
 /**
  * Render "My Orders" sidebar block
  *
  * @return string
  */
 protected function _toHtml()
 {
     $isValid = $this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH) || $this->getCustomerId();
     return $isValid ? parent::_toHtml() : '';
 }