×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: bejoy balan
Added: Aug 21, 2017 7:16 AM
Views: 2501
  1. protected function _getPageType()
  2.     {
  3.         if ($this->_pageType != NULL) {
  4.             return $this->_pageType;
  5.         }
  6.  
  7.         $routeName = $this->getRequest()->getRequestedRouteName();
  8.         $actionName = $this->getAction()->getFullActionName();
  9.         $this->_pageType = '';
  10.  
  11.         if ($actionName == 'catalog_product_view') {
  12.             $this->_pageType = 'product';
  13.  
  14.         } elseif ($actionName == 'catalog_category_view') {
  15.             $this->_pageType = 'category';
  16.  
  17.         } elseif ($this->getRequest()->getPathInfo() == '/') {
  18.             $this->_pageType = 'home';
  19.  
  20.         } elseif ($routeName == 'cms') {
  21.  
  22.             $identifier = Mage::getSingleton('cms/page')->getIdentifier();
  23.             if ($identifier == 'home' || $identifier == 'enterprise-home') {
  24.                 $this->_pageType = 'home';
  25.  
  26.             } else {
  27.                 $this->_pageType = 'cms';
  28.             }
  29.  
  30.         } elseif ($routeName == 'checkout' || $routeName == 'onestepcheckout') {
  31.  
  32.             if ($this->getRequest()->getControllerName() == 'cart') {
  33.                 $this->_pageType = 'cart';
  34.  
  35.             } elseif ($this->getRequest()->getActionName() == 'success') {
  36.                 $this->_pageType = 'success';
  37.  
  38.             } else {
  39.                 $this->_pageType = 'checkout';
  40.             }
  41.  
  42.         } elseif ($routeName == 'customer') {
  43.             $this->_pageType = 'customer';
  44.  
  45.  
  46.         } elseif ($routeName == 'catalogsearch') {
  47.             $this->_pageType = 'search';
  48.  
  49.         }
  50.  
  51.         return $this->_pageType;
  52.     }