Product_sort_by_webline - Version 0.1.0

Version Notes

Product sort by webline extenstion

Download this release

Release Info

Developer Atul Mehta
Extension Product_sort_by_webline
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/local/Wli/Productsortbywebline/Block/Adminhtml/Catalog/Product/Grid.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Webline Magento
4
+ *
5
+ * Adminhtml product grid block
6
+ *
7
+ * @category Wli
8
+ * @package Wli_Productsortbywebline
9
+ * @author Webline Magento Team
10
+ */
11
+ class Wli_Productsortbywebline_Block_Adminhtml_Catalog_Product_Grid extends Mage_Adminhtml_Block_Catalog_Product_Grid
12
+ {
13
+ public function setCollection($collection)
14
+ {
15
+ $store = $this->_getStore();
16
+
17
+ $moduleName = 'Wli_Productsortbywebline';
18
+ if(Mage::helper('core')->isModuleEnabled($moduleName))
19
+ {
20
+ if ($store->getId() && !isset($this->_joinAttributes['wli_sort_order'])) {
21
+ $collection->joinAttribute(
22
+ 'wli_sort_order',
23
+ 'catalog_product/wli_sort_order',
24
+ 'entity_id',
25
+ null,
26
+ 'left',
27
+ $store->getId()
28
+ );
29
+ }
30
+ else {
31
+ $collection->addAttributeToSelect('wli_sort_order');
32
+ }
33
+ }
34
+ parent::setCollection($collection);
35
+ }
36
+
37
+ protected function _prepareColumns()
38
+ {
39
+ $store = $this->_getStore();
40
+ $moduleName = 'Wli_Productsortbywebline';
41
+ if(Mage::helper('core')->isModuleEnabled($moduleName))
42
+ {
43
+ $this->addColumnAfter('wli_sort_order',
44
+ array(
45
+ 'header'=> Mage::helper('catalog')->__('Sort Order'),
46
+ 'width' => '50px',
47
+ 'type' => 'text',
48
+ 'index' => 'wli_sort_order',
49
+ 'align' => 'right',
50
+ ),
51
+ 'qty');
52
+ }
53
+ return parent::_prepareColumns();
54
+ }
55
+
56
+ protected function getAttributeOptions($_attributeCode) {
57
+
58
+ $options = array();
59
+
60
+ $collection = Mage::getModel('eav/entity_attribute_option')->getCollection()
61
+ ->setStoreFilter()
62
+ ->join('attribute','attribute.attribute_id=main_table.attribute_id', 'attribute_code');
63
+
64
+ foreach ($collection as $option) {
65
+ if ($option->getAttributeCode() == $_attributeCode) {
66
+ $options[$option->getOptionId()] = $option->getValue();
67
+ }
68
+ }
69
+ return $options;
70
+ }
71
+ }
app/code/local/Wli/Productsortbywebline/Block/Catalog/Product/List/Toolbar.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Webline Magento
4
+ *
5
+ * Catalog Product List Toolbar block
6
+ *
7
+ * @category Wli
8
+ * @package Wli_Productsortbywebline
9
+ * @author Webline Magento Team
10
+ */
11
+ class Wli_Productsortbywebline_Block_Catalog_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar
12
+ {
13
+ /**
14
+ * Override product collection
15
+ * wli_sort_order attribute to sort product collection
16
+ */
17
+ public function setCollection($collection)
18
+ {
19
+ $this->_collection = $collection;
20
+
21
+ $this->_collection->setCurPage($this->getCurrentPage());
22
+
23
+ // we need to set pagination only if passed value integer and more that 0
24
+ $limit = (int)$this->getLimit();
25
+ if ($limit) {
26
+ $this->_collection->setPageSize($limit);
27
+ }
28
+ if ($this->getCurrentOrder()) {
29
+ $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
30
+ }
31
+
32
+ /* sort by WLI SORT ORDER Custom attribute */
33
+ $this->_collection->setOrder('wli_sort_order', $this->getCurrentDirection());
34
+
35
+ return $this;
36
+ }
37
+ }
app/code/local/Wli/Productsortbywebline/etc/config.xml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Webline Magento
5
+ *
6
+ * @category Wli
7
+ * @package Wli_Productsortbywebline
8
+ * @author Webline Magento Team
9
+ */
10
+ -->
11
+ <config>
12
+ <modules>
13
+ <Wli_Productsortbywebline>
14
+ <version>0.1.0</version>
15
+ </Wli_Productsortbywebline>
16
+ </modules>
17
+ <global>
18
+ <resources>
19
+ <productsortbywebline_setup>
20
+ <setup>
21
+ <module>Wli_Productsortbywebline</module>
22
+ <class>Mage_Catalog_Model_Resource_Setup</class>
23
+ </setup>
24
+ <connection>
25
+ <use>core_setup</use>
26
+ </connection>
27
+ </productsortbywebline_setup>
28
+ <productsortbywebline_write>
29
+ <connection>
30
+ <use>core_write</use>
31
+ </connection>
32
+ </productsortbywebline_write>
33
+ <productsortbywebline_read>
34
+ <connection>
35
+ <use>core_read</use>
36
+ </connection>
37
+ </productsortbywebline_read>
38
+ </resources>
39
+ <blocks>
40
+ <productsortbywebline>
41
+ <class>Wli_Productsortbywebline_Block</class>
42
+ </productsortbywebline>
43
+ <adminhtml>
44
+ <rewrite>
45
+ <catalog_product_grid>Wli_Productsortbywebline_Block_Adminhtml_Catalog_Product_Grid</catalog_product_grid>
46
+ </rewrite>
47
+ </adminhtml>
48
+ <catalog>
49
+ <rewrite>
50
+ <product_list_toolbar>Wli_Productsortbywebline_Block_Catalog_Product_List_Toolbar</product_list_toolbar>
51
+ </rewrite>
52
+ </catalog>
53
+ </blocks>
54
+ </global>
55
+ </config>
app/code/local/Wli/Productsortbywebline/sql/productsortbywebline_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Webline Magento
4
+ *
5
+ * Setup for add Custom attribute "Sort order"
6
+ *
7
+ * @category Wli
8
+ * @package Wli_Productsortbywebline
9
+ * @author Webline Magento Team
10
+ */
11
+ $installer = $this;
12
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
13
+ $installer->startSetup();
14
+
15
+ $data=array(
16
+ 'type'=>'int',
17
+ 'input'=>'text',
18
+ 'sort_order'=> 1,
19
+ 'label'=>'Sort order',
20
+ 'global'=>Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
21
+ 'is_required'=>'0',
22
+ 'comparable'=>'0',
23
+ 'searchable'=>'0',
24
+ 'is_configurable'=>'1',
25
+ 'user_defined'=>'1',
26
+ 'default' => '',
27
+ 'visible_on_front' => 0,
28
+ 'visible_in_advanced_search' => 0,
29
+ 'is_html_allowed_on_front' => 0,
30
+ 'required'=> 0,
31
+ 'unique'=> true,
32
+ 'frontend_class'=>'validate-digits',
33
+ 'apply_to' => '',
34
+ 'is_configurable' => false
35
+ );
36
+
37
+ $installer->addAttribute('catalog_product','wli_sort_order',$data);
38
+ $installer->addAttributeToSet(
39
+ 'catalog_product', 'Default', 'General', 'wli_sort_order'
40
+ );
41
+ $installer->endSetup();
app/etc/modules/Wli_Productsortbywebline.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <!--
3
+ /**
4
+ * Webline Magento
5
+ *
6
+ * @category Wli
7
+ * @package Wli_Productsortbywebline
8
+ * @author Webline Magento Team
9
+ */
10
+ -->
11
+ <config>
12
+ <modules>
13
+ <Wli_Productsortbywebline>
14
+ <active>true</active>
15
+ <codePool>local</codePool>
16
+ <depends>
17
+ <Mage_Catalog />
18
+ <Mage_Adminhtml />
19
+ </depends>
20
+ </Wli_Productsortbywebline>
21
+ </modules>
22
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Product_sort_by_webline</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Product sort by webline extenstion</summary>
10
+ <description>Product sort by webline, is a Magento extension. We've created the Product sort extension to order catalog by custom order with magento default odering. Apply our custom sort order, when products have same order in selected option. With using this extension you can create your own order to each product. This extension mainly usefull to add second level sort order to catalog products.</description>
11
+ <notes>Product sort by webline extenstion</notes>
12
+ <authors><author><name>Atul Mehta</name><user>webline</user><email>partners@weblineindia.com</email></author></authors>
13
+ <date>2015-09-22</date>
14
+ <time>09:59:39</time>
15
+ <contents><target name="magelocal"><dir name="Wli"><dir name="Productsortbywebline"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><file name="Grid.php" hash="0a86bf3a1af58ef1380bfc27a18425dc"/></dir></dir></dir><dir name="Catalog"><dir name="Product"><dir name="List"><file name="Toolbar.php" hash="cf47aeee95b250fea4cdb86b862af197"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="cc02f2e2bb0b93d8c7456fc3f5dc57a2"/></dir><dir name="sql"><dir name="productsortbywebline_setup"><file name="mysql4-install-0.1.0.php" hash="cb0bfbaf369a9f3e989d5b029e9b363b"/></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Wli_Productsortbywebline.xml" hash="2b3b056b8b0540244ae0a37c461730da"/></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>