Version Notes
First Release - 09/02/2011
Download this release
Release Info
Developer | Magento Core Team |
Extension | Gala_Colorswatches |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/EM/Colorswatches/Block/Settings.php +26 -0
- app/code/community/EM/Colorswatches/Helper/Data.php +6 -0
- app/code/community/EM/Colorswatches/etc/config.xml +98 -0
- app/code/community/EM/Colorswatches/etc/system.xml +74 -0
- app/design/frontend/base/default/layout/em_colorswatches.xml +47 -0
- app/design/frontend/base/default/template/em_colorswatches/settings.phtml +79 -0
- app/etc/modules/EM_Colorswatches.xml +9 -0
- media/colors_watches/10.jpg +0 -0
- media/colors_watches/105.jpg +0 -0
- media/colors_watches/11.jpg +0 -0
- media/colors_watches/12.jpg +0 -0
- media/colors_watches/9.jpg +0 -0
- media/colors_watches/95.jpg +0 -0
- media/colors_watches/color-black.png +0 -0
- media/colors_watches/color-yellow.png +0 -0
- package.xml +18 -0
app/code/community/EM/Colorswatches/Block/Settings.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EM_Colorswatches_Block_Settings extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
|
5 |
+
|
6 |
+
public function get_option_swatches() {
|
7 |
+
return $this->parse_swatches(Mage::getStoreConfig('colorswatches/image/option_swatches'));
|
8 |
+
}
|
9 |
+
|
10 |
+
protected function parse_swatches($s) {
|
11 |
+
$swatches = array();
|
12 |
+
if ($s) {
|
13 |
+
if (preg_match_all("/^(.*)\:(.*)=(.*)$/m", $s, $m, PREG_SET_ORDER)) {
|
14 |
+
foreach ($m as $_ln)
|
15 |
+
$swatches[] = array(
|
16 |
+
'key' => trim($_ln[1]),
|
17 |
+
'value' => trim($_ln[2]),
|
18 |
+
'img' => trim($_ln[3])
|
19 |
+
);
|
20 |
+
}
|
21 |
+
}
|
22 |
+
return $swatches;
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
}
|
app/code/community/EM/Colorswatches/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EM_Colorswatches_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/community/EM/Colorswatches/etc/config.xml
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<EM_Colorswatches>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</EM_Colorswatches>
|
7 |
+
</modules>
|
8 |
+
<adminhtml>
|
9 |
+
<acl>
|
10 |
+
<resources>
|
11 |
+
<admin>
|
12 |
+
<children>
|
13 |
+
<system>
|
14 |
+
<children>
|
15 |
+
<config>
|
16 |
+
<children>
|
17 |
+
<colorswatches>
|
18 |
+
<title>Image Configure</title>
|
19 |
+
</colorswatches>
|
20 |
+
</children>
|
21 |
+
</config>
|
22 |
+
</children>
|
23 |
+
</system>
|
24 |
+
</children>
|
25 |
+
</admin>
|
26 |
+
</resources>
|
27 |
+
</acl>
|
28 |
+
</adminhtml>
|
29 |
+
|
30 |
+
<frontend>
|
31 |
+
<routers>
|
32 |
+
<colorswatches>
|
33 |
+
<use>standard</use>
|
34 |
+
<args>
|
35 |
+
<module>EM_Colorswatches</module>
|
36 |
+
<frontName>colorswatches</frontName>
|
37 |
+
</args>
|
38 |
+
</colorswatches>
|
39 |
+
</routers>
|
40 |
+
<layout>
|
41 |
+
<updates>
|
42 |
+
<colorswatches>
|
43 |
+
<file>em_colorswatches.xml</file>
|
44 |
+
</colorswatches>
|
45 |
+
</updates>
|
46 |
+
</layout>
|
47 |
+
</frontend>
|
48 |
+
<admin>
|
49 |
+
<routers>
|
50 |
+
<colorswatches>
|
51 |
+
<use>admin</use>
|
52 |
+
<args>
|
53 |
+
<module>EM_Colorswatches</module>
|
54 |
+
<frontName>colorswatches</frontName>
|
55 |
+
</args>
|
56 |
+
</colorswatches>
|
57 |
+
</routers>
|
58 |
+
</admin>
|
59 |
+
<adminhtml>
|
60 |
+
|
61 |
+
<acl>
|
62 |
+
<resources>
|
63 |
+
<all>
|
64 |
+
<title>Allow Everything</title>
|
65 |
+
</all>
|
66 |
+
<admin>
|
67 |
+
<children>
|
68 |
+
<EM_Colorswatches>
|
69 |
+
<title>Colorswatches Module</title>
|
70 |
+
<sort_order>10</sort_order>
|
71 |
+
</EM_Colorswatches>
|
72 |
+
</children>
|
73 |
+
</admin>
|
74 |
+
</resources>
|
75 |
+
</acl>
|
76 |
+
<layout>
|
77 |
+
<updates>
|
78 |
+
<colorswatches>
|
79 |
+
<file>colorswatches.xml</file>
|
80 |
+
</colorswatches>
|
81 |
+
</updates>
|
82 |
+
</layout>
|
83 |
+
</adminhtml>
|
84 |
+
<global>
|
85 |
+
|
86 |
+
<blocks>
|
87 |
+
<colorswatches>
|
88 |
+
<class>EM_Colorswatches_Block</class>
|
89 |
+
</colorswatches>
|
90 |
+
</blocks>
|
91 |
+
<helpers>
|
92 |
+
<colorswatches>
|
93 |
+
<class>EM_Colorswatches_Helper</class>
|
94 |
+
</colorswatches>
|
95 |
+
</helpers>
|
96 |
+
</global>
|
97 |
+
|
98 |
+
</config>
|
app/code/community/EM/Colorswatches/etc/system.xml
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/afl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Mage
|
23 |
+
* @package Mage_Reports
|
24 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
25 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
26 |
+
*/
|
27 |
+
-->
|
28 |
+
<config>
|
29 |
+
<sections>
|
30 |
+
<colorswatches translate="label" module="colorswatches">
|
31 |
+
<label>Gala ColorSwatches Settings</label>
|
32 |
+
<tab>general</tab>
|
33 |
+
<frontend_type>text</frontend_type>
|
34 |
+
<sort_order>1000</sort_order>
|
35 |
+
<show_in_default>1</show_in_default>
|
36 |
+
<show_in_website>1</show_in_website>
|
37 |
+
<show_in_store>1</show_in_store>
|
38 |
+
<groups>
|
39 |
+
<image translate="label">
|
40 |
+
<label>Image Configure</label>
|
41 |
+
<frontend_type>text</frontend_type>
|
42 |
+
<sort_order>1</sort_order>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>1</show_in_website>
|
45 |
+
<show_in_store>1</show_in_store>
|
46 |
+
<fields>
|
47 |
+
<option_swatches translate="label comment">
|
48 |
+
<label>Custom Option Swatches</label>
|
49 |
+
<frontend_type>textarea</frontend_type>
|
50 |
+
<sort_order>26</sort_order>
|
51 |
+
<show_in_default>1</show_in_default>
|
52 |
+
<show_in_website>1</show_in_website>
|
53 |
+
<show_in_store>1</show_in_store>
|
54 |
+
<comment><![CDATA[
|
55 |
+
<p>Format: <em>[option label]</em> : <em>[option value]</em> = <em>[swatch image]</em></p>
|
56 |
+
<p>Example:</p>
|
57 |
+
<p>
|
58 |
+
Size : Small = size-small.png<br/>
|
59 |
+
Size : Medium = size-medium.png<br/>
|
60 |
+
Size : Large = size-large.png<br/>
|
61 |
+
Color : Red = color-red.png<br/>
|
62 |
+
Color : Green = color-medium.png<br/>
|
63 |
+
Color : Blue = color-blue.png<br/>
|
64 |
+
Color : Yellow = color-yellow.png<br/>
|
65 |
+
</p>
|
66 |
+
<p>Swatch images should be uploaded in <strong>media/color_swatches/</strong></p>
|
67 |
+
]]></comment>
|
68 |
+
</option_swatches>
|
69 |
+
</fields>
|
70 |
+
</image>
|
71 |
+
</groups>
|
72 |
+
</colorswatches>
|
73 |
+
</sections>
|
74 |
+
</config>
|
app/design/frontend/base/default/layout/em_colorswatches.xml
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/afl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category design
|
23 |
+
* @package base_default
|
24 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
25 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
-->
|
29 |
+
<layout version="0.1.0">
|
30 |
+
|
31 |
+
<!--
|
32 |
+
Default layout, loads most of the pages
|
33 |
+
-->
|
34 |
+
|
35 |
+
<catalog_product_view translate="label">
|
36 |
+
<reference name="product.info.options.wrapper">
|
37 |
+
<block type="colorswatches/settings" name="colorswatches.setting" template="em_colorswatches/settings.phtml"/>
|
38 |
+
</reference>
|
39 |
+
<reference name="before_body_end">
|
40 |
+
<block type="core/text" name="colorswatches.copy">
|
41 |
+
<action method="setText"><text><![CDATA[<p style="text-align:center;font-size:0.8em"><a style="color:inherit;text-decoration:none" href="http://galathemes.com/magento-extensions/color-swatches.html">Color Swatches Magento extension</a> by Galathemes <a style="color:inherit;text-decoration:none" href="http://galathemes.com/">Magento Themes</a></p>]]></text></action>
|
42 |
+
</block>
|
43 |
+
</reference>
|
44 |
+
</catalog_product_view>
|
45 |
+
|
46 |
+
|
47 |
+
</layout>
|
app/design/frontend/base/default/template/em_colorswatches/settings.phtml
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$swatches = $this->get_option_swatches();
|
3 |
+
?>
|
4 |
+
<!-- GALATHEMES: COLOR SWATCHES -->
|
5 |
+
<script type="text/javascript">
|
6 |
+
document.observe('dom:loaded', function() {
|
7 |
+
var swatches = <?php echo Mage::helper('core')->jsonEncode($swatches); ?>;
|
8 |
+
|
9 |
+
function find_swatch(key, value) {
|
10 |
+
for (var i in swatches) {
|
11 |
+
if (swatches[i].key == key && swatches[i].value == value)
|
12 |
+
return swatches[i];
|
13 |
+
}
|
14 |
+
return null;
|
15 |
+
}
|
16 |
+
|
17 |
+
function has_swatch_key(key) {
|
18 |
+
for (var i in swatches) {
|
19 |
+
if (swatches[i].key == key)
|
20 |
+
return true;
|
21 |
+
}
|
22 |
+
return false;
|
23 |
+
}
|
24 |
+
|
25 |
+
$$('#product-options-wrapper dt').each(function(dt) {
|
26 |
+
|
27 |
+
// get custom option's label
|
28 |
+
var label = '';
|
29 |
+
$A(dt.down('label').childNodes).each(function(node) {
|
30 |
+
if (node.nodeType == 3) label += node.nodeValue;
|
31 |
+
});
|
32 |
+
label = label.trim();
|
33 |
+
|
34 |
+
var dd = dt.next();
|
35 |
+
var select = dd.down('select');
|
36 |
+
if (select && has_swatch_key(label)) {
|
37 |
+
|
38 |
+
// create swatches div, and append below the <select>
|
39 |
+
var sw = new Element('div', {'class': 'swatches-container'});
|
40 |
+
select.up().appendChild(sw);
|
41 |
+
|
42 |
+
// hide select
|
43 |
+
select.setStyle({position: 'absolute', top: '-9999px'})
|
44 |
+
|
45 |
+
$A(select.options).each(function(opt, i) {
|
46 |
+
if (opt.value) {
|
47 |
+
var elm;
|
48 |
+
var key = opt.innerHTML.trim();
|
49 |
+
|
50 |
+
// remove price
|
51 |
+
if (opt.getAttribute('price')) key = key.replace(/\+([^+]+)$/, '').trim();
|
52 |
+
|
53 |
+
var item = find_swatch(label, key);
|
54 |
+
if (item)
|
55 |
+
elm = new Element('img', {
|
56 |
+
src: '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?>colors_watches/'+item.img,
|
57 |
+
alt: opt.innerHTML,
|
58 |
+
title: opt.innerHTML,
|
59 |
+
'class': 'swatch-img'});
|
60 |
+
else {
|
61 |
+
elm = new Element('span', {'class': 'swatch-span'});
|
62 |
+
elm.update(opt.innerHTML);
|
63 |
+
}
|
64 |
+
elm.observe('click', function(event) {
|
65 |
+
select.selectedIndex = i;
|
66 |
+
var cur = sw.down('.current');
|
67 |
+
if (cur) cur.removeClassName('current');
|
68 |
+
elm.addClassName('current');
|
69 |
+
})
|
70 |
+
sw.appendChild(elm);
|
71 |
+
}
|
72 |
+
});
|
73 |
+
|
74 |
+
}
|
75 |
+
});
|
76 |
+
|
77 |
+
|
78 |
+
});
|
79 |
+
</script>
|
app/etc/modules/EM_Colorswatches.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<EM_Colorswatches>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</EM_Colorswatches>
|
8 |
+
</modules>
|
9 |
+
</config>
|
media/colors_watches/10.jpg
ADDED
Binary file
|
media/colors_watches/105.jpg
ADDED
Binary file
|
media/colors_watches/11.jpg
ADDED
Binary file
|
media/colors_watches/12.jpg
ADDED
Binary file
|
media/colors_watches/9.jpg
ADDED
Binary file
|
media/colors_watches/95.jpg
ADDED
Binary file
|
media/colors_watches/color-black.png
ADDED
Binary file
|
media/colors_watches/color-yellow.png
ADDED
Binary file
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Gala_Colorswatches</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://galathemes.com/license.html">Commercial</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Gala Color Swatches Magento Extension</summary>
|
10 |
+
<description>Color Swatches Magento Extensions, transform drop-down custom options to swatches, it supports all type of products such as simple product, configurable products...</description>
|
11 |
+
<notes>First Release - 09/02/2011</notes>
|
12 |
+
<authors><author><name>galathemes</name><user>auto-converted</user><email>contact@galathemes.com</email></author></authors>
|
13 |
+
<date>2011-09-01</date>
|
14 |
+
<time>13:01:50</time>
|
15 |
+
<contents><target name="magemedia"><dir name="colors_watches"><file name="9.jpg" hash="f836843f7c41cfcbc3bb9ad060340d3d"/><file name="10.jpg" hash="682a217b52553b0b836bb670393ab07c"/><file name="11.jpg" hash="3a4f381f2c63cb74d44833345d9e7587"/><file name="12.jpg" hash="50071c7dcc1f1d06ace20eee30ad00b0"/><file name="95.jpg" hash="1ca78c083d6445af4907e5a03eb17bfa"/><file name="105.jpg" hash="f5e2faba89dcda154f57db8f0a5458f0"/><file name="color-black.png" hash="b7e2043b596a4c16e98394e5e0e0bb61"/><file name="color-yellow.png" hash="b7e2043b596a4c16e98394e5e0e0bb61"/></dir></target><target name="magecommunity"><dir name="EM"><dir name="Colorswatches"><dir name="Block"><file name="Settings.php" hash="934e26bae7e4eb8c485d9e1624e912ef"/></dir><dir name="etc"><file name="config.xml" hash="42ac94059dc34cfdd7187b8f36abc496"/><file name="system.xml" hash="06ea7e33de7cfd4bcfd802f18cda1eec"/></dir><dir name="Helper"><file name="Data.php" hash="e90743912e617d9a91f9e94fa97eb6fc"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="em_colorswatches.xml" hash="47de324772962de44f467bc05043e6eb"/></dir><dir name="template"><dir name="em_colorswatches"><file name="settings.phtml" hash="028ea968383bf700915099f791abae0f"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EM_Colorswatches.xml" hash="28c2dfd0b5e565ee1765e6f9fd29e7a0"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies/>
|
18 |
+
</package>
|