1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Checkout
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * Shopping cart item render block
29: *
30: * @category Mage
31: * @package Mage_Checkout
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Checkout_Block_Cart_Item_Renderer_Configurable extends Mage_Checkout_Block_Cart_Item_Renderer
35: {
36: const CONFIGURABLE_PRODUCT_IMAGE= 'checkout/cart/configurable_product_image';
37: const USE_PARENT_IMAGE = 'parent';
38:
39: /**
40: * Get item configurable product
41: *
42: * @return Mage_Catalog_Model_Product
43: */
44: public function getConfigurableProduct()
45: {
46: if ($option = $this->getItem()->getOptionByCode('product_type')) {
47: return $option->getProduct();
48: }
49: return $this->getProduct();
50: }
51:
52: /**
53: * Get item configurable child product
54: *
55: * @return Mage_Catalog_Model_Product
56: */
57: public function getChildProduct()
58: {
59: if ($option = $this->getItem()->getOptionByCode('simple_product')) {
60: return $option->getProduct();
61: }
62: return $this->getProduct();
63: }
64:
65: /**
66: * Get product thumbnail image
67: *
68: * @return Mage_Catalog_Model_Product_Image
69: */
70: public function getProductThumbnail()
71: {
72: $product = $this->getChildProduct();
73: if (!$product || !$product->getData('thumbnail')
74: || ($product->getData('thumbnail') == 'no_selection')
75: || (Mage::getStoreConfig(self::CONFIGURABLE_PRODUCT_IMAGE) == self::USE_PARENT_IMAGE)) {
76: $product = $this->getProduct();
77: }
78: return $this->helper('catalog/image')->init($product, 'thumbnail');
79: }
80:
81: /**
82: * Get item product name
83: *
84: * @return string
85: */
86: public function getProductName()
87: {
88: return $this->getProduct()->getName();
89: }
90:
91: /**
92: * Get selected for configurable product attributes
93: *
94: * @return array
95: */
96: public function getProductAttributes()
97: {
98: $attributes = $this->getProduct()->getTypeInstance(true)
99: ->getSelectedAttributesInfo($this->getProduct());
100: return $attributes;
101: }
102:
103: /**
104: * Get list of all otions for product
105: *
106: * @return array
107: */
108: public function getOptionList()
109: {
110: /* @var $helper Mage_Catalog_Helper_Product_Configuration */
111: $helper = Mage::helper('catalog/product_configuration');
112: $options = $helper->getConfigurableOptions($this->getItem());
113: return $options;
114: }
115: }
116: