00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_Checkout 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 /** 00028 * Shopping cart item render block 00029 * 00030 * @category Mage 00031 * @package Mage_Checkout 00032 * @author Magento Core Team <core@magentocommerce.com> 00033 */ 00034 class Mage_Checkout_Block_Cart_Item_Renderer_Configurable extends Mage_Checkout_Block_Cart_Item_Renderer 00035 { 00036 const CONFIGURABLE_PRODUCT_IMAGE= 'checkout/cart/configurable_product_image'; 00037 const USE_PARENT_IMAGE = 'parent'; 00038 00039 /** 00040 * Get item configurable product 00041 * 00042 * @return Mage_Catalog_Model_Product 00043 */ 00044 public function getConfigurableProduct() 00045 { 00046 if ($option = $this->getItem()->getOptionByCode('product_type')) { 00047 return $option->getProduct(); 00048 } 00049 return $this->getProduct(); 00050 } 00051 00052 /** 00053 * Get item configurable child product 00054 * 00055 * @return Mage_Catalog_Model_Product 00056 */ 00057 public function getChildProduct() 00058 { 00059 if ($option = $this->getItem()->getOptionByCode('simple_product')) { 00060 return $option->getProduct(); 00061 } 00062 return $this->getProduct(); 00063 } 00064 00065 /** 00066 * Get product thumbnail image 00067 * 00068 * @return Mage_Catalog_Model_Product_Image 00069 */ 00070 public function getProductThumbnail() 00071 { 00072 $product = $this->getChildProduct(); 00073 if (!$product || !$product->getData('thumbnail') 00074 || ($product->getData('thumbnail') == 'no_selection') 00075 || (Mage::getStoreConfig(self::CONFIGURABLE_PRODUCT_IMAGE) == self::USE_PARENT_IMAGE)) { 00076 $product = $this->getProduct(); 00077 } 00078 return $this->helper('catalog/image')->init($product, 'thumbnail'); 00079 } 00080 00081 /** 00082 * Get item product name 00083 * 00084 * @return string 00085 */ 00086 public function getProductName() 00087 { 00088 return $this->getProduct()->getName(); 00089 } 00090 00091 /** 00092 * Get url to item product 00093 * 00094 * @return string 00095 */ 00096 public function getProductUrl() 00097 { 00098 return $this->getProduct()->getProductUrl(); 00099 } 00100 00101 /** 00102 * Get selected for configurable product attributes 00103 * 00104 * @return array 00105 */ 00106 public function getProductAttributes() 00107 { 00108 $attributes = $this->getProduct()->getTypeInstance(true) 00109 ->getSelectedAttributesInfo($this->getProduct()); 00110 return $attributes; 00111 } 00112 00113 /** 00114 * Get list of all otions for product 00115 * 00116 * @return array 00117 */ 00118 public function getOptionList() 00119 { 00120 $options = array_merge($this->getProductAttributes(), $this->getProductOptions()); 00121 return $options; 00122 } 00123 00124 }