Version Notes
This extension working for only configurable products
Download this release
Release Info
Developer | ps_patel |
Extension | Inic_Configure |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/local/Inic/Configurableoption/Block/Product/View/Type/Configurable.php +65 -0
- app/code/local/Inic/Configurableoption/etc/config.xml +26 -0
- app/code/local/Inic/Configurableoption/etc/system.xml +29 -0
- app/design/frontend/default/default/layout/Configurableoption.xml +16 -0
- app/design/frontend/default/default/template/Configurableoption/catalog/product/view/type/options/configurable.phtml +50 -0
- app/etc/modules/Inic_Configurableoption.xml +9 -0
- js/configurableoption/configure.js +68 -0
- package.xml +18 -0
app/code/local/Inic/Configurableoption/Block/Product/View/Type/Configurable.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Catalog
|
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 |
+
/**
|
29 |
+
* Catalog super product configurable part block
|
30 |
+
*
|
31 |
+
* @category Mage
|
32 |
+
* @package Mage_Catalog
|
33 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
+
*/
|
35 |
+
class Inic_Configurableoption_Block_Product_View_Type_Configurable extends Mage_Catalog_Block_Product_View_Type_Configurable
|
36 |
+
{
|
37 |
+
/**
|
38 |
+
* Prices
|
39 |
+
*
|
40 |
+
* @var array
|
41 |
+
*/
|
42 |
+
protected $_prices = array();
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Prepared prices
|
46 |
+
*
|
47 |
+
* @var array
|
48 |
+
*/
|
49 |
+
protected $_resPrices = array();
|
50 |
+
|
51 |
+
/* Preapard simple product's image urls array which is associated with configurable products */
|
52 |
+
public function getAssociatedImages(){
|
53 |
+
$_simpleProducts = array();
|
54 |
+
foreach ($this->getAllowProducts() as $product) {
|
55 |
+
if($product->getImage() != 'no_selection' && $product->getImage() != '') {
|
56 |
+
$_simpleProducts[$product->getId()] = (string)Mage::helper('catalog/image')->init($product, 'image')->resize(265);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
$js_array = json_encode($_simpleProducts);
|
60 |
+
return $js_array;
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
|
65 |
+
}
|
app/code/local/Inic/Configurableoption/etc/config.xml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Inic_Configurableoption>
|
5 |
+
<version>0.1.0</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 |
+
<catalog>
|
20 |
+
<rewrite>
|
21 |
+
<product_view_type_configurable>Inic_Configurableoption_Block_Product_View_Type_Configurable</product_view_type_configurable>
|
22 |
+
</rewrite>
|
23 |
+
</catalog>
|
24 |
+
</blocks>
|
25 |
+
</global>
|
26 |
+
</config>
|
app/code/local/Inic/Configurableoption/etc/system.xml
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<catalog>
|
5 |
+
<groups>
|
6 |
+
<configurable_pro translate="label">
|
7 |
+
<label>Configurable Product's Image</label>
|
8 |
+
<frontend_type>text</frontend_type>
|
9 |
+
<sort_order>2000</sort_order>
|
10 |
+
<show_in_default>1</show_in_default>
|
11 |
+
<show_in_website>1</show_in_website>
|
12 |
+
<show_in_store>1</show_in_store>
|
13 |
+
<fields>
|
14 |
+
<enabled translate="label">
|
15 |
+
<label>Enable</label>
|
16 |
+
<comment>change images as per selected configuable's product's option if enabled </comment>
|
17 |
+
<frontend_type>select</frontend_type>
|
18 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
19 |
+
<sort_order>10</sort_order>
|
20 |
+
<show_in_default>1</show_in_default>
|
21 |
+
<show_in_website>1</show_in_website>
|
22 |
+
<show_in_store>1</show_in_store>
|
23 |
+
</enabled>
|
24 |
+
</fields>
|
25 |
+
</configurable_pro>
|
26 |
+
</groups>
|
27 |
+
</catalog>
|
28 |
+
</sections>
|
29 |
+
</config>
|
app/design/frontend/default/default/layout/Configurableoption.xml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/template/Configurableoption/catalog/product/view/type/options/configurable.phtml
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;?>
|
app/etc/modules/Inic_Configurableoption.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Inic_Configurableoption>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Inic_Configurableoption>
|
8 |
+
</modules>
|
9 |
+
</config>
|
js/configurableoption/configure.js
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
if(typeof selectedAssocProducts=='undefined') {
|
2 |
+
var selectedAssocProducts = {};
|
3 |
+
}
|
4 |
+
if (typeof Product.Config != 'undefined') {
|
5 |
+
Product.Config.addMethods({
|
6 |
+
configureElement : function(element) {
|
7 |
+
this.reloadOptionLabels(element);
|
8 |
+
if(element.value){
|
9 |
+
this.state[element.config.id] = element.value;
|
10 |
+
if(element.nextSetting){
|
11 |
+
element.nextSetting.disabled = false;
|
12 |
+
this.fillSelect(element.nextSetting);
|
13 |
+
this.resetChildren(element.nextSetting);
|
14 |
+
}
|
15 |
+
}
|
16 |
+
else {
|
17 |
+
this.resetChildren(element);
|
18 |
+
}
|
19 |
+
this.reloadPrice();
|
20 |
+
if (!element.value || element.value.substr(0,6) == 'choose') return; // Selected "choose option"
|
21 |
+
var attributeId = element.id.replace(/[a-z]*/, '');
|
22 |
+
for (var a in this.config.attributes)
|
23 |
+
{
|
24 |
+
for (i = 0; i < this.config.attributes[a].options.length; i++)
|
25 |
+
{
|
26 |
+
if (this.config.attributes[a].options[i].id != element.value) continue;
|
27 |
+
selectedAssocProducts[a] = this.config.attributes[attributeId].options[i].products;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
var productNo = intersect(selectedAssocProducts) || selectedAssocProducts[attributeId][0];
|
31 |
+
if(assocIMG[productNo])
|
32 |
+
$('image').src = assocIMG[productNo]; //change your image id here if its not as per default
|
33 |
+
}
|
34 |
+
});
|
35 |
+
function intersect(ar) // ar can be an array of arrays or an asssociative array
|
36 |
+
{
|
37 |
+
if (ar == null) return false;
|
38 |
+
var a = new Array();
|
39 |
+
if (ar.length == undefined) // Associate Array
|
40 |
+
{
|
41 |
+
for (var i in ar)
|
42 |
+
a.push(ar[i]);
|
43 |
+
}
|
44 |
+
else
|
45 |
+
a = ar;
|
46 |
+
if (a.length == 1) return false; // Single array ? Nothing to intersect with
|
47 |
+
var common = new Array();
|
48 |
+
function loop(a, index, s_index, e_index)
|
49 |
+
{
|
50 |
+
if (index == null) index = 0;
|
51 |
+
if (s_index == null) s_index = 0;
|
52 |
+
if (e_index == null) e_index = a[index].length;
|
53 |
+
if (index == a.length - 1) return;
|
54 |
+
for (var i = s_index; i < e_index; i++)
|
55 |
+
{
|
56 |
+
if (common.indexOf(a[index][i]) != -1) continue;
|
57 |
+
for (var j = 0; j < a[index + 1].length; j++)
|
58 |
+
{
|
59 |
+
if (a[index][i] != a[index+1][j]) continue;
|
60 |
+
loop(a, index + 1, j, j + 1);
|
61 |
+
if (index + 1 == a.length - 1) { common.push(a[index][i]); break; }
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
65 |
+
loop(a);
|
66 |
+
return common;
|
67 |
+
}
|
68 |
+
}
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Inic_Configure</name>
|
4 |
+
<version>0.1.0</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>This extension working for only configurable products</summary>
|
10 |
+
<description>This extension allow you to display simple product's images on configurable product's detail page on change selected their options</description>
|
11 |
+
<notes>This extension working for only configurable products</notes>
|
12 |
+
<authors><author><name>ps_patel</name><user>ps_patel</user><email>pspatel5101987@gmail.com</email></author></authors>
|
13 |
+
<date>2013-10-23</date>
|
14 |
+
<time>08:58:01</time>
|
15 |
+
<contents><target name="magelocal"><dir name="Inic"><dir name="Configurableoption"><dir name="Block"><dir name="Product"><dir name="View"><dir name="Type"><file name="Configurable.php" hash="edbd3bca622ad1dd61f41111ed7c5462"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="99c56548579b7dd9716fc3f2189046c2"/><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="7aeb5683c1fb132836f41fdc09cf7922"/></dir><dir name="template"><dir name="Configurableoption"><dir name="catalog"><dir name="product"><dir name="view"><dir name="type"><dir name="options"><file name="configurable.phtml" hash="aa0b1d8804afd9c85eab77b1982ddb9d"/></dir></dir></dir></dir></dir></dir></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="js"><dir name="configurableoption"><file name="configure.js" hash="c89160bab9f1fc7e89bb01cb43c666b0"/></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|