Mage_Catalog_Helper_Data Class Reference

Inheritance diagram for Mage_Catalog_Helper_Data:

Mage_Core_Helper_Abstract

List of all members.

Public Member Functions

 getBreadcrumbPath ()
 getCategory ()
 getProduct ()
 getLastViewedUrl ()
 splitSku ($sku, $length=30)
 getAttributeHiddenFields ()
 getAttributeDisabledTypes ()
 getPriceScope ()
 isPriceGlobal ()

Public Attributes

const PRICE_SCOPE_GLOBAL = 0
const PRICE_SCOPE_WEBSITE = 1
const XML_PATH_PRICE_SCOPE = 'catalog/price/scope'

Protected Member Functions

 _isCategoryLink ($categoryId)

Protected Attributes

 $_categoryPath


Detailed Description

Definition at line 35 of file Data.php.


Member Function Documentation

_isCategoryLink ( categoryId  )  [protected]

Check is category link

Parameters:
int $categoryId
Returns:
bool

Definition at line 91 of file Data.php.

00092     {
00093         if ($this->getProduct()) {
00094             return true;
00095         }
00096         if ($categoryId != $this->getCategory()->getId()) {
00097             return true;
00098         }
00099         return false;
00100     }

getAttributeDisabledTypes (  ) 

Retrieve attribute disabled types

Returns:
array

Definition at line 179 of file Data.php.

00180     {
00181         if (Mage::registry('attribute_type_disabled_types')) {
00182             return Mage::registry('attribute_type_disabled_types');
00183         } else {
00184             return array();
00185         }
00186     }

getAttributeHiddenFields (  ) 

Retrieve attribute hidden fields

Returns:
array

Definition at line 165 of file Data.php.

00166     {
00167         if (Mage::registry('attribute_type_hidden_fields')) {
00168             return Mage::registry('attribute_type_hidden_fields');
00169         } else {
00170             return array();
00171         }
00172     }

getBreadcrumbPath (  ) 

Return current category path or get it from current category and creating array of categories|product paths for breadcrumbs

Returns:
string

Definition at line 54 of file Data.php.

00055     {
00056         if (!$this->_categoryPath) {
00057 
00058             $path = array();
00059             if ($category = $this->getCategory()) {
00060                 $pathInStore = $category->getPathInStore();
00061                 $pathIds = array_reverse(explode(',', $pathInStore));
00062 
00063                 $categories = $category->getParentCategories();
00064 
00065                 // add category path breadcrumb
00066                 foreach ($pathIds as $categoryId) {
00067                     if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
00068                         $path['category'.$categoryId] = array(
00069                             'label' => $categories[$categoryId]->getName(),
00070                             'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''
00071                         );
00072                     }
00073                 }
00074             }
00075 
00076             if ($this->getProduct()) {
00077                 $path['product'] = array('label'=>$this->getProduct()->getName());
00078             }
00079 
00080             $this->_categoryPath = $path;
00081         }
00082         return $this->_categoryPath;
00083     }

getCategory (  ) 

Return current category object

Returns:
Mage_Catalog_Model_Category|null

Definition at line 107 of file Data.php.

00108     {
00109         return Mage::registry('current_category');
00110     }

getLastViewedUrl (  ) 

Retrieve Visitor/Customer Last Viewed URL

Returns:
string

Definition at line 127 of file Data.php.

00128     {
00129         if ($productId = Mage::getSingleton('catalog/session')->getLastViewedProductId()) {
00130             $product = Mage::getModel('catalog/product')->load($productId);
00131             /* @var $product Mage_Catalog_Model_Product */
00132             if (Mage::helper('catalog/product')->canShow($product, 'catalog')) {
00133                 return $product->getProductUrl();
00134             }
00135         }
00136         if ($categoryId = Mage::getSingleton('catalog/session')->getLastViewedCategoryId()) {
00137             $category = Mage::getModel('catalog/category')->load($categoryId);
00138             /* @var $category Mage_Catalog_Model_Category */
00139             if (!Mage::helper('catalog/category')->canShow($category)) {
00140                 return '';
00141             }
00142             return $category->getCategoryUrl();
00143         }
00144         return '';
00145     }

getPriceScope (  ) 

Retrieve Catalog Price Scope

Returns:
int

Definition at line 193 of file Data.php.

00194     {
00195         return Mage::getStoreConfig(self::XML_PATH_PRICE_SCOPE);
00196     }

getProduct (  ) 

Retrieve current Product object

Returns:
Mage_Catalog_Model_Product|null

Definition at line 117 of file Data.php.

00118     {
00119         return Mage::registry('current_product');
00120     }

isPriceGlobal (  ) 

Is Global Price

Returns:
bool

Definition at line 203 of file Data.php.

00204     {
00205         return $this->getPriceScope() == self::PRICE_SCOPE_GLOBAL;
00206     }

splitSku ( sku,
length = 30 
)

Split SKU of an item by dashes and spaces Words will not be broken, unless thir length is greater than $length

Parameters:
string $sku
int $length
Returns:
array

Definition at line 155 of file Data.php.

00156     {
00157         return Mage::helper('core/string')->str_split($sku, $length, true, false, '[\-\s]');
00158     }


Member Data Documentation

$_categoryPath [protected]

Definition at line 46 of file Data.php.

const PRICE_SCOPE_GLOBAL = 0

Definition at line 37 of file Data.php.

Definition at line 38 of file Data.php.

const XML_PATH_PRICE_SCOPE = 'catalog/price/scope'

Definition at line 39 of file Data.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:37 2009 for Magento by  doxygen 1.5.8