HK_Optionswatches - Version 1.0.1

Version Notes

Version 1.0.1 first Release

Download this release

Release Info

Developer Hardik
Extension HK_Optionswatches
Version 1.0.1
Comparing to
See all releases


Version 1.0.1

app/code/community/HK/Optionswatches/Block/Index.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class HK_Optionswatches_Block_Index extends Mage_Core_Block_Template{
3
+
4
+
5
+ public function get_option_swatches() {
6
+ return $this->parse_swatches(Mage::getStoreConfig('optionswatches/image/option_swatches'));
7
+ }
8
+
9
+ protected function parse_swatches($s) {
10
+ $swatches = array();
11
+ if ($s) {
12
+ if (preg_match_all("/^(.*)\:(.*)=(.*)$/m", $s, $m, PREG_SET_ORDER)) {
13
+ foreach ($m as $_ln)
14
+ $swatches[] = array(
15
+ 'key' => trim($_ln[1]),
16
+ 'value' => trim($_ln[2]),
17
+ 'img' => trim($_ln[3])
18
+ );
19
+ }
20
+ }
21
+ return $swatches;
22
+ }
23
+
24
+
25
+ }
app/code/community/HK/Optionswatches/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class HK_Optionswatches_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
5
+
app/code/community/HK/Optionswatches/etc/config.xml ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <HK_Optionswatches>
5
+ <version>0.1.0</version>
6
+ </HK_Optionswatches>
7
+ </modules>
8
+
9
+ <adminhtml>
10
+ <acl>
11
+ <resources>
12
+ <admin>
13
+ <children>
14
+ <system>
15
+ <children>
16
+ <config>
17
+ <children>
18
+ <optionswatches>
19
+ <title>Image Configure</title>
20
+ </optionswatches>
21
+ </children>
22
+ </config>
23
+ </children>
24
+ </system>
25
+ </children>
26
+ </admin>
27
+ </resources>
28
+ </acl>
29
+ </adminhtml>
30
+
31
+ <admin>
32
+ <routers>
33
+ <optionswatches>
34
+ <use>admin</use>
35
+ <args>
36
+ <module>HK_Optionswatches</module>
37
+ <frontName>optionswatches</frontName>
38
+ </args>
39
+ </optionswatches>
40
+ </routers>
41
+ </admin>
42
+
43
+ <frontend>
44
+ <routers>
45
+ <optionswatches>
46
+ <use>standard</use>
47
+ <args>
48
+ <module>HK_Optionswatches</module>
49
+ <frontName>optionswatches</frontName>
50
+ </args>
51
+ </optionswatches>
52
+ </routers>
53
+ <layout>
54
+ <updates>
55
+ <optionswatches>
56
+ <file>optionswatches.xml</file>
57
+ </optionswatches>
58
+ </updates>
59
+ </layout>
60
+ </frontend>
61
+
62
+ <global>
63
+ <helpers>
64
+ <optionswatches>
65
+ <class>HK_Optionswatches_Helper</class>
66
+ </optionswatches>
67
+ </helpers>
68
+ <blocks>
69
+ <optionswatches>
70
+ <class>HK_Optionswatches_Block</class>
71
+ </optionswatches>
72
+ </blocks>
73
+ </global>
74
+ </config>
app/code/community/HK/Optionswatches/etc/system.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <sections>
5
+ <optionswatches translate="label" module="optionswatches">
6
+ <label>HK Optionswatches Settings</label>
7
+ <tab>general</tab>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>1000</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
+ <groups>
14
+ <image translate="label">
15
+ <label>Image Configure</label>
16
+ <frontend_type>text</frontend_type>
17
+ <sort_order>1</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>1</show_in_store>
21
+ <fields>
22
+ <option_swatches translate="label comment">
23
+ <label>Custom Option Swatches</label>
24
+ <frontend_type>textarea</frontend_type>
25
+ <sort_order>26</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ <comment><![CDATA[
30
+ <p>Format: <em>[option label]</em> : <em>[option value]</em> = <em>[option image]</em></p>
31
+ <p>Example:</p>
32
+ <p>
33
+ Size : Small = small.png<br/>
34
+ Color : Red = red.png<br/>
35
+ </p>
36
+ <p>Swatch images should be uploaded in <strong>media/hk_option_swatches/</strong></p>
37
+ ]]></comment>
38
+ </option_swatches>
39
+ </fields>
40
+ </image>
41
+ </groups>
42
+ </optionswatches>
43
+ </sections>
44
+ </config>
app/design/frontend/base/default/layout/optionswatches.xml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout version="0.1.0">
4
+ <catalog_product_view translate="label">
5
+ <reference name="head">
6
+ <action method="addCss"><stylesheet>css/hk_optionswatches.css</stylesheet></action>
7
+ </reference>
8
+ <reference name="product.info.options.wrapper">
9
+ <block type="optionswatches/index" name="optionswatches_index" template="optionswatches/option_js.phtml"/>
10
+ </reference>
11
+ </catalog_product_view>
12
+
13
+ <catalog_category_default translate="label">
14
+ <reference name="head">
15
+ <action method="addCss"><stylesheet>css/hk_optionswatches.css</stylesheet></action>
16
+ </reference>
17
+ <reference name="product_list">
18
+ <block type="optionswatches/index" name="optionswatches_index" template="optionswatches/option_js.phtml"/>
19
+ </reference>
20
+ <reference name="product_list">
21
+ <action method="setTemplate">
22
+ <template>optionswatches/list.phtml</template>
23
+ </action>
24
+ </reference>
25
+ </catalog_category_default>
26
+
27
+ <catalog_category_layered translate="label">
28
+ <reference name="head">
29
+ <action method="addCss"><stylesheet>css/hk_optionswatches.css</stylesheet></action>
30
+ </reference>
31
+ <reference name="product_list">
32
+ <block type="optionswatches/index" name="optionswatches_index" template="optionswatches/option_js.phtml"/>
33
+ </reference>
34
+ <reference name="product_list">
35
+ <action method="setTemplate">
36
+ <template>optionswatches/list.phtml</template>
37
+ </action>
38
+ </reference>
39
+ </catalog_category_layered>
40
+
41
+ </layout>
42
+
app/design/frontend/base/default/template/optionswatches/list.phtml ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $_productCollection=$this->getLoadedProductCollection();
30
+ $_helper = $this->helper('catalog/output');
31
+ ?>
32
+ <?php echo $this->getChildHtml('optionswatches_index') ?>
33
+ <?php if(!$_productCollection->count()): ?>
34
+ <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
35
+ <?php else: ?>
36
+ <div class="category-products">
37
+ <?php echo $this->getToolbarHtml() ?>
38
+ <?php // List mode ?>
39
+ <?php if($this->getMode()!='grid'): ?>
40
+ <?php $_iterator = 0; ?>
41
+ <ol class="products-list" id="products-list">
42
+ <?php foreach ($_productCollection as $_product): ?>
43
+
44
+ <?php
45
+ $productSku = $_product->getSku();
46
+ $product = Mage::getModel('catalog/product');
47
+ $productId = $product->getIdBySku( $productSku );
48
+ $product = Mage::getModel("catalog/product")->load($productId);
49
+ $attVal = $product->getOptions();
50
+ $optStr = "";
51
+ ?>
52
+
53
+ <li class="hklist item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
54
+ <?php // Product Image ?>
55
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
56
+ <?php // Product description ?>
57
+ <div class="product-shop">
58
+ <div class="f-fix">
59
+ <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
60
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
61
+ <?php if($_product->getRatingSummary()): ?>
62
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
63
+ <?php endif; ?>
64
+ <?php echo $this->getPriceHtml($_product, true) ?>
65
+ <?php if($_product->isSaleable()): ?>
66
+ <div id="product-options-wrapper">
67
+ <form action="<?php echo $this->helper('checkout/cart')->getAddUrl($_product)?>" method="post" id= "product_addtocart_form" <?php if($_product->getOptions()):?> enctype="multipart/form-data"<?php endif;?>>
68
+
69
+ <!--New layout--->
70
+ <?php foreach($attVal as $optionKey => $optionVal)
71
+ {
72
+ $optStr.= "<dl> <dt> <label class='required'><em>*</em>".$optionVal->getTitle()."</label></dt>";
73
+ $optStr.= "<dd> <div class='input-box'>";
74
+ $optStr.= "<select id='".$z."' class='required-entry product-custom-option' name='options[".$optionVal->getId()."]'>";
75
+
76
+ foreach($optionVal->getValues() as $valuesKey => $valuesVal)
77
+ {
78
+ $optStr.= "<option value='".$valuesVal->getId()."' price='".number_format($valuesVal->getPrice(true),2)."'>".$valuesVal->getTitle()."</option>";
79
+ }
80
+ $optStr.= "</select>";
81
+ $optStr.= "</div> </dd> </dl>";
82
+ }
83
+ echo($optStr );?>
84
+
85
+ <div>
86
+ <input type="image" value="Add to cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product)?>')" style="background: none repeat scroll 0px 0px rgb(241, 130, 0); border: 1px solid rgb(222, 84, 0); color: rgb(255, 255, 255); height: 19px; text-align: center; white-space: nowrap; width: 65px; font: bold 12px/19px Arial,Helvetica,sans-serif; padding: 1px 8px;">
87
+ </div>
88
+ <!--End New layout--->
89
+
90
+ <?php else: ?>
91
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
92
+ <?php endif; ?>
93
+ <div class="desc std">
94
+ <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
95
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
96
+ </div>
97
+ <ul class="add-to-links">
98
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
99
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
100
+ <?php endif; ?>
101
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
102
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
103
+ <?php endif; ?>
104
+ </ul>
105
+ </form>
106
+ </div>
107
+ </div>
108
+ </div>
109
+ </li>
110
+ <?php endforeach; ?>
111
+ </ol>
112
+ <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
113
+
114
+ <?php else: ?>
115
+
116
+ <?php // Grid Mode ?>
117
+
118
+ <?php $_collectionSize = $_productCollection->count() ?>
119
+ <?php $_columnCount = $this->getColumnCount(); ?>
120
+ <?php $i=0; foreach ($_productCollection as $_product): ?>
121
+
122
+ <?php
123
+ $productSku = $_product->getSku();
124
+ $product = Mage::getModel('catalog/product');
125
+ $productId = $product->getIdBySku( $productSku );
126
+ $product = Mage::getModel("catalog/product")->load($productId);
127
+ $attVal = $product->getOptions();
128
+ $optStr = "";
129
+ ?>
130
+
131
+ <?php if ($i++%$_columnCount==0): ?>
132
+ <ul class="products-grid">
133
+ <?php endif ?>
134
+ <li class="hklist item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
135
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
136
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
137
+ <?php if($_product->getRatingSummary()): ?>
138
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
139
+ <?php endif; ?>
140
+ <?php echo $this->getPriceHtml($_product, true) ?>
141
+ <div class="actions" id="product-options-wrapper">
142
+ <?php if($_product->isSaleable()):?>
143
+ <form action="<?php echo $this->helper('checkout/cart')->getAddUrl($_product)?>" method="post" id= "product_addtocart_form" <?php if($_product->getOptions()):?> enctype="multipart/form-data"<?php endif;?>>
144
+
145
+ <!--New layout--->
146
+ <?php foreach($attVal as $optionKey => $optionVal)
147
+ {
148
+ $optStr.= "<dl> <dt> <label class='required'><em>*</em>".$optionVal->getTitle()."</label></dt>";
149
+ $optStr.= "<dd> <div class='input-box'>";
150
+ $optStr.= "<select id='".$z."' class='required-entry product-custom-option' name='options[".$optionVal->getId()."]'>";
151
+
152
+ foreach($optionVal->getValues() as $valuesKey => $valuesVal)
153
+ {
154
+ $optStr.= "<option value='".$valuesVal->getId()."' price='".number_format($valuesVal->getPrice(true),2)."'>".$valuesVal->getTitle()."</option>";
155
+ }
156
+ $optStr.= "</select>";
157
+ $optStr.= "</div> </dd> </dl>";
158
+ }
159
+ echo($optStr );?>
160
+ <!--End New layout--->
161
+
162
+ <div>
163
+ <input type="image" value="Add to cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product)?>')" style="background: none repeat scroll 0px 0px rgb(241, 130, 0); border: 1px solid rgb(222, 84, 0); color: rgb(255, 255, 255); height: 19px; text-align: center; white-space: nowrap; width: 65px; font: bold 12px/19px Arial,Helvetica,sans-serif; padding: 1px 8px;">
164
+ </div>
165
+ <?php else:?>
166
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock')?></span></p>
167
+ <?php endif;?>
168
+ <ul class="add-to-links">
169
+ <?php if ($this->helper('wishlist')->isAllow()) :?>
170
+ <li>
171
+ <a href="<?php echo $this->helper('wishlist')->getAddUrl($_product)?>" class="link-wishlist">
172
+ <?php echo $this->__('Add to Wishlist')?>
173
+ </a>
174
+ </li>
175
+ <?php endif;?>
176
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)):?>
177
+ <li>
178
+ <span class="separator">|</span>
179
+ <a href="<?php echo $_compareUrl?>" class="link-compare"><?php echo $this->__('Add to Compare')?>
180
+ </a>
181
+ </li>
182
+ <?php endif;?>
183
+ </ul>
184
+ </form>
185
+ </div>
186
+ </li>
187
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
188
+ </ul>
189
+ <?php endif ?>
190
+ <?php endforeach ?>
191
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
192
+ <?php endif; ?>
193
+
194
+ <div class="toolbar-bottom">
195
+ <?php echo $this->getToolbarHtml() ?>
196
+ </div>
197
+ </div>
198
+ <?php endif; ?>
app/design/frontend/base/default/template/optionswatches/option_js.phtml ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $hkswatches = $this->get_option_swatches();
3
+ ?>
4
+
5
+ <script type="text/javascript">
6
+ document.observe('dom:loaded', function() {
7
+ try {
8
+ var swatches = <?php echo Mage::helper('core')->jsonEncode($hkswatches); ?>;
9
+
10
+ function find_swatch(key, value) {
11
+ for (var i in swatches) {
12
+ if (swatches[i].key == key && swatches[i].value == value)
13
+ return swatches[i];
14
+ }
15
+ return null;
16
+ }
17
+
18
+ function has_swatch_key(key) {
19
+ for (var i in swatches) {
20
+ if (swatches[i].key == key)
21
+ return true;
22
+ }
23
+ return false;
24
+ }
25
+
26
+ function create_swatches(label, select) {
27
+ var sw = new Element('div', {'class': 'swatches-container'});
28
+ if(select)
29
+ select.up().appendChild(sw);
30
+
31
+ select.swatchLabel = label;
32
+ select.swatchElement = sw;
33
+
34
+ select.setStyle({position: 'absolute', top: '-9999px'})
35
+
36
+ $A(select.options).each(function(opt, i) {
37
+ if (opt.getAttribute('value')) {
38
+ var elm;
39
+ var key = trim(opt.innerHTML);
40
+
41
+ if (opt.getAttribute('price')) key = trim(key.replace(/\+([^+]+)$/, ''));
42
+
43
+ var item = find_swatch(label, key);
44
+ if (item)
45
+ elm = new Element('img', {
46
+ src: '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?>hk_option_swatches/'+item.img,
47
+ alt: opt.innerHTML,
48
+ title: opt.innerHTML,
49
+ 'class': 'swatch-img'});
50
+ else {
51
+ console.debug(label, key, swatches);
52
+ elm = new Element('a', {'class': 'swatch-span'});
53
+ elm.update(opt.innerHTML);
54
+ }
55
+ elm.observe('click', function(event) {
56
+ select.selectedIndex = i;
57
+ fireEvent(select, 'change');
58
+ var cur = sw.down('.current');
59
+ if (cur) cur.removeClassName('current');
60
+ elm.addClassName('current');
61
+ });
62
+ sw.appendChild(elm);
63
+ }
64
+ });
65
+ }
66
+
67
+ function recreate_swatches_recursive(select) {
68
+ if (select.swatchElement) {
69
+ select.up().removeChild(select.swatchElement);
70
+ select.swatchElement = null;
71
+ }
72
+
73
+ if (!select.disabled){
74
+ create_swatches(select.swatchLabel, select);
75
+ }
76
+
77
+ if (select.nextSetting){
78
+ recreate_swatches_recursive(select.nextSetting);
79
+ }
80
+ }
81
+
82
+ function fireEvent(element,event){
83
+ if (document.createEventObject){
84
+ var evt = document.createEventObject();
85
+ return element.fireEvent('on'+event,evt)
86
+ }
87
+ else{
88
+ var evt = document.createEvent("HTMLEvents");
89
+ evt.initEvent(event, true, true );
90
+ return !element.dispatchEvent(evt);
91
+ }
92
+ }
93
+
94
+ function trim(str) {
95
+ return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
96
+ }
97
+
98
+
99
+ $$('#product-options-wrapper dt').each(function(dt) {
100
+ var label = '';
101
+ $A(dt.down('label').childNodes).each(function(node) {
102
+ if (node.nodeType == 3) label += node.nodeValue;
103
+ });
104
+ label = trim(label);
105
+
106
+ var dd = dt.next();
107
+ var select = dd.down('select');
108
+
109
+ if (select && has_swatch_key(label)) {
110
+ create_swatches(label, select);
111
+
112
+ if (select.hasClassName('super-attribute-select')) {
113
+ select.observe('change', function() {
114
+ setTimeout(function() {
115
+ recreate_swatches_recursive(select.nextSetting);
116
+ }, 100);
117
+ });
118
+ }
119
+ }
120
+ });
121
+ }
122
+ catch(e) {
123
+ alert("Option Swatches javascript error. Please report this error to hkpatel201@gmail.com. Error:" + e.message);
124
+ }
125
+ });
126
+ </script>
app/etc/modules/HK_Optionswatches.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <HK_Optionswatches>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </HK_Optionswatches>
8
+ </modules>
9
+ </config>
media/hk_option_swatches/black.png ADDED
Binary file
media/hk_option_swatches/blue.png ADDED
Binary file
media/hk_option_swatches/l.png ADDED
Binary file
media/hk_option_swatches/m.png ADDED
Binary file
media/hk_option_swatches/red.png ADDED
Binary file
media/hk_option_swatches/s.png ADDED
Binary file
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>HK_Optionswatches</name>
4
+ <version>1.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OLS v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>HK Option Swatches Magento Extension</summary>
10
+ <description>HK Option Swatches Magento Extensions, create drop-down custom options to swatches.</description>
11
+ <notes>Version 1.0.1 first Release</notes>
12
+ <authors><author><name>Hardik</name><user>khpatel201</user><email>hkpatel201@gmail.com</email></author></authors>
13
+ <date>2015-01-07</date>
14
+ <time>07:44:42</time>
15
+ <contents><target name="magecommunity"><dir name="HK"><dir name="Optionswatches"><dir name="Block"><file name="Index.php" hash="c917b7a36eddba3a9ee7f2ea7a22c617"/></dir><dir name="Helper"><file name="Data.php" hash="c8f049e1475d5456829afcd9b604c873"/></dir><dir name="etc"><file name="config.xml" hash="975061ac6672ea2d143ca7229754af7a"/><file name="system.xml" hash="f8cf65d1d16a067d56c4803a78dd0a82"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="optionswatches.xml" hash="7f65b4ee9d80319c4564e7fc1c700cd7"/></dir><dir name="template"><dir name="optionswatches"><file name="list.phtml" hash="e93e0e340c9b8a3f1ab2fe529ddd45ce"/><file name="option_js.phtml" hash="784ea246407b7a2770594b42df034ff9"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="HK_Optionswatches.xml" hash="c024476a3337515e1128c3b78d53104f"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="hk_optionswatches.css" hash="d5a7bb3cbff765ae560869fd88c18471"/></dir></dir></dir></dir></target><target name="magemedia"><dir name="hk_option_swatches"><file name="black.png" hash="f05c5386e416e53ec2b10060f5837b47"/><file name="blue.png" hash="e254da06b5e924011035ede292b9ffdd"/><file name="l.png" hash="77f053586eba95833b4bc05515c302a9"/><file name="m.png" hash="ad4e90ef4577452856c3c15534913d84"/><file name="red.png" hash="9223706248b9b63bc6a4751809bb2781"/><file name="s.png" hash="44eeeee15a7bff5459276de4eb64d496"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/css/hk_optionswatches.css ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ .swatches-container .swatch-img,
2
+ .swatches-container .swatch-span { margin:0 2px 2px 0; }
3
+ .swatches-container .swatch-img { border:1px solid #eee; }
4
+ .swatches-container .swatch-img.current { border:1px solid #333; }
5
+ .swatches-container .swatch-span { }
6
+ .products-grid li.item.hklist{padding: 12px 10px 10px;}
7
+ .products-grid .hklist .actions{
8
+ bottom: 0;
9
+ position: relative;
10
+ }