Version Notes
First Search By Size extension
Download this release
Release Info
Developer | Iverve |
Extension | Ifuturz_Searchbysize |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/community/Ifuturz/Searchbysize/Helper/Data.php +4 -0
- app/code/community/Ifuturz/Searchbysize/Model/CatalogSearch/Advanced.php +101 -0
- app/code/community/Ifuturz/Searchbysize/Model/Mysql4/Searchbysize.php +10 -0
- app/code/community/Ifuturz/Searchbysize/Model/Mysql4/Searchbysize/Collection.php +9 -0
- app/code/community/Ifuturz/Searchbysize/Model/Searchbysize.php +10 -0
- app/code/community/Ifuturz/Searchbysize/controllers/Adminhtml/SearchbysizeController.php +104 -0
- app/code/community/Ifuturz/Searchbysize/controllers/IndexController.php +9 -0
- app/code/community/Ifuturz/Searchbysize/etc/config.xml +116 -0
- app/code/community/Ifuturz/Searchbysize/sql/searchbysize_setup/mysql4-install-0.1.0.php +20 -0
- app/design/adminhtml/default/default/layout/searchbysize.xml +8 -0
- app/design/adminhtml/default/default/template/searchbysize/form.phtml +126 -0
- app/design/frontend/default/default/layout/searchbysize.xml +12 -0
- app/design/frontend/default/default/template/searchbysize/advanced/searchbysize.phtml +123 -0
- app/etc/modules/Ifuturz_Searchbysize.xml +9 -0
- package.xml +21 -0
- skin/frontend/base/default/css/searchbysize.css +18 -0
- skin/frontend/base/default/images/searchicon.png +0 -0
app/code/community/Ifuturz/Searchbysize/Helper/Data.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Ifuturz_Searchbysize_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
}
|
app/code/community/Ifuturz/Searchbysize/Model/CatalogSearch/Advanced.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
include_once 'Mage/CatalogSearch/Model/Advanced.php';
|
3 |
+
class Ifuturz_Searchbysize_Model_CatalogSearch_Advanced extends Mage_CatalogSearch_Model_Advanced
|
4 |
+
{
|
5 |
+
public function addFilters($values)
|
6 |
+
{
|
7 |
+
$attributes = $this->getAttributes();
|
8 |
+
$hasConditions = false;
|
9 |
+
$allConditions = array();
|
10 |
+
|
11 |
+
foreach ($attributes as $attribute) {
|
12 |
+
/* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
|
13 |
+
if (!isset($values[$attribute->getAttributeCode()])) {
|
14 |
+
continue;
|
15 |
+
}
|
16 |
+
$value = $values[$attribute->getAttributeCode()];
|
17 |
+
|
18 |
+
if ($attribute->getAttributeCode() == 'price') {
|
19 |
+
$value['from'] = isset($value['from']) ? trim($value['from']) : '';
|
20 |
+
$value['to'] = isset($value['to']) ? trim($value['to']) : '';
|
21 |
+
if (is_numeric($value['from']) || is_numeric($value['to'])) {
|
22 |
+
if (!empty($value['currency'])) {
|
23 |
+
$rate = Mage::app()->getStore()->getBaseCurrency()->getRate($value['currency']);
|
24 |
+
} else {
|
25 |
+
$rate = 1;
|
26 |
+
}
|
27 |
+
if ($this->_getResource()->addRatedPriceFilter(
|
28 |
+
$this->getProductCollection(), $attribute, $value, $rate)
|
29 |
+
) {
|
30 |
+
$hasConditions = true;
|
31 |
+
$this->_addSearchCriteria($attribute, $value);
|
32 |
+
}
|
33 |
+
}
|
34 |
+
} else if ($attribute->isIndexable()) {
|
35 |
+
if (!is_string($value) || strlen($value) != 0) {
|
36 |
+
if ($this->_getResource()->addIndexableAttributeModifiedFilter(
|
37 |
+
$this->getProductCollection(), $attribute, $value)) {
|
38 |
+
$hasConditions = true;
|
39 |
+
$this->_addSearchCriteria($attribute, $value);
|
40 |
+
}
|
41 |
+
}
|
42 |
+
} else {
|
43 |
+
|
44 |
+
|
45 |
+
$condition = $this->_prepareCondition($attribute, $value);
|
46 |
+
if ($condition === false) {
|
47 |
+
continue;
|
48 |
+
}
|
49 |
+
|
50 |
+
$this->_addSearchCriteria($attribute, $value);
|
51 |
+
|
52 |
+
$table = $attribute->getBackend()->getTable();
|
53 |
+
if ($attribute->getBackendType() == 'static'){
|
54 |
+
$attributeId = $attribute->getAttributeCode();
|
55 |
+
} else {
|
56 |
+
$attributeId = $attribute->getId();
|
57 |
+
}
|
58 |
+
$allConditions[$table][$attributeId] = $condition;
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
/*if (($allConditions)*/
|
63 |
+
if (($allConditions) || (isset($values['category']) && is_numeric($values['category']))) {
|
64 |
+
$this->getProductCollection()->addFieldsToFilter($allConditions);
|
65 |
+
} else if (!$hasConditions) {
|
66 |
+
Mage::throwException(Mage::helper('catalogsearch')->__('Please specify at least one search term.'));
|
67 |
+
}
|
68 |
+
|
69 |
+
return $this;
|
70 |
+
}
|
71 |
+
|
72 |
+
|
73 |
+
public function getSearchCriterias()
|
74 |
+
{
|
75 |
+
$search = $this->_searchCriterias;
|
76 |
+
/* display category filtering criteria */
|
77 |
+
if(isset($_GET['category']) && is_numeric($_GET['category'])) {
|
78 |
+
$category = Mage::getModel('catalog/category')->load($_GET['category']);
|
79 |
+
$search[] = array('name'=>'Category','value'=>$category->getName());
|
80 |
+
}
|
81 |
+
return $search;
|
82 |
+
}
|
83 |
+
|
84 |
+
public function getProductCollection()
|
85 |
+
{
|
86 |
+
if (is_null($this->_productCollection))
|
87 |
+
{
|
88 |
+
$this->_productCollection = Mage::getResourceModel('catalogsearch/advanced_collection')
|
89 |
+
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
|
90 |
+
->addMinimalPrice()
|
91 |
+
->addStoreFilter();
|
92 |
+
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($this->_productCollection);
|
93 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($this->_productCollection);
|
94 |
+
/* include category filtering */
|
95 |
+
if(isset($_GET['category']) && is_numeric($_GET['category'])) $this->_productCollection->addCategoryFilter(Mage::getModel('catalog/category')->load($_GET['category']),true);
|
96 |
+
}
|
97 |
+
|
98 |
+
return $this->_productCollection;
|
99 |
+
}
|
100 |
+
|
101 |
+
}
|
app/code/community/Ifuturz/Searchbysize/Model/Mysql4/Searchbysize.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Ifuturz_Searchbysize_Model_Mysql4_Searchbysize extends Mage_Core_Model_Mysql4_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
// Note that the coupon_id refers to the key field in your database table.
|
7 |
+
$this->_init('searchbysize/searchbysize', 'searchsize_id');
|
8 |
+
}
|
9 |
+
|
10 |
+
}
|
app/code/community/Ifuturz/Searchbysize/Model/Mysql4/Searchbysize/Collection.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Ifuturz_Searchbysize_Model_Mysql4_Searchbysize_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->_init('searchbysize/searchbysize');
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Ifuturz/Searchbysize/Model/Searchbysize.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Ifuturz_Searchbysize_Model_Searchbysize extends Mage_Core_Model_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->_init('searchbysize/searchbysize');
|
8 |
+
}
|
9 |
+
|
10 |
+
}
|
app/code/community/Ifuturz/Searchbysize/controllers/Adminhtml/SearchbysizeController.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Ifuturz_Searchbysize_Adminhtml_SearchbysizeController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
+
protected function _initAction()
|
5 |
+
{
|
6 |
+
$this->loadLayout()
|
7 |
+
->_setActiveMenu('searchbysize')
|
8 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Search By Size'), Mage::helper('adminhtml')->__('Coupon Category Management'));
|
9 |
+
|
10 |
+
return $this;
|
11 |
+
}
|
12 |
+
|
13 |
+
public function indexAction()
|
14 |
+
{
|
15 |
+
$this->_initAction()
|
16 |
+
->renderLayout();
|
17 |
+
}
|
18 |
+
public function editAction() {
|
19 |
+
$id = $this->getRequest()->getParam('id');
|
20 |
+
$model = Mage::getModel('searchbysize/searchbysize')->load($id);
|
21 |
+
|
22 |
+
if ($model->getId() || $id == 0) {
|
23 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
24 |
+
if (!empty($data)) {
|
25 |
+
$model->setData($data);
|
26 |
+
}
|
27 |
+
/* if($id!=0)
|
28 |
+
{
|
29 |
+
Mage::register('region_reload', $model);
|
30 |
+
}
|
31 |
+
*/
|
32 |
+
Mage::register('searchbysize_data', $model);
|
33 |
+
|
34 |
+
$this->loadLayout();
|
35 |
+
$this->_setActiveMenu('searchbysize');
|
36 |
+
|
37 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Special Offer Message Management'), Mage::helper('adminhtml')->__('Special Offer Message Management'));
|
38 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Rule News'), Mage::helper('adminhtml')->__('Rule News'));
|
39 |
+
|
40 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
41 |
+
|
42 |
+
$this->renderLayout();
|
43 |
+
} else {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('searchbysize')->__('Message does not exist'));
|
45 |
+
$this->_redirect('*/*/');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
public function saveAction()
|
49 |
+
{
|
50 |
+
$width = $this->getRequest()->getParam('width');
|
51 |
+
$depth = $this->getRequest()->getParam('depth');
|
52 |
+
$height = $this->getRequest()->getParam('height');
|
53 |
+
|
54 |
+
$width = implode(",",$width);
|
55 |
+
$depth = implode(",",$depth);
|
56 |
+
$height = implode(",",$height);
|
57 |
+
|
58 |
+
//echo $width."<br>"; echo $depth."<br>"; echo $height;die;
|
59 |
+
|
60 |
+
$model = Mage::getModel('searchbysize/searchbysize');
|
61 |
+
$collection = $model->getCollection();
|
62 |
+
if(count($collection)==0)
|
63 |
+
{
|
64 |
+
$model->setWidth($width)
|
65 |
+
->setDepth($depth)
|
66 |
+
->setheight($height)
|
67 |
+
->setId($this->getRequest()->getParam('id'));
|
68 |
+
try
|
69 |
+
{
|
70 |
+
$model->save();
|
71 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('searchbysize')->__('Sizes are successfully saved'));
|
72 |
+
//Mage::getSingleton('adminhtml/session')->setFormData(false);
|
73 |
+
$this->_redirect('*/*/');
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
catch (Exception $e)
|
77 |
+
{
|
78 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
79 |
+
//Mage::getSingleton('adminhtml/session')->setFormData($data);
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
else
|
84 |
+
{
|
85 |
+
try
|
86 |
+
{
|
87 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
88 |
+
$connection->query("UPDATE ifuturz_searchbysize SET width='$width',depth='$depth',height='$height'");
|
89 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('searchbysize')->__('Sizes are successfully saved'));
|
90 |
+
$this->_redirect('*/*/');
|
91 |
+
return;
|
92 |
+
}
|
93 |
+
catch(Exception $e)
|
94 |
+
{
|
95 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
96 |
+
return;
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('searchbysize')->__('Unable to find User to save'));
|
101 |
+
$this->_redirect('*/*/');
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
app/code/community/Ifuturz/Searchbysize/controllers/IndexController.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Ifuturz_Searchbysize_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
|
5 |
+
public function indexAction()
|
6 |
+
{
|
7 |
+
$this->loadLayout()->renderLayout();
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Ifuturz/Searchbysize/etc/config.xml
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" ?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Ifuturz_Searchbysize>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Ifuturz_Searchbysize>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<searchbysize>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Ifuturz_Searchbysize</module>
|
14 |
+
<frontName>searchbysize</frontName>
|
15 |
+
</args>
|
16 |
+
</searchbysize>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<searchbysize>
|
21 |
+
<file>searchbysize.xml</file>
|
22 |
+
</searchbysize>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<searchbysize>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>Ifuturz_Searchbysize</module>
|
32 |
+
<frontName>searchbysize</frontName>
|
33 |
+
</args>
|
34 |
+
</searchbysize>
|
35 |
+
</routers>
|
36 |
+
</admin>
|
37 |
+
<adminhtml>
|
38 |
+
<menu>
|
39 |
+
<searchbysize module="searchbysize">
|
40 |
+
<title>Search by Sizes</title>
|
41 |
+
<sort_order>100</sort_order>
|
42 |
+
<action>searchbysize/adminhtml_searchbysize</action>
|
43 |
+
</searchbysize>
|
44 |
+
</menu>
|
45 |
+
<acl>
|
46 |
+
<resources>
|
47 |
+
<admin>
|
48 |
+
<children>
|
49 |
+
<searchbysize translate="title">
|
50 |
+
<title>Search by Sizes</title>
|
51 |
+
<sort_order>120</sort_order>
|
52 |
+
</searchbysize>
|
53 |
+
</children>
|
54 |
+
</admin>
|
55 |
+
</resources>
|
56 |
+
</acl>
|
57 |
+
<layout>
|
58 |
+
<updates>
|
59 |
+
<searchbysize>
|
60 |
+
<file>searchbysize.xml</file>
|
61 |
+
</searchbysize>
|
62 |
+
</updates>
|
63 |
+
</layout>
|
64 |
+
</adminhtml>
|
65 |
+
<global>
|
66 |
+
<models>
|
67 |
+
<catalogsearch>
|
68 |
+
<rewrite>
|
69 |
+
<advanced>Ifuturz_Searchbysize_Model_CatalogSearch_Advanced</advanced>
|
70 |
+
</rewrite>
|
71 |
+
</catalogsearch>
|
72 |
+
<searchbysize>
|
73 |
+
<class>Ifuturz_Searchbysize_Model</class>
|
74 |
+
<resourceModel>searchbysize_mysql4</resourceModel>
|
75 |
+
</searchbysize>
|
76 |
+
<searchbysize_mysql4>
|
77 |
+
<class>Ifuturz_Searchbysize_Model_Mysql4</class>
|
78 |
+
<entities>
|
79 |
+
<searchbysize>
|
80 |
+
<table>ifuturz_searchbysize</table>
|
81 |
+
</searchbysize>
|
82 |
+
</entities>
|
83 |
+
</searchbysize_mysql4>
|
84 |
+
</models>
|
85 |
+
<resources>
|
86 |
+
<searchbysize_setup>
|
87 |
+
<setup>
|
88 |
+
<module>Ifuturz_Searchbysize</module>
|
89 |
+
</setup>
|
90 |
+
<connection>
|
91 |
+
<use>core_setup</use>
|
92 |
+
</connection>
|
93 |
+
</searchbysize_setup>
|
94 |
+
<searchbysize_write>
|
95 |
+
<connection>
|
96 |
+
<use>core_write</use>
|
97 |
+
</connection>
|
98 |
+
</searchbysize_write>
|
99 |
+
<searchbysize_read>
|
100 |
+
<connection>
|
101 |
+
<use>core_read</use>
|
102 |
+
</connection>
|
103 |
+
</searchbysize_read>
|
104 |
+
</resources>
|
105 |
+
<blocks>
|
106 |
+
<searchbysize>
|
107 |
+
<class>Ifuturz_Searchbysize_Block</class>
|
108 |
+
</searchbysize>
|
109 |
+
</blocks>
|
110 |
+
<helpers>
|
111 |
+
<searchbysize>
|
112 |
+
<class>Ifuturz_Searchbysize_Helper</class>
|
113 |
+
</searchbysize>
|
114 |
+
</helpers>
|
115 |
+
</global>
|
116 |
+
</config>
|
app/code/community/Ifuturz/Searchbysize/sql/searchbysize_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
-- DROP TABLE IF EXISTS {$this->getTable('ifuturz_searchbysize')};
|
10 |
+
CREATE TABLE {$this->getTable('ifuturz_searchbysize')} (
|
11 |
+
`searchsize_id` int(11) unsigned NOT NULL auto_increment,
|
12 |
+
`width` varchar(255),
|
13 |
+
`depth` varchar(255),
|
14 |
+
`height` varchar(255),
|
15 |
+
PRIMARY KEY (`searchsize_id`)
|
16 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
17 |
+
|
18 |
+
");
|
19 |
+
|
20 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/searchbysize.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<searchbysize_adminhtml_searchbysize_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="adminhtml/template" name="searchbysize" template="searchbysize/form.phtml"/>
|
6 |
+
</reference>
|
7 |
+
</searchbysize_adminhtml_searchbysize_index>
|
8 |
+
</layout>
|
app/design/adminhtml/default/default/template/searchbysize/form.phtml
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php //echo $this->getFormHtml() ?>
|
2 |
+
<div class="content-header">
|
3 |
+
<table cellspacing="0" class="grid-header">
|
4 |
+
<tr>
|
5 |
+
<td><h3><?=$this->__('Search By Size')?></h3></td>
|
6 |
+
<td class="a-right">
|
7 |
+
<button onclick="editForm.submit()" class="scalable save" type="button"><span>Save</span></button>
|
8 |
+
</td>
|
9 |
+
</tr>
|
10 |
+
</table>
|
11 |
+
</div>
|
12 |
+
<?php
|
13 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
14 |
+
|
15 |
+
$model = Mage::getModel('catalog/product');
|
16 |
+
$collection = $model->getCollection();
|
17 |
+
$productids = $collection->getAllIds();
|
18 |
+
|
19 |
+
$width = array();
|
20 |
+
$depth = array();
|
21 |
+
$height = array();
|
22 |
+
$attids1= $read->query("Select attribute_id from eav_attribute where attribute_code='width'");
|
23 |
+
$attidrow1 = $attids1->fetch();
|
24 |
+
$widthattid = $attidrow1['attribute_id'];
|
25 |
+
|
26 |
+
$attids2= $read->query("Select attribute_id from eav_attribute where attribute_code='depth'");
|
27 |
+
$attidrow2 = $attids2->fetch();
|
28 |
+
$depthattid = $attidrow2['attribute_id'];
|
29 |
+
|
30 |
+
$attids3= $read->query("Select attribute_id from eav_attribute where attribute_code='height'");
|
31 |
+
$attidrow3 = $attids3->fetch();
|
32 |
+
$heightattid = $attidrow3['attribute_id'];
|
33 |
+
|
34 |
+
foreach($productids as $id)
|
35 |
+
{
|
36 |
+
|
37 |
+
|
38 |
+
$widthvalue = $read->query("Select value from catalog_product_entity_varchar where attribute_id='$widthattid' and entity_id='$id'");
|
39 |
+
$widthrow = $widthvalue->fetch();
|
40 |
+
if($widthrow['value']!='')
|
41 |
+
{
|
42 |
+
$width[] = $widthrow['value'];
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
$depthvalue =$read->query("Select value from catalog_product_entity_varchar where attribute_id='$depthattid' and entity_id='$id'");
|
48 |
+
$depthrow = $depthvalue->fetch();
|
49 |
+
if($depthrow['value']!='')
|
50 |
+
{
|
51 |
+
$depth[] = $depthrow['value'];
|
52 |
+
}
|
53 |
+
|
54 |
+
|
55 |
+
$heightvalue =$read->query("Select value from catalog_product_entity_varchar where attribute_id='$heightattid' and entity_id='$id'");
|
56 |
+
$heightrow = $heightvalue->fetch();
|
57 |
+
if($heightrow['value']!='')
|
58 |
+
{
|
59 |
+
$height[] = $heightrow['value'];
|
60 |
+
}
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
$ww = array_unique($width);
|
65 |
+
$dd = array_unique($depth);
|
66 |
+
$hh = array_unique($height);
|
67 |
+
|
68 |
+
sort($ww, SORT_NUMERIC);
|
69 |
+
sort($dd, SORT_NUMERIC);
|
70 |
+
sort($hh, SORT_NUMERIC);
|
71 |
+
?>
|
72 |
+
<?php
|
73 |
+
$model = Mage::getModel('searchbysize/searchbysize')->getCollection();
|
74 |
+
$temp = $model->getData();
|
75 |
+
$width = $temp[0]['width'];
|
76 |
+
$depth = $temp[0]['depth'];
|
77 |
+
$height = $temp[0]['height'];
|
78 |
+
|
79 |
+
$exwidth = explode(',',$width);
|
80 |
+
$exdepth = explode(',',$depth);
|
81 |
+
$exheight = explode(',',$height);
|
82 |
+
|
83 |
+
|
84 |
+
?>
|
85 |
+
|
86 |
+
<div class="entry-edit">
|
87 |
+
<form id="edit_form" name="edit_form" method="post" action="<?=$this->getUrl('*/*/save')?>">
|
88 |
+
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
89 |
+
<h4 class="icon-head head-edit-form fieldset-legend"><?=$this->__('Allowed Sizes')?></h4>
|
90 |
+
<fieldset id="my-fieldset">
|
91 |
+
<table cellspacing="0" class="form-list">
|
92 |
+
<tr>
|
93 |
+
<td class="label" align="center"><?=$this->__('Width')?> <span class="required">*</span></td>
|
94 |
+
<td><select name="width[]" size="10" multiple>
|
95 |
+
<!--<option value='' selected>-- Select Width --</option>-->
|
96 |
+
<?php foreach($ww as $w):?>
|
97 |
+
<option value='<?php echo $w;?>'<?php if(in_array($w,$exwidth,true)):?>selected<?php endif; ?>><?php echo $w; ?></option>
|
98 |
+
<?php endforeach; ?>
|
99 |
+
</select>
|
100 |
+
</td>
|
101 |
+
|
102 |
+
<td class="label" align="center"><?=$this->__('Depth')?> <span class="required">*</span></td>
|
103 |
+
<td><select name="depth[]" size="10" multiple>
|
104 |
+
<!--<option value='' selected>-- Select Width --</option>-->
|
105 |
+
<?php foreach($dd as $d):?>
|
106 |
+
<option value='<?php echo $d; ?>'<?php if(in_array($d,$exdepth,true)):?>//selected<?php endif; ?>><?php echo $d; ?></option>
|
107 |
+
<?php endforeach; ?>
|
108 |
+
</select>
|
109 |
+
</td>
|
110 |
+
|
111 |
+
<td class="label" align="center"><?=$this->__('Height')?> <span class="required">*</span></td>
|
112 |
+
<td><select name="height[]" size="10" multiple>
|
113 |
+
<!--<option value='' selected>-- Select Width --</option>-->
|
114 |
+
<?php foreach($hh as $h):?>
|
115 |
+
<option value='<?php echo $h; ?>'<?php if(in_array($h,$exheight,true)):?>selected<?php endif; ?>><?php echo $h; ?></option>
|
116 |
+
<?php endforeach; ?>
|
117 |
+
</select>
|
118 |
+
</td>
|
119 |
+
</tr>
|
120 |
+
</table>
|
121 |
+
</fieldset>
|
122 |
+
</form>
|
123 |
+
</div>
|
124 |
+
<script type="text/javascript">
|
125 |
+
var editForm = new varienForm('edit_form');
|
126 |
+
</script>
|
app/design/frontend/default/default/layout/searchbysize.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addCss"><stylesheet>css/searchbysize.css</stylesheet></action>
|
6 |
+
</reference>
|
7 |
+
<reference name="right">
|
8 |
+
<block type="catalogsearch/advanced_form" before="-" name="catalog_size_sidebar" template="searchbysize/advanced/searchbysize.phtml"/>
|
9 |
+
</reference>
|
10 |
+
|
11 |
+
</default>
|
12 |
+
</layout>
|
app/design/frontend/default/default/template/searchbysize/advanced/searchbysize.phtml
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="block block-list block-searchsize">
|
2 |
+
<div class="block-title">
|
3 |
+
<strong><span class="block-new"><?php echo $this->__('Search By Size') ?></span></strong>
|
4 |
+
</div>
|
5 |
+
<?php
|
6 |
+
$layer = Mage::getSingleton('catalog/layer');
|
7 |
+
$_category = $layer->getCurrentCategory();
|
8 |
+
|
9 |
+
$currentCategoryname= $_category->getName();
|
10 |
+
$currentCategoryId = $_category->getEntity_id();
|
11 |
+
|
12 |
+
$cat_mod = Mage::getModel('catalog/category');
|
13 |
+
$helper = new Mage_Catalog_Helper_Category();
|
14 |
+
$_main_categories=$helper->getStoreCategories();
|
15 |
+
|
16 |
+
$model = Mage::getModel('searchbysize/searchbysize')->getCollection();
|
17 |
+
$temp = $model->getData();
|
18 |
+
$width = $temp[0]['width'];
|
19 |
+
$depth = $temp[0]['depth'];
|
20 |
+
$height = $temp[0]['height'];
|
21 |
+
|
22 |
+
$ww = explode(',',$width);
|
23 |
+
$dd = explode(',',$depth);
|
24 |
+
$hh = explode(',',$height);
|
25 |
+
|
26 |
+
?>
|
27 |
+
<div class="block-content block-content-search">
|
28 |
+
<form action="<?php echo $this->getUrl().'catalogsearch/advanced/result/'?>" name="searchform" method="get" id="form-validate" onSubmit="return checksearchform()">
|
29 |
+
<fieldset>
|
30 |
+
<ul>
|
31 |
+
<li>
|
32 |
+
<label for="width">Width </label>
|
33 |
+
<select title="width" class="searchsize" id="width" name="width">
|
34 |
+
<option value=''>-- Select Width --</option>
|
35 |
+
<?php foreach($ww as $w):?>
|
36 |
+
<?php if(isset($_GET['width'])): ?>
|
37 |
+
<?php if($w == $_GET['width']): ?>
|
38 |
+
<option value='<?php echo $w; ?>'selected><?php echo $_GET['width']; ?></option>
|
39 |
+
<?php else: ?>
|
40 |
+
<option value='<?php echo $w; ?>'><?php echo $w; ?></option>
|
41 |
+
<?php endif; ?>
|
42 |
+
<?php else: ?>
|
43 |
+
<option value='<?php echo $w; ?>'><?php echo $w; ?></option>
|
44 |
+
<?php endif; ?>
|
45 |
+
<?php endforeach; ?>
|
46 |
+
</select>
|
47 |
+
<br><br>
|
48 |
+
<label for="depth">Depth </label>
|
49 |
+
<select title="depth" class="searchsize" id="depth" name="depth">
|
50 |
+
<option value=''>-- Select Depth --</option>
|
51 |
+
|
52 |
+
<?php foreach($dd as $d):?>
|
53 |
+
<?php if(isset($_GET['depth'])): ?>
|
54 |
+
<?php if($d == $_GET['depth']): ?>
|
55 |
+
<option value='<?php echo $d; ?>'selected><?php echo $_GET['depth']; ?></option>
|
56 |
+
<?php else: ?>
|
57 |
+
<option value='<?php echo $d; ?>'><?php echo $d; ?></option>
|
58 |
+
<?php endif; ?>
|
59 |
+
<?php else: ?>
|
60 |
+
<option value='<?php echo $d; ?>'><?php echo $d; ?></option>
|
61 |
+
<?php endif; ?>
|
62 |
+
<?php endforeach; ?>
|
63 |
+
</select>
|
64 |
+
<br><br>
|
65 |
+
<label for="height">Height</label>
|
66 |
+
<select title="height" class="searchsize" id="height" name="height">
|
67 |
+
<option value=''>-- Select Height --</option>
|
68 |
+
|
69 |
+
<?php foreach($hh as $h):?>
|
70 |
+
<?php if(isset($_GET['height'])): ?>
|
71 |
+
<?php if($h == $_GET['height']): ?>
|
72 |
+
<option value='<?php echo $h; ?>'selected><?php echo $_GET['height']; ?></option>
|
73 |
+
<?php else: ?>
|
74 |
+
<option value='<?php echo $h; ?>'><?php echo $h; ?></option>
|
75 |
+
<?php endif; ?>
|
76 |
+
<?php else: ?>
|
77 |
+
<option value='<?php echo $h; ?>'><?php echo $h; ?></option>
|
78 |
+
<?php endif; ?>
|
79 |
+
<?php endforeach; ?>
|
80 |
+
</select>
|
81 |
+
|
82 |
+
<br><br>
|
83 |
+
<label for="category"><?php echo $this->__("Category")?></label>
|
84 |
+
<select class="searchsize" id="category" name="category">
|
85 |
+
<option value=''><?php echo $this->__("-Select Category-")?></option>
|
86 |
+
<?php if ($_main_categories): ?>
|
87 |
+
<?php foreach ($_main_categories as $_main_category): ?>
|
88 |
+
<?php if($_main_category->getIsActive()): ?>
|
89 |
+
<?php $cid = $_main_category->getId();
|
90 |
+
$cur_category = $cat_mod->load($cid); ?>
|
91 |
+
<?php $category_name = $cur_category->getName(); ?>
|
92 |
+
<option title="<?php echo $category_name; ?>" value='<?php echo $cur_category->getEntity_id(); ?>'<?php if(isset($_GET['category']) && $cur_category->getEntity_id()==$_GET['category']):?>selected<?php endif; ?>><?php echo $category_name; ?></option>
|
93 |
+
<?php endif; ?>
|
94 |
+
<?php endforeach; ?>
|
95 |
+
<?php endif; ?>
|
96 |
+
</select>
|
97 |
+
|
98 |
+
</li>
|
99 |
+
</ul>
|
100 |
+
<script type="text/javascript">decorateList('advanced-search-list')</script>
|
101 |
+
</fieldset>
|
102 |
+
|
103 |
+
<div class="button-set">
|
104 |
+
<button class="form-button" type="submit"><span><?php echo $this->__('Search') ?></span></button>
|
105 |
+
</div>
|
106 |
+
</form>
|
107 |
+
</div>
|
108 |
+
<script type="text/javascript">
|
109 |
+
var dataForm = new VarienForm('form-validate', true);
|
110 |
+
function checksearchform(searchform)
|
111 |
+
{
|
112 |
+
if(document.getElementById('width').value == '' && document.getElementById('depth').value == '' && document.getElementById('height').value == '' ) {
|
113 |
+
alert('Please select atleast one option to search.');
|
114 |
+
return false;
|
115 |
+
} else {
|
116 |
+
return true;
|
117 |
+
}
|
118 |
+
}
|
119 |
+
</script>
|
120 |
+
|
121 |
+
|
122 |
+
</div>
|
123 |
+
<!-- [ends] .cart-sidebar // -->
|
app/etc/modules/Ifuturz_Searchbysize.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Ifuturz_Searchbysize>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Ifuturz_Searchbysize>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Ifuturz_Searchbysize</name>
|
4 |
+
<version>0.1.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>Search the product by size that is width, height, depth of the product along with the categories.</summary>
|
10 |
+
<description>This extension allows for a customer to search the products by its size. It is more convenient for the products like Lokcers, benches, tables, cupboard.. In short the product which have a width, height and depth.
|
11 |
+
- Search by size will display on right sidebar. Here four drop-down/selection boxes are given to user that is width, depth, height and category to search the products as per their needs. 
|
12 |
+
- Note that width, depth, heigth box contains only those sizes which are allowed by admin from admin-panel.
|
13 |
+
</description>
|
14 |
+
<notes>First Search By Size extension</notes>
|
15 |
+
<authors><author><name>Iverve</name><user>iverve</user><email>extension.geek@ifuturz.com</email></author></authors>
|
16 |
+
<date>2014-01-08</date>
|
17 |
+
<time>09:15:02</time>
|
18 |
+
<contents><target name="magecommunity"><dir name="Ifuturz"><dir name="Searchbysize"><dir name="Helper"><file name="Data.php" hash="86b900b274a15cae78c8a18b12a375af"/></dir><dir name="Model"><dir name="CatalogSearch"><file name="Advanced.php" hash="88ff37fd3be7e94d1cde75a8bf9abdd8"/></dir><dir name="Mysql4"><dir name="Searchbysize"><file name="Collection.php" hash="1f7bf17422f73c23468c9750b3496302"/></dir><file name="Searchbysize.php" hash="e6af4293f660e4559d665a92309d4313"/></dir><file name="Searchbysize.php" hash="75770324e1d0dc2bd169af6b1d196550"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SearchbysizeController.php" hash="93460b96e914994d68ec2228ab46e7a8"/></dir><file name="IndexController.php" hash="aff304f0991b31117a71074192ded694"/></dir><dir name="etc"><file name="config.xml" hash="da282805474221b5b92220d43cd9f766"/></dir><dir name="sql"><dir name="searchbysize_setup"><file name="mysql4-install-0.1.0.php" hash="ed334a44e9afce7f9ff8336998a21a1e"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="searchbysize.xml" hash="ae940118e665575d5607aab82c88b202"/></dir><dir name="template"><dir name="searchbysize"><file name="form.phtml" hash="34d52ba21b8216182a58f560ae9f4596"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="searchbysize.xml" hash="1819e0ece647f8906284dc8d4e32273c"/></dir><dir name="template"><dir name="searchbysize"><dir name="advanced"><file name="searchbysize.phtml" hash="d8c5a2b457e031e27cf0a5abe8ca969b"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ifuturz_Searchbysize.xml" hash="d75111753fee32e0a18812c301d0e165"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="searchbysize.css" hash="17d9fa42bc6027e8bb3f4c909f81e20a"/></dir><dir name="images"><file name="searchicon.png" hash="93d958211da51b1797fd7a0b38608e45"/></dir></dir></dir></dir></target></contents>
|
19 |
+
<compatible/>
|
20 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
21 |
+
</package>
|
skin/frontend/base/default/css/searchbysize.css
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.block-title strong
|
2 |
+
{
|
3 |
+
background-image: url("../images/searchicon.png");
|
4 |
+
background-repeat:no-repeat;
|
5 |
+
}
|
6 |
+
.block-new
|
7 |
+
{
|
8 |
+
padding-left:15px;
|
9 |
+
}
|
10 |
+
.block-content select
|
11 |
+
{
|
12 |
+
float:right;
|
13 |
+
width:115px;
|
14 |
+
}
|
15 |
+
.block-content-search
|
16 |
+
{
|
17 |
+
padding:10px;
|
18 |
+
}
|
skin/frontend/base/default/images/searchicon.png
ADDED
Binary file
|