Mage_Catalog_Block_Product_View Class Reference

Inheritance diagram for Mage_Catalog_Block_Product_View:

Mage_Catalog_Block_Product_Abstract Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object Mage_Bundle_Block_Catalog_Product_View Mage_Review_Block_Product_View Mage_Review_Block_Product_View_List

List of all members.

Public Member Functions

 getProduct ()
 canEmailToFriend ()
 getAddToCartUrl ($product, $additional=array())
 getJsonConfig ()
 hasOptions ()
 hasRequiredOptions ()

Protected Member Functions

 _prepareLayout ()


Detailed Description

Definition at line 35 of file View.php.


Member Function Documentation

_prepareLayout (  )  [protected]

Preparing global layout

You can redefine this method in child classes for changin layout

Returns:
Mage_Core_Block_Abstract

Reimplemented from Mage_Core_Block_Abstract.

Reimplemented in Mage_Review_Block_Product_View_List.

Definition at line 37 of file View.php.

00038     {
00039         $this->getLayout()->createBlock('catalog/breadcrumbs');
00040         if ($headBlock = $this->getLayout()->getBlock('head')) {
00041             if ($title = $this->getProduct()->getMetaTitle()) {
00042                 $headBlock->setTitle($title);
00043             }
00044 
00045             if ($keyword = $this->getProduct()->getMetaKeyword()) {
00046                 $headBlock->setKeywords($keyword);
00047             } elseif( $currentCategory = Mage::registry('current_category') ) {
00048                 $headBlock->setKeywords($this->getProduct()->getName());
00049             }
00050 
00051             if ($description = $this->getProduct()->getMetaDescription()) {
00052                 $headBlock->setDescription( ($description) );
00053             } else {
00054                 $headBlock->setDescription( $this->getProduct()->getDescription() );
00055             }
00056         }
00057 
00058         return parent::_prepareLayout();
00059     }

canEmailToFriend (  ) 

Definition at line 75 of file View.php.

00076     {
00077         $sendToFriendModel = Mage::registry('send_to_friend_model');
00078         return $sendToFriendModel && $sendToFriendModel->canEmailToFriend();
00079     }

getAddToCartUrl ( product,
additional = array() 
)

Retrieve url for direct adding product to cart

Parameters:
Mage_Catalog_Model_Product $product
array $additional
Returns:
string

Reimplemented from Mage_Catalog_Block_Product_Abstract.

Definition at line 88 of file View.php.

00089     {
00090         $additional = array();
00091 
00092         if ($this->getRequest()->getParam('wishlist_next')){
00093             $additional['wishlist_next'] = 1;
00094         }
00095 
00096         return $this->helper('checkout/cart')->getAddUrl($product, $additional);
00097     }

getJsonConfig (  ) 

Definition at line 99 of file View.php.

00100     {
00101         $config = array();
00102 
00103         $_request = Mage::getSingleton('tax/calculation')->getRateRequest(false, false, false);
00104         $_request->setProductClassId($this->getProduct()->getTaxClassId());
00105         $defaultTax = Mage::getSingleton('tax/calculation')->getRate($_request);
00106 
00107         $_request = Mage::getSingleton('tax/calculation')->getRateRequest();
00108         $_request->setProductClassId($this->getProduct()->getTaxClassId());
00109         $currentTax = Mage::getSingleton('tax/calculation')->getRate($_request);
00110 
00111         $_regularPrice = $this->getProduct()->getPrice();
00112         $_finalPrice = $this->getProduct()->getFinalPrice();
00113         $_priceInclTax = Mage::helper('tax')->getPrice($this->getProduct(), $_finalPrice, true);
00114         $_priceExclTax = Mage::helper('tax')->getPrice($this->getProduct(), $_finalPrice);
00115 
00116         $idSuffix = '__none__';
00117         if ($this->hasOptions()) {
00118             $idSuffix = '_clone';
00119         }
00120 
00121         $config = array(
00122             'productId'           => $this->getProduct()->getId(),
00123             'priceFormat'         => Mage::app()->getLocale()->getJsPriceFormat(),
00124             'includeTax'          => Mage::helper('tax')->priceIncludesTax() ? 'true' : 'false',
00125             'showIncludeTax'      => Mage::helper('tax')->displayPriceIncludingTax(),
00126             'showBothPrices'      => Mage::helper('tax')->displayBothPrices(),
00127             'productPrice'        => Mage::helper('core')->currency($_finalPrice, false, false),
00128             'productOldPrice'     => Mage::helper('core')->currency($_regularPrice, false, false),
00129             'skipCalculate'       => ($_priceExclTax != $_priceInclTax ? 0 : 1),
00130             'defaultTax'          => $defaultTax,
00131             'currentTax'          => $currentTax,
00132             'idSuffix'            => $idSuffix,
00133             'oldPlusDisposition'  => 0,
00134             'plusDisposition'     => 0,
00135             'oldMinusDisposition' => 0,
00136             'minusDisposition'    => 0,
00137         );
00138 
00139         $responseObject = new Varien_Object();
00140         Mage::dispatchEvent('catalog_product_view_config', array('response_object'=>$responseObject));
00141         if (is_array($responseObject->getAdditionalOptions())) {
00142             foreach ($responseObject->getAdditionalOptions() as $option=>$value) {
00143                 $config[$option] = $value;
00144             }
00145         }
00146 
00147         return Zend_Json::encode($config);
00148     }

getProduct (  ) 

Retrieve current product model

Returns:
Mage_Catalog_Model_Product

Reimplemented from Mage_Catalog_Block_Product_Abstract.

Definition at line 66 of file View.php.

00067     {
00068         if (!Mage::registry('product') && $this->getProductId()) {
00069             $product = Mage::getModel('catalog/product')->load($this->getProductId());
00070             Mage::register('product', $product);
00071         }
00072         return Mage::registry('product');
00073     }

hasOptions (  ) 

Return true if product has options

Returns:
bool

Reimplemented in Mage_Review_Block_Product_View.

Definition at line 155 of file View.php.

00156     {
00157         if ($this->getProduct()->getTypeInstance(true)->hasOptions($this->getProduct())) {
00158             return true;
00159         }
00160         return false;
00161     }

hasRequiredOptions (  ) 

Check if product has required options

Returns:
bool

Definition at line 168 of file View.php.

00169     {
00170         return $this->getProduct()->getTypeInstance(true)->hasRequiredOptions($this->getProduct());
00171     }


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