Version Notes
Release with no bugs.
Download this release
Release Info
Developer | Sanjay Dabhoya |
Extension | Solwin_AttributeImage |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Solwin/AttributeImage/Block/Catalog/Product/Attribute/Edit/Tab/Options.php +70 -0
- app/code/community/Solwin/AttributeImage/Helper/Cms/Wysiwyg/Images.php +13 -0
- app/code/community/Solwin/AttributeImage/Helper/Data.php +33 -0
- app/code/community/Solwin/AttributeImage/Model/Catalog/Resource/Eav/Mysql4/Attribute.php +87 -0
- app/code/community/Solwin/AttributeImage/Model/Eav/Entity/Attribute/Source/Table.php +36 -0
- app/code/community/Solwin/AttributeImage/Model/Eav/Mysql4/Entity/Attribute/Option.php +22 -0
- app/code/community/Solwin/AttributeImage/Model/Observer.php +27 -0
- app/code/community/Solwin/AttributeImage/Model/Resource/Mysql4/Setup.php +3 -0
- app/code/community/Solwin/AttributeImage/controllers/Cms/Wysiwyg/ImagesController.php +20 -0
- app/code/community/Solwin/AttributeImage/etc/config.xml +78 -0
- app/code/community/Solwin/AttributeImage/sql/solwin_attributeimage_setup/mysql4-install-1.0.0.php +18 -0
- app/design/adminhtml/default/default/template/solwin/catalog/product/attribute/options.phtml +183 -0
- app/design/frontend/default/default/template/catalog/layer/filter.phtml +25 -0
- app/etc/modules/Solwin_AttributeImage.xml +9 -0
- package.xml +21 -0
app/code/community/Solwin/AttributeImage/Block/Catalog/Product/Attribute/Edit/Tab/Options.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Solwin_AttributeImage_Block_Catalog_Product_Attribute_Edit_Tab_Options extends Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setTemplate('solwin/catalog/product/attribute/options.phtml');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getOptionValues()
|
12 |
+
{
|
13 |
+
$attributeType = $this->getAttributeObject()->getFrontendInput();
|
14 |
+
$defaultValues = $this->getAttributeObject()->getDefaultValue();
|
15 |
+
if ($attributeType == 'select' || $attributeType == 'multiselect') {
|
16 |
+
$defaultValues = explode(',', $defaultValues);
|
17 |
+
} else {
|
18 |
+
$defaultValues = array();
|
19 |
+
}
|
20 |
+
|
21 |
+
switch ($attributeType) {
|
22 |
+
case 'select':
|
23 |
+
$inputType = 'radio';
|
24 |
+
break;
|
25 |
+
case 'multiselect':
|
26 |
+
$inputType = 'checkbox';
|
27 |
+
break;
|
28 |
+
default:
|
29 |
+
$inputType = '';
|
30 |
+
break;
|
31 |
+
}
|
32 |
+
|
33 |
+
$values = $this->getData('option_values');
|
34 |
+
if (is_null($values)) {
|
35 |
+
$values = array();
|
36 |
+
$optionCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
37 |
+
->setAttributeFilter($this->getAttributeObject()->getId())
|
38 |
+
->setPositionOrder('desc', true)
|
39 |
+
->load();
|
40 |
+
|
41 |
+
foreach ($optionCollection as $option) {
|
42 |
+
$value = array();
|
43 |
+
if (in_array($option->getId(), $defaultValues)) {
|
44 |
+
$value['checked'] = 'checked="checked"';
|
45 |
+
} else {
|
46 |
+
$value['checked'] = '';
|
47 |
+
}
|
48 |
+
|
49 |
+
$value['intype'] = $inputType;
|
50 |
+
$value['id'] = $option->getId();
|
51 |
+
$value['sort_order'] = $option->getSortOrder();
|
52 |
+
$value['image'] = $option->getImage();
|
53 |
+
$value['thumb'] = $option->getThumb();
|
54 |
+
foreach ($this->getStores() as $store) {
|
55 |
+
$storeValues = $this->getStoreOptionValues($store->getId());
|
56 |
+
if (isset($storeValues[$option->getId()])) {
|
57 |
+
$value['store'.$store->getId()] = htmlspecialchars($storeValues[$option->getId()]);
|
58 |
+
}
|
59 |
+
else {
|
60 |
+
$value['store'.$store->getId()] = '';
|
61 |
+
}
|
62 |
+
}
|
63 |
+
$values[] = new Varien_Object($value);
|
64 |
+
}
|
65 |
+
$this->setData('option_values', $values);
|
66 |
+
}
|
67 |
+
|
68 |
+
return $values;
|
69 |
+
}
|
70 |
+
}
|
app/code/community/Solwin/AttributeImage/Helper/Cms/Wysiwyg/Images.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Solwin_AttributeImage_Helper_Cms_Wysiwyg_Images extends Mage_Cms_Helper_Wysiwyg_Images
|
4 |
+
{
|
5 |
+
public function isUsingStaticUrlsAllowed()
|
6 |
+
{
|
7 |
+
if (Mage::getSingleton('adminhtml/session')->getStaticUrlsAllowed()) {
|
8 |
+
return true;
|
9 |
+
}
|
10 |
+
|
11 |
+
return parent::isUsingStaticUrlsAllowed();
|
12 |
+
}
|
13 |
+
}
|
app/code/community/Solwin/AttributeImage/Helper/Data.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Solwin_AttributeImage_Helper_Data extends Mage_Core_Helper_Abstract {
|
4 |
+
|
5 |
+
public function getAttributeImage($optionId) {
|
6 |
+
$images = $this->getAttributeImages();
|
7 |
+
$image = array_key_exists($optionId, $images) ? $images[$optionId] : '';
|
8 |
+
if ($image && (strpos($image, 'http') !== 0)) {
|
9 |
+
$image = Mage::getDesign()->getSkinUrl($image);
|
10 |
+
}
|
11 |
+
return $image;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getAttributeImages() {
|
15 |
+
$images = Mage::getResourceModel('eav/entity_attribute_option')->getAttributeImages();
|
16 |
+
return $images;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getAttributeThumb($optionId) {
|
20 |
+
$images = $this->getAttributeThumbs();
|
21 |
+
$image = array_key_exists($optionId, $images) ? $images[$optionId] : '';
|
22 |
+
if ($image && (strpos($image, 'http') !== 0)) {
|
23 |
+
$image = Mage::getDesign()->getSkinUrl($image);
|
24 |
+
}
|
25 |
+
return $image;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getAttributeThumbs() {
|
29 |
+
$images = Mage::getResourceModel('eav/entity_attribute_option')->getAttributeThumbs();
|
30 |
+
return $images;
|
31 |
+
}
|
32 |
+
|
33 |
+
}
|
app/code/community/Solwin/AttributeImage/Model/Catalog/Resource/Eav/Mysql4/Attribute.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Solwin_AttributeImage_Model_Catalog_Resource_Eav_Mysql4_Attribute extends Mage_Catalog_Model_Resource_Eav_Mysql4_Attribute
|
4 |
+
{
|
5 |
+
protected function _saveOption(Mage_Core_Model_Abstract $object)
|
6 |
+
{
|
7 |
+
$option = $object->getOption();
|
8 |
+
if (is_array($option)) {
|
9 |
+
$write = $this->_getWriteAdapter();
|
10 |
+
$optionTable = $this->getTable('attribute_option');
|
11 |
+
$optionValueTable = $this->getTable('attribute_option_value');
|
12 |
+
$stores = Mage::getModel('core/store')
|
13 |
+
->getResourceCollection()
|
14 |
+
->setLoadDefault(true)
|
15 |
+
->load();
|
16 |
+
|
17 |
+
if (isset($option['value'])) {
|
18 |
+
$attributeDefaultValue = array();
|
19 |
+
if (!is_array($object->getDefault())) {
|
20 |
+
$object->setDefault(array());
|
21 |
+
}
|
22 |
+
|
23 |
+
foreach ($option['value'] as $optionId => $values) {
|
24 |
+
$intOptionId = (int) $optionId;
|
25 |
+
if (!empty($option['delete'][$optionId])) {
|
26 |
+
if ($intOptionId) {
|
27 |
+
$condition = $write->quoteInto('option_id=?', $intOptionId);
|
28 |
+
$write->delete($optionTable, $condition);
|
29 |
+
}
|
30 |
+
|
31 |
+
continue;
|
32 |
+
}
|
33 |
+
|
34 |
+
if (!$intOptionId) {
|
35 |
+
$data = array(
|
36 |
+
'attribute_id' => $object->getId(),
|
37 |
+
'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0,
|
38 |
+
'image' => isset($option['image'][$optionId]) ? $option['image'][$optionId] : '',
|
39 |
+
'thumb' => isset($option['thumb'][$optionId]) ? $option['thumb'][$optionId] : '',
|
40 |
+
);
|
41 |
+
$write->insert($optionTable, $data);
|
42 |
+
$intOptionId = $write->lastInsertId();
|
43 |
+
}
|
44 |
+
else {
|
45 |
+
$data = array(
|
46 |
+
'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0,
|
47 |
+
'image' => isset($option['image'][$optionId]) ? $option['image'][$optionId] : '',
|
48 |
+
'thumb' => isset($option['thumb'][$optionId]) ? $option['thumb'][$optionId] : '',
|
49 |
+
);
|
50 |
+
$write->update($optionTable, $data, $write->quoteInto('option_id=?', $intOptionId));
|
51 |
+
}
|
52 |
+
|
53 |
+
if (in_array($optionId, $object->getDefault())) {
|
54 |
+
if ($object->getFrontendInput() == 'multiselect') {
|
55 |
+
$attributeDefaultValue[] = $intOptionId;
|
56 |
+
} else if ($object->getFrontendInput() == 'select') {
|
57 |
+
$attributeDefaultValue = array($intOptionId);
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
// Default value
|
63 |
+
if (!isset($values[0])) {
|
64 |
+
Mage::throwException(Mage::helper('eav')->__('Default option value is not defined.'));
|
65 |
+
}
|
66 |
+
|
67 |
+
$write->delete($optionValueTable, $write->quoteInto('option_id=?', $intOptionId));
|
68 |
+
foreach ($stores as $store) {
|
69 |
+
if (isset($values[$store->getId()]) && (!empty($values[$store->getId()]) || $values[$store->getId()] == "0")) {
|
70 |
+
$data = array(
|
71 |
+
'option_id' => $intOptionId,
|
72 |
+
'store_id' => $store->getId(),
|
73 |
+
'value' => $values[$store->getId()],
|
74 |
+
);
|
75 |
+
$write->insert($optionValueTable, $data);
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
$write->update($this->getMainTable(), array(
|
81 |
+
'default_value' => implode(',', $attributeDefaultValue)
|
82 |
+
), $write->quoteInto($this->getIdFieldName() . '=?', $object->getId()));
|
83 |
+
}
|
84 |
+
}
|
85 |
+
return $this;
|
86 |
+
}
|
87 |
+
}
|
app/code/community/Solwin/AttributeImage/Model/Eav/Entity/Attribute/Source/Table.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Solwin_AttributeImage_Model_Eav_Entity_Attribute_Source_Table extends Mage_Eav_Model_Entity_Attribute_Source_Table
|
4 |
+
{
|
5 |
+
public function getOptionImage($value)
|
6 |
+
{
|
7 |
+
$options = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
8 |
+
->setPositionOrder('asc')
|
9 |
+
->setAttributeFilter($this->getAttribute()->getId())
|
10 |
+
->setStoreFilter($this->getAttribute()->getStoreId())
|
11 |
+
->load()
|
12 |
+
->toArray();
|
13 |
+
foreach ($options['items'] as $item) {
|
14 |
+
if ($item['option_id'] == $value) {
|
15 |
+
return $item['image'];
|
16 |
+
}
|
17 |
+
}
|
18 |
+
return false;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getOptionThumb($value)
|
22 |
+
{
|
23 |
+
$options = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
24 |
+
->setPositionOrder('asc')
|
25 |
+
->setAttributeFilter($this->getAttribute()->getId())
|
26 |
+
->setStoreFilter($this->getAttribute()->getStoreId())
|
27 |
+
->load()
|
28 |
+
->toArray();
|
29 |
+
foreach ($options['items'] as $item) {
|
30 |
+
if ($item['option_id'] == $value) {
|
31 |
+
return $item['thumb'];
|
32 |
+
}
|
33 |
+
}
|
34 |
+
return false;
|
35 |
+
}
|
36 |
+
}
|
app/code/community/Solwin/AttributeImage/Model/Eav/Mysql4/Entity/Attribute/Option.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Solwin_AttributeImage_Model_Eav_Mysql4_Entity_Attribute_Option extends Mage_Eav_Model_Mysql4_Entity_Attribute_Option
|
4 |
+
{
|
5 |
+
public function getAttributeImages()
|
6 |
+
{
|
7 |
+
$select = $this->getReadConnection()
|
8 |
+
->select()
|
9 |
+
->from($this->getTable('eav/attribute_option'), array('option_id', 'image'));
|
10 |
+
|
11 |
+
return $this->getReadConnection()->fetchPairs($select);
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getAttributeThumbs()
|
15 |
+
{
|
16 |
+
$select = $this->getReadConnection()
|
17 |
+
->select()
|
18 |
+
->from($this->getTable('eav/attribute_option'), array('option_id', 'thumb'));
|
19 |
+
|
20 |
+
return $this->getReadConnection()->fetchPairs($select);
|
21 |
+
}
|
22 |
+
}
|
app/code/community/Solwin/AttributeImage/Model/Observer.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Solwin_AttributeImage_Model_Observer
|
4 |
+
{
|
5 |
+
public function updateLayout()
|
6 |
+
{
|
7 |
+
$layout = Mage::getSingleton('core/layout');
|
8 |
+
|
9 |
+
$head = $layout->getBlock('head');
|
10 |
+
$head->setCanLoadExtJs(true)
|
11 |
+
->addJs('mage/adminhtml/variables.js')
|
12 |
+
->addJs('mage/adminhtml/wysiwyg/widget.js')
|
13 |
+
->addJs('lib/flex.js')
|
14 |
+
->addJs('lib/FABridge.js')
|
15 |
+
->addJs('mage/adminhtml/flexuploader.js')
|
16 |
+
->addJs('mage/adminhtml/browser.js')
|
17 |
+
->addJs('prototype/window.js')
|
18 |
+
->addItem('js_css', 'prototype/windows/themes/default.css');
|
19 |
+
|
20 |
+
// Less than 1.7
|
21 |
+
if (version_compare(Mage::getVersion(), '1.7.0.0', '<')) {
|
22 |
+
$head->addItem('js_css', 'prototype/windows/themes/magento.css');
|
23 |
+
} else {
|
24 |
+
$head->addCss('lib/prototype/windows/themes/magento.css');
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
app/code/community/Solwin/AttributeImage/Model/Resource/Mysql4/Setup.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Solwin_AttributeImage_Model_Resource_Mysql4_Setup extends Mage_Core_Model_Resource_Setup {
|
3 |
+
}
|
app/code/community/Solwin/AttributeImage/controllers/Cms/Wysiwyg/ImagesController.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once 'Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php';
|
4 |
+
|
5 |
+
class Solwin_AttributeImage_Cms_Wysiwyg_ImagesController extends Mage_Adminhtml_Cms_Wysiwyg_ImagesController
|
6 |
+
{
|
7 |
+
public function indexAction()
|
8 |
+
{
|
9 |
+
if ($this->getRequest()->getParam('static_urls_allowed')) {
|
10 |
+
$this->_getSession()->setStaticUrlsAllowed(true);
|
11 |
+
}
|
12 |
+
parent::indexAction();
|
13 |
+
}
|
14 |
+
|
15 |
+
public function onInsertAction()
|
16 |
+
{
|
17 |
+
parent::onInsertAction();
|
18 |
+
$this->_getSession()->setStaticUrlsAllowed();
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Solwin/AttributeImage/etc/config.xml
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Solwin_AttributeImage>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Solwin_AttributeImage>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<resources>
|
10 |
+
<solwin_attributeimage_setup>
|
11 |
+
<setup>
|
12 |
+
<module>Solwin_AttributeImage</module>
|
13 |
+
<class>Solwin_AttributeImage_Model_Resource_Mysql4_Setup</class>
|
14 |
+
</setup>
|
15 |
+
</solwin_attributeimage_setup>
|
16 |
+
</resources>
|
17 |
+
<models>
|
18 |
+
<solwin_attributeimage>
|
19 |
+
<class>Solwin_AttributeImage_Model</class>
|
20 |
+
</solwin_attributeimage>
|
21 |
+
<catalog_resource_eav_mysql4>
|
22 |
+
<rewrite>
|
23 |
+
<attribute>Solwin_AttributeImage_Model_Catalog_Resource_Eav_Mysql4_Attribute</attribute>
|
24 |
+
</rewrite>
|
25 |
+
</catalog_resource_eav_mysql4>
|
26 |
+
<eav>
|
27 |
+
<rewrite>
|
28 |
+
<entity_attribute_source_table>Solwin_AttributeImage_Model_Eav_Entity_Attribute_Source_Table</entity_attribute_source_table>
|
29 |
+
</rewrite>
|
30 |
+
</eav>
|
31 |
+
<eav_mysql4>
|
32 |
+
<rewrite>
|
33 |
+
<entity_attribute_option>Solwin_AttributeImage_Model_Eav_Mysql4_Entity_Attribute_Option</entity_attribute_option>
|
34 |
+
</rewrite>
|
35 |
+
</eav_mysql4>
|
36 |
+
</models>
|
37 |
+
<blocks>
|
38 |
+
<adminhtml>
|
39 |
+
<rewrite>
|
40 |
+
<catalog_product_attribute_edit_tab_options>Solwin_AttributeImage_Block_Catalog_Product_Attribute_Edit_Tab_Options</catalog_product_attribute_edit_tab_options>
|
41 |
+
</rewrite>
|
42 |
+
</adminhtml>
|
43 |
+
</blocks>
|
44 |
+
<helpers>
|
45 |
+
<attributeimage>
|
46 |
+
<class>Solwin_AttributeImage_Helper</class>
|
47 |
+
</attributeimage>
|
48 |
+
<cms>
|
49 |
+
<rewrite>
|
50 |
+
<wysiwyg_images>Solwin_AttributeImage_Helper_Cms_Wysiwyg_Images</wysiwyg_images>
|
51 |
+
</rewrite>
|
52 |
+
</cms>
|
53 |
+
</helpers>
|
54 |
+
</global>
|
55 |
+
<admin>
|
56 |
+
<routers>
|
57 |
+
<adminhtml>
|
58 |
+
<args>
|
59 |
+
<modules>
|
60 |
+
<Solwin_AttributeImage before="Mage_Adminhtml">Solwin_AttributeImage</Solwin_AttributeImage>
|
61 |
+
</modules>
|
62 |
+
</args>
|
63 |
+
</adminhtml>
|
64 |
+
</routers>
|
65 |
+
</admin>
|
66 |
+
<adminhtml>
|
67 |
+
<events>
|
68 |
+
<controller_action_layout_render_before_adminhtml_catalog_product_attribute_edit>
|
69 |
+
<observers>
|
70 |
+
<update_layout>
|
71 |
+
<class>solwin_attributeimage/observer</class>
|
72 |
+
<method>updateLayout</method>
|
73 |
+
</update_layout>
|
74 |
+
</observers>
|
75 |
+
</controller_action_layout_render_before_adminhtml_catalog_product_attribute_edit>
|
76 |
+
</events>
|
77 |
+
</adminhtml>
|
78 |
+
</config>
|
app/code/community/Solwin/AttributeImage/sql/solwin_attributeimage_setup/mysql4-install-1.0.0.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$tableOption = $this->getTable('eav_attribute_option');
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
$installer->run("
|
9 |
+
ALTER TABLE `{$tableOption}`
|
10 |
+
ADD `image` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
|
11 |
+
");
|
12 |
+
|
13 |
+
$installer->run("
|
14 |
+
ALTER TABLE `{$tableOption}`
|
15 |
+
ADD `thumb` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
|
16 |
+
");
|
17 |
+
|
18 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/template/solwin/catalog/product/attribute/options.phtml
ADDED
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div>
|
2 |
+
<ul class="messages">
|
3 |
+
<li class="notice-msg">
|
4 |
+
<ul>
|
5 |
+
<li><?php echo Mage::helper('catalog')->__('If you do not specify an option value for a specific store view then the default (Admin) value will be used.') ?></li>
|
6 |
+
</ul>
|
7 |
+
</li>
|
8 |
+
</ul>
|
9 |
+
</div>
|
10 |
+
|
11 |
+
<div class="entity-edit">
|
12 |
+
<div class="entry-edit-head">
|
13 |
+
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('catalog')->__('Manage Titles (Size, Color, etc.)') ?></h4>
|
14 |
+
</div>
|
15 |
+
<div class="box">
|
16 |
+
<div class="hor-scroll">
|
17 |
+
<table class="dynamic-grid" cellspacing="0" id="attribute-labels-table">
|
18 |
+
<tr>
|
19 |
+
<?php foreach ($this->getStores() as $_store): ?>
|
20 |
+
<th><?php echo $_store->getName() ?></th>
|
21 |
+
<?php endforeach; ?>
|
22 |
+
</tr>
|
23 |
+
<tr>
|
24 |
+
<?php $_labels = $this->getLabelValues() ?>
|
25 |
+
<?php foreach ($this->getStores() as $_store): ?>
|
26 |
+
<td>
|
27 |
+
<input class="input-text<?php if($_store->getId()==0): ?> required-option<?php endif; ?>" type="text" name="frontend_label[<?php echo $_store->getId() ?>]" value="<?php echo $this->htmlEscape($_labels[$_store->getId()]) ?>"<?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/>
|
28 |
+
</td>
|
29 |
+
<?php endforeach; ?>
|
30 |
+
</tr>
|
31 |
+
</table>
|
32 |
+
</div>
|
33 |
+
</div>
|
34 |
+
</div>
|
35 |
+
<br/>
|
36 |
+
<div class="entity-edit" id="matage-options-panel">
|
37 |
+
<div class="entry-edit-head">
|
38 |
+
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('catalog')->__('Manage Options (values of your attribute)') ?></h4>
|
39 |
+
</div>
|
40 |
+
<div class="box">
|
41 |
+
<div class="hor-scroll">
|
42 |
+
<table class="dynamic-grid" cellspacing="0" cellpadding="0">
|
43 |
+
<tr id="attribute-options-table">
|
44 |
+
<?php foreach ($this->getStores() as $_store): ?>
|
45 |
+
<th><?php echo $_store->getName() ?></th>
|
46 |
+
<?php endforeach; ?>
|
47 |
+
<th><?php echo Mage::helper('catalog')->__('Position') ?></th>
|
48 |
+
<th class="nobr a-center"><?php echo Mage::helper('catalog')->__('Is Default') ?></th>
|
49 |
+
<th class="nobr"><?php echo Mage::helper('catalog')->__('Image') ?></th>
|
50 |
+
<th class="nobr"><?php echo Mage::helper('catalog')->__('Thumbnail') ?></th>
|
51 |
+
<th>
|
52 |
+
<?php if (!$this->getReadOnly()):?>
|
53 |
+
<?php echo $this->getAddNewButtonHtml() ?>
|
54 |
+
<?php endif;?>
|
55 |
+
</th>
|
56 |
+
</tr>
|
57 |
+
<tr class="no-display template" id="row-template">
|
58 |
+
<?php foreach ($this->getStores() as $_store): ?>
|
59 |
+
<td><input name="option[value][{{id}}][<?php echo $_store->getId() ?>]" value="{{store<?php echo $_store->getId() ?>}}" class="input-text<?php if($_store->getId()==0): ?> required-option<?php endif; ?>" type="text" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/></td>
|
60 |
+
<?php endforeach; ?>
|
61 |
+
<td class="a-center"><input class="input-text" type="text" name="option[order][{{id}}]" value="{{sort_order}}" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/></td>
|
62 |
+
<td><input class="input-radio" type="radio" name="default[]" value="{{id}}" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/></td>
|
63 |
+
<td class="a-left">
|
64 |
+
<input type="hidden" class="delete-flag" name="option[delete][{{id}}]" value="" />
|
65 |
+
<?php if (!$this->getReadOnly()):?>
|
66 |
+
<?php echo $this->getDeleteButtonHtml() ?>
|
67 |
+
<?php endif;?>
|
68 |
+
</td>
|
69 |
+
</tr>
|
70 |
+
</table>
|
71 |
+
</div>
|
72 |
+
<input type="hidden" id="option-count-check" value="" />
|
73 |
+
</div>
|
74 |
+
</div>
|
75 |
+
<script type="text/javascript">
|
76 |
+
//<![CDATA[
|
77 |
+
var optionDefaultInputType = 'radio';
|
78 |
+
|
79 |
+
// IE removes quotes from element.innerHTML whenever it thinks they're not needed, which breaks html.
|
80 |
+
var templateText =
|
81 |
+
'<tr class="option-row">'+
|
82 |
+
<?php foreach ($this->getStores() as $_store): ?>
|
83 |
+
'<td><input name="option[value][{{id}}][<?php echo $_store->getId() ?>]" value="{{store<?php echo $_store->getId() ?>}}" class="input-text<?php if($_store->getId()==0): ?> required-option<?php endif; ?>" type="text" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/><\/td>'+
|
84 |
+
<?php endforeach; ?>
|
85 |
+
'<td><input class="input-text" type="text" name="option[order][{{id}}]" value="{{sort_order}}" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/><\/td>'+
|
86 |
+
'<td class="a-center"><input class="input-radio" type="{{intype}}" name="default[]" value="{{id}}" {{checked}} <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/><\/td>'+
|
87 |
+
'<td class="nobr"><input id="option_image_{{id}}" type="text" name="option[image][{{id}}]" value="{{image}}" class="attribute_option_image" style="width:300px;" /><button id="add_image_{{id}}" class="scalable" type="button" onclick="MediabrowserUtility.openDialog(\'<?php echo Mage::getSingleton('adminhtml/url')->getUrl('*/cms_wysiwyg_images/index', array('static_urls_allowed' => 1)) ?>target_element_id/option_image_{{id}}/\');"><span>...</span></button></td>'+
|
88 |
+
'<td class="nobr"><input id="option_thumb_{{id}}" type="text" name="option[thumb][{{id}}]" value="{{thumb}}" class="attribute_option_image" style="width:200px;" /><button id="add_thumb_{{id}}" class="scalable" type="button" onclick="MediabrowserUtility.openDialog(\'<?php echo Mage::getSingleton('adminhtml/url')->getUrl('*/cms_wysiwyg_images/index', array('static_urls_allowed' => 1)) ?>target_element_id/option_thumb_{{id}}/\');"><span>...</span></button></td>'+
|
89 |
+
'<td class="a-left">'+
|
90 |
+
'<input type="hidden" class="delete-flag" name="option[delete][{{id}}]" value="" />'+
|
91 |
+
<?php if (!$this->getReadOnly()):?>
|
92 |
+
'<?php echo $this->getDeleteButtonHtml() ?>'+
|
93 |
+
<?php endif;?>
|
94 |
+
'<\/td>'+
|
95 |
+
'<\/tr>';
|
96 |
+
|
97 |
+
var attributeOption = {
|
98 |
+
table : $('attribute-options-table'),
|
99 |
+
templateSyntax : /(^|.|\r|\n)({{(\w+)}})/,
|
100 |
+
templateText : templateText,
|
101 |
+
itemCount : 0,
|
102 |
+
totalItems : 0,
|
103 |
+
add : function(data) {
|
104 |
+
this.template = new Template(this.templateText, this.templateSyntax);
|
105 |
+
if(!data.id){
|
106 |
+
data = {};
|
107 |
+
data.id = 'option_'+this.itemCount;
|
108 |
+
}
|
109 |
+
if (!data.intype)
|
110 |
+
data.intype = optionDefaultInputType;
|
111 |
+
|
112 |
+
Element.insert(this.table, {after: this.template.evaluate(data)});
|
113 |
+
this.bindRemoveButtons();
|
114 |
+
this.itemCount++;
|
115 |
+
this.totalItems++;
|
116 |
+
this.updateItemsCountField();
|
117 |
+
},
|
118 |
+
remove : function(event){
|
119 |
+
var element = $(Event.findElement(event, 'tr')); // !!! Button already
|
120 |
+
// have table parent in safari
|
121 |
+
// Safari workaround
|
122 |
+
element.ancestors().each(function(parentItem){
|
123 |
+
if (parentItem.hasClassName('option-row')) {
|
124 |
+
element = parentItem;
|
125 |
+
throw $break;
|
126 |
+
} else if (parentItem.hasClassName('box')) {
|
127 |
+
throw $break;
|
128 |
+
}
|
129 |
+
});
|
130 |
+
|
131 |
+
|
132 |
+
if(element){
|
133 |
+
var elementFlags = element.getElementsByClassName('delete-flag');
|
134 |
+
if(elementFlags[0]){
|
135 |
+
elementFlags[0].value=1;
|
136 |
+
}
|
137 |
+
|
138 |
+
element.addClassName('no-display');
|
139 |
+
element.addClassName('template');
|
140 |
+
element.hide();
|
141 |
+
this.totalItems--;
|
142 |
+
this.updateItemsCountField();
|
143 |
+
}
|
144 |
+
},
|
145 |
+
updateItemsCountField: function() {
|
146 |
+
if (this.totalItems > 0) {
|
147 |
+
$('option-count-check').value = '1';
|
148 |
+
} else {
|
149 |
+
$('option-count-check').value = '';
|
150 |
+
}
|
151 |
+
},
|
152 |
+
bindRemoveButtons : function(){
|
153 |
+
var buttons = $$('.delete-option');
|
154 |
+
for(var i=0;i<buttons.length;i++){
|
155 |
+
if(!$(buttons[i]).binded){
|
156 |
+
$(buttons[i]).binded = true;
|
157 |
+
Event.observe(buttons[i], 'click', this.remove.bind(this));
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
}
|
163 |
+
if($('row-template')){
|
164 |
+
$('row-template').remove();
|
165 |
+
}
|
166 |
+
attributeOption.bindRemoveButtons();
|
167 |
+
|
168 |
+
if($('add_new_option_button')){
|
169 |
+
Event.observe('add_new_option_button', 'click', attributeOption.add.bind(attributeOption));
|
170 |
+
}
|
171 |
+
Validation.addAllThese([
|
172 |
+
['required-option', '<?php echo Mage::helper('catalog')->__('Failed') ?>', function(v) {
|
173 |
+
return !Validation.get('IsEmpty').test(v);
|
174 |
+
}]]);
|
175 |
+
Validation.addAllThese([
|
176 |
+
['required-options-count', '<?php echo Mage::helper('catalog')->__('Options is required') ?>', function(v) {
|
177 |
+
return !Validation.get('IsEmpty').test(v);
|
178 |
+
}]]);
|
179 |
+
<?php foreach ($this->getOptionValues() as $_value): ?>
|
180 |
+
attributeOption.add(<?php echo $_value->toJson() ?>);
|
181 |
+
<?php endforeach; ?>
|
182 |
+
//]]>
|
183 |
+
</script>
|
app/design/frontend/default/default/template/catalog/layer/filter.phtml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Template for filter items block
|
4 |
+
*
|
5 |
+
* @see Mage_Catalog_Block_Layer_Filter_Abstract
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
<ol>
|
9 |
+
<?php foreach ($this->getItems() as $_item): ?>
|
10 |
+
<li>
|
11 |
+
|
12 |
+
<?php $_img = $this->helper('attributeimage')->getAttributeImage($_item->getValue()); ?>
|
13 |
+
<?php if ($_img && $_item->getFilter()->getRequestVar() != 'cat'): ?>
|
14 |
+
<img src="<?php echo $this->escapeHtml($_img); ?>" alt="<?php echo $_item->getLabel(); ?>" />
|
15 |
+
<?php endif; ?>
|
16 |
+
<?php if ($_item->getCount() > 0): ?>
|
17 |
+
<a href="<?php echo $this->urlEscape($_item->getUrl()); ?>"><?php echo $_item->getLabel(); ?></a>
|
18 |
+
<?php else: echo $_item->getLabel(); ?>
|
19 |
+
<?php endif; ?>
|
20 |
+
<?php if ($this->shouldDisplayProductCount()): ?>
|
21 |
+
(<?php echo $_item->getCount(); ?>)
|
22 |
+
<?php endif; ?>
|
23 |
+
</li>
|
24 |
+
<?php endforeach ?>
|
25 |
+
</ol>
|
app/etc/modules/Solwin_AttributeImage.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Solwin_AttributeImage>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Solwin_AttributeImage>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Solwin_AttributeImage</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>This extension add images to attribute options displayed in layered navigation.</summary>
|
10 |
+
<description>This extension associate images to product attributes options and easily manageable from admin side.
|
11 |
+
Main Features:
|
12 |
+
1. Associate main image & thumb image to product attributes options.
|
13 |
+
2. Display images easily in layered navigation.</description>
|
14 |
+
<notes>Release with no bugs.</notes>
|
15 |
+
<authors><author><name>Sanjay Dabhoya</name><user>solwin</user><email>stdabhoya@yahoo.com</email></author></authors>
|
16 |
+
<date>2015-07-23</date>
|
17 |
+
<time>04:40:55</time>
|
18 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Solwin_AttributeImage.xml" hash="eaa47bdae3740fcefee9d44038ea0a56"/></dir></target><target name="magecommunity"><dir name="Solwin"><dir name="AttributeImage"><dir name="Block"><dir name="Catalog"><dir name="Product"><dir name="Attribute"><dir name="Edit"><dir name="Tab"><file name="Options.php" hash="458a8cc0d146076ff86ef966a3e3ef6c"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><dir name="Cms"><dir name="Wysiwyg"><file name="Images.php" hash="3fe53494c56e168b1962d1f7cceaac9c"/></dir></dir><file name="Data.php" hash="6bbeedcd8ac57dec284bf81e0b73c491"/></dir><dir name="Model"><dir name="Catalog"><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Attribute.php" hash="41c098b9f24bf63725f9ba904969f351"/></dir></dir></dir></dir><dir name="Eav"><dir name="Entity"><dir name="Attribute"><dir name="Source"><file name="Table.php" hash="a5f795db6c5b2a5555c3e95aa2843666"/></dir></dir></dir><dir name="Mysql4"><dir name="Entity"><dir name="Attribute"><file name="Option.php" hash="7344c66933539e059d0ad7beb22fcdd6"/></dir></dir></dir></dir><file name="Observer.php" hash="5f9de7bb0ded4d476b7d2db44f72782c"/><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="cd17e49c9fdf966c75b622b06954ff42"/></dir></dir></dir><dir name="controllers"><dir name="Cms"><dir name="Wysiwyg"><file name="ImagesController.php" hash="ee4dba1e23d8324059787418da5b0c0f"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="ad60b5aeb29a92c7d0f58e31b3d1fe75"/></dir><dir name="sql"><dir name="solwin_attributeimage_setup"><file name="mysql4-install-1.0.0.php" hash="208d57da4f03c74c8d61f3f9559ec59a"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="solwin"><dir name="catalog"><dir name="product"><dir name="attribute"><file name="options.phtml" hash="fc0f07f8d9b623dee95844dfcf860360"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="catalog"><dir name="layer"><file name="filter.phtml" hash="669a6641ff6e6800e6ea3e0ec8e7cd2d"/></dir></dir></dir></dir></dir></dir></target></contents>
|
19 |
+
<compatible/>
|
20 |
+
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
21 |
+
</package>
|