Version Notes
Next Beta version release
Download this release
Release Info
Developer | ps_patel |
Extension | Inic_Configure |
Version | 0.1.1 |
Comparing to | |
See all releases |
Code changes from version 0.1.0 to 0.1.1
- app/code/local/Inic/Configurableoption/Block/Additionaldata.php +51 -0
- app/code/local/Inic/Configurableoption/Block/Product/View/Type/Configurable.php +175 -9
- app/code/local/Inic/Configurableoption/etc/config.xml +7 -2
- app/design/frontend/default/default/layout/Configurableoption.xml +0 -16
- app/design/frontend/default/default/layout/configurableoption.xml +9 -0
- app/design/frontend/default/default/template/Configurableoption/catalog/product/view/type/options/configurable.phtml +0 -50
- js/configurableoption/configure.js +172 -59
- package.xml +19 -9
app/code/local/Inic/Configurableoption/Block/Additionaldata.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Inic_Configurableoption_Block_Additionaldata extends Mage_Catalog_Block_Product_Abstract
|
3 |
+
{
|
4 |
+
protected function _beforeToHtml()
|
5 |
+
{
|
6 |
+
$this->setData('module_name','Mage_Catalog');
|
7 |
+
}
|
8 |
+
|
9 |
+
public function setProduct($product)
|
10 |
+
{
|
11 |
+
$this->setData('product', $product);
|
12 |
+
return $this;
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* $excludeAttr is optional array of attribute codes to
|
17 |
+
* exclude them from additional data array
|
18 |
+
*
|
19 |
+
* @param array $excludeAttr
|
20 |
+
* @return array
|
21 |
+
*/
|
22 |
+
public function getAdditionalData(array $excludeAttr = array())
|
23 |
+
{
|
24 |
+
$data = array();
|
25 |
+
$product = $this->getProduct();
|
26 |
+
$attributes = $product->getAttributes();
|
27 |
+
foreach ($attributes as $attribute) {
|
28 |
+
// if ($attribute->getIsVisibleOnFront() && $attribute->getIsUserDefined() && !in_array($attribute->getAttributeCode(), $excludeAttr)) {
|
29 |
+
if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), $excludeAttr)) {
|
30 |
+
$value = $attribute->getFrontend()->getValue($product);
|
31 |
+
|
32 |
+
if (!$product->hasData($attribute->getAttributeCode())) {
|
33 |
+
$value = Mage::helper('catalog')->__('N/A');
|
34 |
+
} elseif ((string)$value == '') {
|
35 |
+
$value = Mage::helper('catalog')->__('No');
|
36 |
+
} elseif ($attribute->getFrontendInput() == 'price' && is_string($value)) {
|
37 |
+
$value = Mage::app()->getStore()->convertPrice($value, true);
|
38 |
+
}
|
39 |
+
|
40 |
+
if (is_string($value) && strlen($value)) {
|
41 |
+
$data[$attribute->getAttributeCode()] = array(
|
42 |
+
'label' => $attribute->getStoreLabel(),
|
43 |
+
'value' => $value,
|
44 |
+
'code' => $attribute->getAttributeCode()
|
45 |
+
);
|
46 |
+
}
|
47 |
+
}
|
48 |
+
}
|
49 |
+
return $data;
|
50 |
+
}
|
51 |
+
}
|
app/code/local/Inic/Configurableoption/Block/Product/View/Type/Configurable.php
CHANGED
@@ -48,16 +48,182 @@ class Inic_Configurableoption_Block_Product_View_Type_Configurable extends Mage_
|
|
48 |
*/
|
49 |
protected $_resPrices = array();
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
|
63 |
|
48 |
*/
|
49 |
protected $_resPrices = array();
|
50 |
|
51 |
+
/**
|
52 |
+
* Composes configuration for js
|
53 |
+
*
|
54 |
+
* @return string
|
55 |
+
*/
|
56 |
+
public function getJsonConfig()
|
57 |
+
{
|
58 |
+
$attributes = array();
|
59 |
+
$options = array();
|
60 |
+
$store = $this->getCurrentStore();
|
61 |
+
$taxHelper = Mage::helper('tax');
|
62 |
+
$currentProduct = $this->getProduct();
|
63 |
+
|
64 |
+
$preconfiguredFlag = $currentProduct->hasPreconfiguredValues();
|
65 |
+
if ($preconfiguredFlag) {
|
66 |
+
$preconfiguredValues = $currentProduct->getPreconfiguredValues();
|
67 |
+
$defaultValues = array();
|
68 |
+
}
|
69 |
+
|
70 |
+
foreach ($this->getAllowProducts() as $product) {
|
71 |
+
$productId = $product->getId();
|
72 |
+
$product = Mage::getModel('catalog/product')->load($productId);
|
73 |
+
/* start by custom */
|
74 |
+
$childProducts[$productId] = array(
|
75 |
+
"price" => $this->_registerJsPrice($this->_convertPrice($product->getPrice())),
|
76 |
+
"finalPrice" => $this->_registerJsPrice($this->_convertPrice($product->getFinalPrice()))
|
77 |
+
);
|
78 |
+
|
79 |
+
$childProducts[$productId]["productName"] = $product->getName();
|
80 |
+
$childProducts[$productId]["description"] = $product->getDescription();
|
81 |
+
$childProducts[$productId]["shortDescription"] = $product->getShortDescription();
|
82 |
+
|
83 |
+
$childBlock = $this->getLayout()->createBlock('configurableoption/additionaldata');
|
84 |
+
$childProducts[$productId]["productAttributes"] = $childBlock->setProduct($product)->setTemplate('catalog/product/view/attributes.phtml')->toHtml();
|
85 |
+
#If image is not placeholder...
|
86 |
+
if ($product->getImage() && $product->getImage() !== 'no_selection') {
|
87 |
+
$childProducts[$productId]["imageUrl"] = (string) Mage::helper('catalog/image')->init($product, 'image')->resize(600, 900);
|
88 |
+
}
|
89 |
+
/* end by custom */
|
90 |
+
|
91 |
+
foreach ($this->getAllowAttributes() as $attribute) {
|
92 |
+
$productAttribute = $attribute->getProductAttribute();
|
93 |
+
$productAttributeId = $productAttribute->getId();
|
94 |
+
$attributeValue = $product->getData($productAttribute->getAttributeCode());
|
95 |
+
if (!isset($options[$productAttributeId])) {
|
96 |
+
$options[$productAttributeId] = array();
|
97 |
+
}
|
98 |
+
|
99 |
+
if (!isset($options[$productAttributeId][$attributeValue])) {
|
100 |
+
$options[$productAttributeId][$attributeValue] = array();
|
101 |
+
}
|
102 |
+
$options[$productAttributeId][$attributeValue][] = $productId;
|
103 |
+
}
|
104 |
}
|
105 |
+
|
106 |
+
$this->_resPrices = array(
|
107 |
+
$this->_preparePrice($currentProduct->getFinalPrice())
|
108 |
+
);
|
109 |
+
|
110 |
+
foreach ($this->getAllowAttributes() as $attribute) {
|
111 |
+
$productAttribute = $attribute->getProductAttribute();
|
112 |
+
$attributeId = $productAttribute->getId();
|
113 |
+
$info = array(
|
114 |
+
'id' => $productAttribute->getId(),
|
115 |
+
'code' => $productAttribute->getAttributeCode(),
|
116 |
+
'label' => $attribute->getLabel(),
|
117 |
+
'options' => array()
|
118 |
+
);
|
119 |
+
|
120 |
+
$optionPrices = array();
|
121 |
+
$prices = $attribute->getPrices();
|
122 |
+
if (is_array($prices)) {
|
123 |
+
foreach ($prices as $value) {
|
124 |
+
if(!$this->_validateAttributeValue($attributeId, $value, $options)) {
|
125 |
+
continue;
|
126 |
+
}
|
127 |
+
$currentProduct->setConfigurablePrice(
|
128 |
+
$this->_preparePrice($value['pricing_value'], $value['is_percent'])
|
129 |
+
);
|
130 |
+
$currentProduct->setParentId(true);
|
131 |
+
Mage::dispatchEvent(
|
132 |
+
'catalog_product_type_configurable_price',
|
133 |
+
array('product' => $currentProduct)
|
134 |
+
);
|
135 |
+
$configurablePrice = $currentProduct->getConfigurablePrice();
|
136 |
+
|
137 |
+
if (isset($options[$attributeId][$value['value_index']])) {
|
138 |
+
$productsIndex = $options[$attributeId][$value['value_index']];
|
139 |
+
} else {
|
140 |
+
$productsIndex = array();
|
141 |
+
}
|
142 |
+
|
143 |
+
$info['options'][] = array(
|
144 |
+
'id' => $value['value_index'],
|
145 |
+
'label' => $value['label'],
|
146 |
+
'price' => $configurablePrice,
|
147 |
+
'oldPrice' => $this->_prepareOldPrice($value['pricing_value'], $value['is_percent']),
|
148 |
+
'products' => $productsIndex,
|
149 |
+
);
|
150 |
+
$optionPrices[] = $configurablePrice;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
/**
|
154 |
+
* Prepare formated values for options choose
|
155 |
+
*/
|
156 |
+
foreach ($optionPrices as $optionPrice) {
|
157 |
+
foreach ($optionPrices as $additional) {
|
158 |
+
$this->_preparePrice(abs($additional-$optionPrice));
|
159 |
+
}
|
160 |
+
}
|
161 |
+
if($this->_validateAttributeInfo($info)) {
|
162 |
+
$attributes[$attributeId] = $info;
|
163 |
+
}
|
164 |
+
|
165 |
+
// Add attribute default value (if set)
|
166 |
+
if ($preconfiguredFlag) {
|
167 |
+
$configValue = $preconfiguredValues->getData('super_attribute/' . $attributeId);
|
168 |
+
if ($configValue) {
|
169 |
+
$defaultValues[$attributeId] = $configValue;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
$taxCalculation = Mage::getSingleton('tax/calculation');
|
175 |
+
if (!$taxCalculation->getCustomer() && Mage::registry('current_customer')) {
|
176 |
+
$taxCalculation->setCustomer(Mage::registry('current_customer'));
|
177 |
+
}
|
178 |
+
|
179 |
+
$_request = $taxCalculation->getDefaultRateRequest();
|
180 |
+
$_request->setProductClassId($currentProduct->getTaxClassId());
|
181 |
+
$defaultTax = $taxCalculation->getRate($_request);
|
182 |
+
|
183 |
+
$_request = $taxCalculation->getRateRequest();
|
184 |
+
$_request->setProductClassId($currentProduct->getTaxClassId());
|
185 |
+
$currentTax = $taxCalculation->getRate($_request);
|
186 |
+
|
187 |
+
$taxConfig = array(
|
188 |
+
'includeTax' => $taxHelper->priceIncludesTax(),
|
189 |
+
'showIncludeTax' => $taxHelper->displayPriceIncludingTax(),
|
190 |
+
'showBothPrices' => $taxHelper->displayBothPrices(),
|
191 |
+
'defaultTax' => $defaultTax,
|
192 |
+
'currentTax' => $currentTax,
|
193 |
+
'inclTaxTitle' => Mage::helper('catalog')->__('Incl. Tax')
|
194 |
+
);
|
195 |
+
|
196 |
+
$config = array(
|
197 |
+
'attributes' => $attributes,
|
198 |
+
'template' => str_replace('%s', '#{price}', $store->getCurrentCurrency()->getOutputFormat()),
|
199 |
+
'basePrice' => $this->_registerJsPrice($this->_convertPrice($currentProduct->getFinalPrice())),
|
200 |
+
'oldPrice' => $this->_registerJsPrice($this->_convertPrice($currentProduct->getPrice())),
|
201 |
+
'productId' => $currentProduct->getId(),
|
202 |
+
'chooseText' => Mage::helper('catalog')->__('Choose an Option...'),
|
203 |
+
'taxConfig' => $taxConfig
|
204 |
+
);
|
205 |
+
|
206 |
+
if ($preconfiguredFlag && !empty($defaultValues)) {
|
207 |
+
$config['defaultValues'] = $defaultValues;
|
208 |
+
}
|
209 |
+
|
210 |
+
/* start by custom */
|
211 |
+
$config['productName'] = $this->getProduct()->getName();
|
212 |
+
$config['description'] = $this->getProduct()->getDescription();
|
213 |
+
$config['shortDescription'] = $this->getProduct()->getShortDescription();
|
214 |
+
if (Mage::helper('catalog/image')->init($this->getProduct(), 'image') !== 'no_selection') {
|
215 |
+
$config["imageUrl"] = (string) Mage::helper('catalog/image')->init($this->getProduct(), 'image')->resize(600, 900);
|
216 |
+
}
|
217 |
+
$childBlock = $this->getLayout()->createBlock('configurableoption/additionaldata');
|
218 |
+
$config["productAttributes"] = $childBlock->setTemplate('catalog/product/view/attributes.phtml')
|
219 |
+
->setProduct($this->getProduct())
|
220 |
+
->toHtml();
|
221 |
+
$config['childProducts'] = $childProducts;
|
222 |
+
/* end by custom */
|
223 |
+
|
224 |
+
$config = array_merge($config, $this->_getAdditionalConfig());
|
225 |
+
|
226 |
+
return Zend_Json::encode($config);
|
227 |
}
|
228 |
|
229 |
|
app/code/local/Inic/Configurableoption/etc/config.xml
CHANGED
@@ -2,19 +2,24 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Inic_Configurableoption>
|
5 |
-
<version>0.1.
|
6 |
</Inic_Configurableoption>
|
7 |
</modules>
|
8 |
<frontend>
|
9 |
<layout>
|
10 |
<updates>
|
11 |
<configurableoption>
|
12 |
-
<file>
|
13 |
</configurableoption>
|
14 |
</updates>
|
15 |
</layout>
|
16 |
</frontend>
|
17 |
<global>
|
|
|
|
|
|
|
|
|
|
|
18 |
<blocks>
|
19 |
<catalog>
|
20 |
<rewrite>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Inic_Configurableoption>
|
5 |
+
<version>0.1.1</version>
|
6 |
</Inic_Configurableoption>
|
7 |
</modules>
|
8 |
<frontend>
|
9 |
<layout>
|
10 |
<updates>
|
11 |
<configurableoption>
|
12 |
+
<file>configurableoption.xml</file>
|
13 |
</configurableoption>
|
14 |
</updates>
|
15 |
</layout>
|
16 |
</frontend>
|
17 |
<global>
|
18 |
+
<blocks>
|
19 |
+
<configurableoption>
|
20 |
+
<class>Inic_Configurableoption_Block</class>
|
21 |
+
</configurableoption>
|
22 |
+
</blocks>
|
23 |
<blocks>
|
24 |
<catalog>
|
25 |
<rewrite>
|
app/design/frontend/default/default/layout/Configurableoption.xml
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<layout version="0.1.0">
|
3 |
-
<catalog_product_view>
|
4 |
-
<reference name="head">
|
5 |
-
<action method="addJs" ifconfig="catalog/configurable_pro/enabled"><script>configurableoption/configure.js</script></action>
|
6 |
-
</reference>
|
7 |
-
</catalog_product_view>
|
8 |
-
<PRODUCT_TYPE_configurable>
|
9 |
-
<reference name="product.info.options.configurable">
|
10 |
-
<action method="setTemplate" ifconfig="catalog/configurable_pro/enabled">
|
11 |
-
<template>configurableoption/catalog/product/view/type/options/configurable.phtml</template>
|
12 |
-
</action>
|
13 |
-
</reference>
|
14 |
-
</PRODUCT_TYPE_configurable>
|
15 |
-
</layout>
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/default/default/layout/configurableoption.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<catalog_product_view>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addJs" ifconfig="catalog/configurable_pro/enabled"><script>configurableoption/configure.js</script></action>
|
6 |
+
</reference>
|
7 |
+
</catalog_product_view>
|
8 |
+
</layout>
|
9 |
+
|
app/design/frontend/default/default/template/Configurableoption/catalog/product/view/type/options/configurable.phtml
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-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 design
|
22 |
-
* @package base_default
|
23 |
-
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
-
*/
|
26 |
-
?>
|
27 |
-
|
28 |
-
<?php
|
29 |
-
|
30 |
-
$_product = $this->getProduct();
|
31 |
-
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
|
32 |
-
?>
|
33 |
-
<?php if ($_product->isSaleable() && count($_attributes)):?>
|
34 |
-
<dl>
|
35 |
-
<?php foreach($_attributes as $_attribute): ?>
|
36 |
-
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
|
37 |
-
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
|
38 |
-
<div class="input-box">
|
39 |
-
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
|
40 |
-
<option><?php echo $this->__('Choose an Option...') ?></option>
|
41 |
-
</select>
|
42 |
-
</div>
|
43 |
-
</dd>
|
44 |
-
<?php endforeach; ?>
|
45 |
-
</dl>
|
46 |
-
<script type="text/javascript">
|
47 |
-
var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
|
48 |
-
var assocIMG = <?php echo $this->getAssociatedImages() ?>
|
49 |
-
</script>
|
50 |
-
<?php endif;?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/configurableoption/configure.js
CHANGED
@@ -3,66 +3,179 @@ if(typeof selectedAssocProducts=='undefined') {
|
|
3 |
}
|
4 |
if (typeof Product.Config != 'undefined') {
|
5 |
Product.Config.addMethods({
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
15 |
}
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
-
this.
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
}
|
4 |
if (typeof Product.Config != 'undefined') {
|
5 |
Product.Config.addMethods({
|
6 |
+
|
7 |
+
});
|
8 |
+
}
|
9 |
+
|
10 |
+
/*
|
11 |
+
Some of these override earlier varien/product.js methods, therefore
|
12 |
+
varien/product.js must have been included prior to this file.
|
13 |
+
*/
|
14 |
+
|
15 |
+
|
16 |
+
Product.Config.prototype.getMatchingSimpleProduct = function(){
|
17 |
+
var inScopeProductIds = this.getInScopeProductIds();
|
18 |
+
if ((typeof inScopeProductIds != 'undefined') && (inScopeProductIds.length == 1)) {
|
19 |
+
return inScopeProductIds[0];
|
20 |
+
}
|
21 |
+
return false;
|
22 |
+
};
|
23 |
+
|
24 |
+
/*
|
25 |
+
Find products which are within consideration based on user's selection of
|
26 |
+
config options so far
|
27 |
+
Returns a normal array containing product ids
|
28 |
+
allowedProducts is a normal numeric array containing product ids.
|
29 |
+
childProducts is a hash keyed on product id
|
30 |
+
optionalAllowedProducts lets you pass a set of products to restrict by,
|
31 |
+
in addition to just using the ones already selected by the user
|
32 |
+
*/
|
33 |
+
Product.Config.prototype.getInScopeProductIds = function(optionalAllowedProducts) {
|
34 |
+
|
35 |
+
var childProducts = this.config.childProducts;
|
36 |
+
var allowedProducts = [];
|
37 |
+
|
38 |
+
if ((typeof optionalAllowedProducts != 'undefined') && (optionalAllowedProducts.length > 0)) {
|
39 |
+
// alert("starting with: " + optionalAllowedProducts.inspect());
|
40 |
+
allowedProducts = optionalAllowedProducts;
|
41 |
+
}
|
42 |
+
|
43 |
+
for(var s=0, len=this.settings.length-1; s<=len; s++) {
|
44 |
+
if (this.settings[s].selectedIndex <= 0){
|
45 |
+
break;
|
46 |
+
}
|
47 |
+
var selected = this.settings[s].options[this.settings[s].selectedIndex];
|
48 |
+
if (s==0 && allowedProducts.length == 0){
|
49 |
+
allowedProducts = selected.config.allowedProducts;
|
50 |
+
} else {
|
51 |
+
// alert("merging: " + allowedProducts.inspect() + " with: " + selected.config.allowedProducts.inspect());
|
52 |
+
allowedProducts = allowedProducts.intersect(selected.config.allowedProducts).uniq();
|
53 |
+
// alert("to give: " + allowedProducts.inspect());
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
//If we can't find any products (because nothing's been selected most likely)
|
58 |
+
//then just use all product ids.
|
59 |
+
if ((typeof allowedProducts == 'undefined') || (allowedProducts.length == 0)) {
|
60 |
+
productIds = Object.keys(childProducts);
|
61 |
+
} else {
|
62 |
+
productIds = allowedProducts;
|
63 |
+
}
|
64 |
+
return productIds;
|
65 |
+
};
|
66 |
+
|
67 |
+
|
68 |
+
|
69 |
+
Product.Config.prototype.reloadPrice = function(){
|
70 |
+
if (this.config.disablePriceReload) {
|
71 |
+
return;
|
72 |
+
}
|
73 |
+
var childProductId = this.getMatchingSimpleProduct();
|
74 |
+
var childProducts = this.config.childProducts;
|
75 |
+
var price = 0;
|
76 |
+
var oldPrice = 0;
|
77 |
+
for(var i=this.settings.length-1;i>=0;i--){
|
78 |
+
var selected = this.settings[i].options[this.settings[i].selectedIndex];
|
79 |
+
if(selected.config){
|
80 |
+
price += parseFloat(selected.config.price);
|
81 |
+
oldPrice += parseFloat(selected.config.oldPrice);
|
82 |
}
|
83 |
}
|
84 |
+
|
85 |
+
if (childProductId){
|
86 |
+
this.updateProductName(childProductId);
|
87 |
+
this.updateProductShortDescription(childProductId);
|
88 |
+
this.updateProductDescription(childProductId);
|
89 |
+
this.updateProductAttributes(childProductId);
|
90 |
+
this.updateProductImage(childProductId);
|
91 |
+
|
92 |
+
} else {
|
93 |
+
this.updateProductName(false);
|
94 |
+
this.updateProductShortDescription(false);
|
95 |
+
this.updateProductDescription(false);
|
96 |
+
this.updateProductAttributes(false);
|
97 |
+
this.updateProductImage(false);
|
98 |
+
}
|
99 |
+
|
100 |
+
optionsPrice.changePrice('config', {'price': price, 'oldPrice': oldPrice});
|
101 |
+
optionsPrice.reload();
|
102 |
+
return price;
|
103 |
+
|
104 |
+
if($('product-price-'+this.config.productId)){
|
105 |
+
$('product-price-'+this.config.productId).innerHTML = price;
|
106 |
}
|
107 |
+
this.reloadOldPrice();
|
108 |
+
|
109 |
+
|
110 |
+
};
|
111 |
+
|
112 |
+
Product.Config.prototype.updateProductShortDescription = function(productId) {
|
113 |
+
var shortDescription = this.config.shortDescription;
|
114 |
+
if (productId && this.config.childProducts[productId].shortDescription) {
|
115 |
+
shortDescription = this.config.childProducts[productId].shortDescription;
|
116 |
+
}
|
117 |
+
$$('#product_addtocart_form div.short-description div.std').each(function(el) {
|
118 |
+
el.innerHTML = shortDescription;
|
119 |
+
});
|
120 |
+
};
|
121 |
+
|
122 |
+
Product.Config.prototype.updateProductDescription = function(productId) {
|
123 |
+
var description = this.config.description;
|
124 |
+
if (productId && this.config.childProducts[productId].description) {
|
125 |
+
description = this.config.childProducts[productId].description;
|
126 |
}
|
127 |
+
|
128 |
+
$$('div.box-description div.std').each(function(el) {
|
129 |
+
el.innerHTML = description;
|
130 |
+
});
|
131 |
+
|
132 |
+
};
|
133 |
+
|
134 |
+
Product.Config.prototype.updateProductAttributes = function(productId) {
|
135 |
+
var productAttributes = this.config.productAttributes;
|
136 |
+
if (productId && this.config.childProducts[productId].productAttributes) {
|
137 |
+
productAttributes = this.config.childProducts[productId].productAttributes;
|
138 |
+
}
|
139 |
+
//If config product doesn't already have an additional information section,
|
140 |
+
//it won't be shown for associated product either. It's too hard to work out
|
141 |
+
//where to place it given that different themes use very different html here
|
142 |
+
|
143 |
+
$$('div.product-collateral div.box-additional').each(function(el) {
|
144 |
+
el.innerHTML = productAttributes;
|
145 |
+
decorateTable('product-attribute-specs-table');
|
146 |
+
});
|
147 |
+
|
148 |
+
};
|
149 |
+
|
150 |
+
Product.Config.prototype.updateProductName = function(productId) {
|
151 |
+
var productName = this.config.productName;
|
152 |
+
if (productId && this.config.childProducts[productId].productName) {
|
153 |
+
productName = this.config.childProducts[productId].productName;
|
154 |
+
}
|
155 |
+
$$('#product_addtocart_form div.product-name h1').each(function(el) {
|
156 |
+
el.innerHTML = productName;
|
157 |
+
});
|
158 |
+
};
|
159 |
+
|
160 |
+
Product.Config.prototype.updateProductImage = function(productId) {
|
161 |
+
var imageUrl = this.config.imageUrl;
|
162 |
+
|
163 |
+
if(productId && this.config.childProducts[productId].imageUrl) {
|
164 |
+
imageUrl = this.config.childProducts[productId].imageUrl;
|
165 |
+
}
|
166 |
+
|
167 |
+
if (!imageUrl) {
|
168 |
+
return;
|
169 |
+
}
|
170 |
+
|
171 |
+
if($('img')) {
|
172 |
+
$('img').src = imageUrl;
|
173 |
+
} else {
|
174 |
+
$$('p.product-image img').each(function(el) {
|
175 |
+
var dims = el.getDimensions();
|
176 |
+
el.src = imageUrl;
|
177 |
+
el.width = dims.width;
|
178 |
+
el.height = dims.height;
|
179 |
+
});
|
180 |
+
}
|
181 |
+
};
|
package.xml
CHANGED
@@ -1,18 +1,28 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Inic_Configure</name>
|
4 |
-
<version>0.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>This extension allow you to display simple product's images
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
<compatible/>
|
17 |
-
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Inic_Configure</name>
|
4 |
+
<version>0.1.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Display simple products images and other info on configurable product's detail page </summary>
|
10 |
+
<description>This extension allow you to display simple product's images even name,description, short description and additional information on change options of configurable products, 
|
11 |
+

|
12 |
+
After installed extension, go to admin panel, clear cache if enabled after go to System->configuration->CATALOG->Catalog->Configurable Product's Image Enable as "yes" from there.
|
13 |
+

|
14 |
+
Now go to frontend and reach at configurable product detail page after try to change options on this products detail page. 
|
15 |
+

|
16 |
+
Which options you will select, same simple product image replaced with main image. Also product name,decription,short description and additional info replaced with main product info.
|
17 |
+

|
18 |
+
This extension work for only configurable products. 
|
19 |
+

|
20 |
+
Note : This extension will not work with rwd default theme of magento</description>
|
21 |
+
<notes>Next Beta version release</notes>
|
22 |
+
<authors><author><name>ps</name><user>ps_patel</user><email>pspatel5101987@gmail.com</email></author></authors>
|
23 |
+
<date>2015-05-27</date>
|
24 |
+
<time>06:19:47</time>
|
25 |
+
<contents><target name="magelocal"><dir name="Inic"><dir name="Configurableoption"><dir name="Block"><file name="Additionaldata.php" hash="0d6c2cc23df6b30284d340edfbc99e94"/><dir name="Product"><dir name="View"><dir name="Type"><file name="Configurable.php" hash="e979d7b6e4feb68412d9008b44b1b0bd"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="2d0ed955c469a25827bb85a6548b39f8"/><file name="system.xml" hash="f6c9e0cfb6198c54f0e7f4234ec156b3"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="configurableoption.xml" hash="4e2590c14ae97290f0777795c0cb29b6"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Inic_Configurableoption.xml" hash="2357b155b96058ec3934b381d0590367"/></dir></target><target name="mage"><dir name="."><dir name="js"><dir name="configurableoption"><file name="configure.js" hash="a6c7fc27c492e12c453a33aa48653cb2"/></dir></dir></dir></target></contents>
|
26 |
<compatible/>
|
27 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.7</max></package><extension><name>gd</name><min>2.0.28</min><max>3.0</max></extension></required></dependencies>
|
28 |
</package>
|