Mage_Catalog_Block_Product_Abstract Class Reference

Inheritance diagram for Mage_Catalog_Block_Product_Abstract:

Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object Mage_Bundle_Block_Catalog_Product_List_Partof Mage_Catalog_Block_Product_Compare_List Mage_Catalog_Block_Product_Compare_Sidebar Mage_Catalog_Block_Product_List Mage_Catalog_Block_Product_List_Crosssell Mage_Catalog_Block_Product_List_Related Mage_Catalog_Block_Product_List_Upsell Mage_Catalog_Block_Product_New Mage_Catalog_Block_Product_Send Mage_Catalog_Block_Product_View Mage_Catalog_Block_Product_View_Abstract Mage_Checkout_Block_Cart_Crosssell Mage_Downloadable_Block_Catalog_Product_Links Mage_Downloadable_Block_Catalog_Product_Samples Mage_Reports_Block_Product_Abstract Mage_Review_Block_Customer_View Mage_Review_Block_View Mage_Tag_Block_Customer_View Mage_Tag_Block_Product_Result Mage_Wishlist_Block_Customer_Sidebar Mage_Wishlist_Block_Customer_Wishlist Mage_Wishlist_Block_Share_Wishlist

List of all members.

Public Member Functions

 getAddToCartUrl ($product, $additional=array())
 getAddToWishlistUrl ($product)
 getAddToCompareUrl ($product)
 getMinimalQty ($product)
 getPriceHtml ($product, $displayMinimalPrice=false, $idSuffix='')
 addPriceBlockType ($type, $block= '', $template= '')
 getReviewsSummaryHtml (Mage_Catalog_Model_Product $product, $templateType=false, $displayIfNoReviews=false)
 addReviewSummaryTemplate ($type, $template)
 getProduct ()
 getTierPriceTemplate ()
 getTierPriceHtml ($product=null)
 getTierPrices ($product=null)
 getImageLabel ($product=null, $mediaAttributeCode='image')

Protected Member Functions

 _getPriceBlock ($productTypeId)
 _getPriceBlockTemplate ($productTypeId)
 _initReviewsHelperBlock ()
 _addProductAttributesAndPrices (Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection)


Detailed Description

Definition at line 35 of file Abstract.php.


Member Function Documentation

_addProductAttributesAndPrices ( Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection collection  )  [protected]

Add all attributes and apply pricing logic to products collection to get correct values in different products lists. E.g. crosssells, upsells, new products, recently viewed

Parameters:
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
Returns:
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection

Definition at line 271 of file Abstract.php.

00272     {
00273         return $collection
00274             ->addMinimalPrice()
00275             ->addFinalPrice()
00276             ->addTaxPercents()
00277             ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes());
00278     }

_getPriceBlock ( productTypeId  )  [protected]

Definition at line 92 of file Abstract.php.

00093     {
00094         if (!isset($this->_priceBlock[$productTypeId])) {
00095             $block = 'catalog/product_price';
00096             if (isset($this->_priceBlockTypes[$productTypeId])) {
00097                 if ($this->_priceBlockTypes[$productTypeId]['block'] != '') {
00098                     $block = $this->_priceBlockTypes[$productTypeId]['block'];
00099                 }
00100             }
00101             $this->_priceBlock[$productTypeId] = $this->getLayout()->createBlock($block);
00102         }
00103         return $this->_priceBlock[$productTypeId];
00104     }

_getPriceBlockTemplate ( productTypeId  )  [protected]

Definition at line 106 of file Abstract.php.

00107     {
00108         if (isset($this->_priceBlockTypes[$productTypeId])) {
00109             if ($this->_priceBlockTypes[$productTypeId]['template'] != '') {
00110                 return $this->_priceBlockTypes[$productTypeId]['template'];
00111             }
00112         }
00113         return $this->_priceBlockDefaultTemplate;
00114     }

_initReviewsHelperBlock (  )  [protected]

Create reviews summary helper block once

Definition at line 179 of file Abstract.php.

00180     {
00181         if (!$this->_reviewsHelperBlock) {
00182             $this->_reviewsHelperBlock = $this->getLayout()->createBlock('review/helper');
00183         }
00184     }

addPriceBlockType ( type,
block = '',
template = '' 
)

Adding customized price template for product type

Parameters:
string $type
string $block
string $template

Definition at line 139 of file Abstract.php.

00140     {
00141         if ($type) {
00142             $this->_priceBlockTypes[$type] = array(
00143                 'block' => $block,
00144                 'template' => $template
00145             );
00146         }
00147     }

addReviewSummaryTemplate ( type,
template 
)

Add/replace reviews summary template by type

Parameters:
string $type
string $template

Definition at line 169 of file Abstract.php.

00170     {
00171         $this->_initReviewsHelperBlock();
00172         $this->_reviewsHelperBlock->addTemplate($type, $template);
00173     }

getAddToCartUrl ( product,
additional = array() 
)

Retrieve url for add product to cart Will return product view page URL if product has required options

Parameters:
Mage_Catalog_Model_Product $product
array $additional
Returns:
string

Reimplemented in Mage_Catalog_Block_Product_View.

Definition at line 52 of file Abstract.php.

00053     {
00054         if ($product->getTypeInstance(true)->hasRequiredOptions($product)) {
00055             $url = $product->getProductUrl();
00056             $link = (strpos($url, '?') !== false) ? '&' : '?';
00057             return $url . $link . 'options=cart';
00058         }
00059         return $this->helper('checkout/cart')->getAddUrl($product, $additional);
00060     }

getAddToCompareUrl ( product  ) 

Enter description here...

Parameters:
Mage_Catalog_Model_Product $product
Returns:
string

Definition at line 79 of file Abstract.php.

00080     {
00081         return $this->helper('catalog/product_compare')->getAddUrl($product);
00082     }

getAddToWishlistUrl ( product  ) 

Enter description here...

Parameters:
Mage_Catalog_Model_Product $product
Returns:
string

Definition at line 68 of file Abstract.php.

00069     {
00070         return $this->getUrl('wishlist/index/add',array('product'=>$product->getId()));
00071     }

getImageLabel ( product = null,
mediaAttributeCode = 'image' 
)

Retrieve given media attribute label or product name if no label

Parameters:
Mage_Catalog_Model_Product $product
string $mediaAttributeCode
Returns:
string

Definition at line 288 of file Abstract.php.

00289     {
00290         if (is_null($product)) {
00291             $product = $this->getProduct();
00292         }
00293 
00294         $label = $product->getData($mediaAttributeCode.'_label');
00295         if (empty($label)) {
00296             $label = $product->getName();
00297         }
00298 
00299         return $label;
00300     }

getMinimalQty ( product  ) 

Definition at line 84 of file Abstract.php.

00085     {
00086         if ($stockItem = $product->getStockItem()) {
00087             return $stockItem->getMinSaleQty()>1 ? $stockItem->getMinSaleQty()*1 : null;
00088         }
00089         return null;
00090     }

getPriceHtml ( product,
displayMinimalPrice = false,
idSuffix = '' 
)

Returns product price block html

Parameters:
Mage_Catalog_Model_Product $product
boolean $displayMinimalPrice

Definition at line 122 of file Abstract.php.

00123     {
00124         return $this->_getPriceBlock($product->getTypeId())
00125             ->setTemplate($this->_getPriceBlockTemplate($product->getTypeId()))
00126             ->setProduct($product)
00127             ->setDisplayMinimalPrice($displayMinimalPrice)
00128             ->setIdSuffix($idSuffix)
00129             ->toHtml();
00130     }

getProduct (  ) 

Retrieve currently viewed product object

Returns:
Mage_Catalog_Model_Product

Reimplemented in Mage_Bundle_Block_Catalog_Product_List_Partof, Mage_Catalog_Block_Product_View_Abstract, and Mage_Catalog_Block_Product_View.

Definition at line 191 of file Abstract.php.

00192     {
00193         if (!$this->hasData('product')) {
00194             $this->setData('product', Mage::registry('product'));
00195         }
00196         return $this->getData('product');
00197     }

getReviewsSummaryHtml ( Mage_Catalog_Model_Product product,
templateType = false,
displayIfNoReviews = false 
)

Get product reviews summary

Parameters:
Mage_Catalog_Model_Product $product
bool $templateType
bool $displayIfNoReviews
Returns:
string

Reimplemented in Mage_Review_Block_Product_View.

Definition at line 157 of file Abstract.php.

00158     {
00159         $this->_initReviewsHelperBlock();
00160         return $this->_reviewsHelperBlock->getSummaryHtml($product, $templateType, $displayIfNoReviews);
00161     }

getTierPriceHtml ( product = null  ) 

Returns product tierprice block html

Parameters:
Mage_Catalog_Model_Product $product

Definition at line 212 of file Abstract.php.

00213     {
00214         if (is_null($product)) {
00215             $product = $this->getProduct();
00216         }
00217         return $this->_getPriceBlock($product->getTypeId())
00218             ->setTemplate($this->getTierPriceTemplate())
00219             ->setProduct($product)
00220             ->setInGrouped($this->getProduct()->isGrouped())
00221             ->toHtml();
00222     }

getTierPrices ( product = null  ) 

Get tier prices (formatted)

Parameters:
Mage_Catalog_Model_Product $product
Returns:
array

Reimplemented in Mage_Bundle_Block_Catalog_Product_View.

Definition at line 230 of file Abstract.php.

00231     {
00232         if (is_null($product)) {
00233             $product = $this->getProduct();
00234         }
00235         $prices  = $product->getFormatedTierPrice();
00236 
00237         $res = array();
00238         if (is_array($prices)) {
00239             foreach ($prices as $price) {
00240                 $price['price_qty'] = $price['price_qty']*1;
00241                 if ($product->getPrice() != $product->getFinalPrice()) {
00242                     if ($price['price']<$product->getFinalPrice()) {
00243                         $price['savePercent'] = ceil(100 - (( 100/$product->getFinalPrice() ) * $price['price'] ));
00244                         $price['formated_price'] = Mage::app()->getStore()->formatPrice(Mage::app()->getStore()->convertPrice(Mage::helper('tax')->getPrice($product, $price['website_price'])));
00245                         $price['formated_price_incl_tax'] = Mage::app()->getStore()->formatPrice(Mage::app()->getStore()->convertPrice(Mage::helper('tax')->getPrice($product, $price['website_price'], true)));
00246                         $res[] = $price;
00247                     }
00248                 }
00249                 else {
00250                     if ($price['price']<$product->getPrice()) {
00251                         $price['savePercent'] = ceil(100 - (( 100/$product->getPrice() ) * $price['price'] ));
00252                         $price['formated_price'] = Mage::app()->getStore()->formatPrice(Mage::app()->getStore()->convertPrice(Mage::helper('tax')->getPrice($product, $price['website_price'])));
00253                         $price['formated_price_incl_tax'] = Mage::app()->getStore()->formatPrice(Mage::app()->getStore()->convertPrice(Mage::helper('tax')->getPrice($product, $price['website_price'], true)));
00254                         $res[] = $price;
00255                     }
00256                 }
00257             }
00258         }
00259 
00260         return $res;
00261     }

getTierPriceTemplate (  ) 

Definition at line 199 of file Abstract.php.

00200     {
00201         if (!$this->hasData('tier_price_template')) {
00202             return $this->_tierPriceDefaultTemplate;
00203         }
00204 
00205         return $this->getData('tier_price_template');
00206     }


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

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