Version Notes
If you have ideas for improvements or find bugs, please send them to pektsekye@gmail.com
Download this release
Release Info
Developer | Magento Core Team |
Extension | Year_Make_Model_Filter_Box |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- app/code/local/Pektsekye/Catalog/Model/Category.php +97 -0
- app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm.php +12 -0
- app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Edit.php +45 -0
- app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Edit/Form.php +19 -0
- app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Edit/Tab/Form.php +50 -0
- app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Edit/Tabs.php +24 -0
- app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Grid.php +121 -0
- app/code/local/Pektsekye/Ymm/Block/Ymm.php +17 -0
- app/code/local/Pektsekye/Ymm/Helper/Data.php +6 -0
- app/code/local/Pektsekye/Ymm/Model/Mysql4/Ymm.php +10 -0
- app/code/local/Pektsekye/Ymm/Model/Mysql4/Ymm/Collection.php +10 -0
- app/code/local/Pektsekye/Ymm/Model/Status.php +15 -0
- app/code/local/Pektsekye/Ymm/Model/Ymm.php +10 -0
- app/code/local/Pektsekye/Ymm/controllers/Adminhtml/YmmController.php +214 -0
- app/code/local/Pektsekye/Ymm/controllers/IndexController.php +10 -0
- app/code/local/Pektsekye/Ymm/etc/config.xml +125 -0
- app/code/local/Pektsekye/Ymm/sql/ymm_setup/mysql4-install-0.1.0.php +21 -0
- app/design/adminhtml/default/default/layout/ymm.xml +8 -0
- app/design/frontend/default/default/layout/ymm.xml +8 -0
- app/design/frontend/default/default/template/ymm/ymm.phtml +188 -0
- app/etc/modules/Pektsekye_Catalog.xml +7 -0
- app/etc/modules/Pektsekye_Ymm.xml +9 -0
- package.xml +33 -0
app/code/local/Pektsekye/Catalog/Model/Category.php
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Written by pektsekye@gmail.com on Monday Jul 20 2009
|
4 |
+
version 1.0
|
5 |
+
*/
|
6 |
+
|
7 |
+
|
8 |
+
class Pektsekye_Catalog_Model_Category extends Mage_Catalog_Model_Category
|
9 |
+
{
|
10 |
+
|
11 |
+
/** Override core magento function
|
12 |
+
* Get category products collection
|
13 |
+
*
|
14 |
+
* @return Varien_Data_Collection_Db
|
15 |
+
*/
|
16 |
+
public function getProductCollection()
|
17 |
+
{
|
18 |
+
|
19 |
+
$expire=time()+60*60*24*90;
|
20 |
+
$where = "";
|
21 |
+
|
22 |
+
if (isset($_GET['Make'])){
|
23 |
+
setcookie("Make_selected", $_GET['Make'], $expire,'/');
|
24 |
+
if ($_GET['Make'] != 'all')
|
25 |
+
$Make_selected_var = $_GET['Make'];
|
26 |
+
} elseif (isset($_COOKIE['Make_selected']) && $_COOKIE['Make_selected'] != 'all')
|
27 |
+
$Make_selected_var = $_COOKIE['Make_selected'];
|
28 |
+
|
29 |
+
if (isset($_GET['Model'])){
|
30 |
+
setcookie("Model_selected", $_GET['Model'], $expire,'/');
|
31 |
+
if ($_GET['Model'] != 'all')
|
32 |
+
$Model_selected_var = $_GET['Model'];
|
33 |
+
} elseif (isset($_COOKIE['Model_selected']) && $_COOKIE['Model_selected'] != 'all')
|
34 |
+
$Model_selected_var = $_COOKIE['Model_selected'];
|
35 |
+
|
36 |
+
if (isset($_GET['Year'])){
|
37 |
+
setcookie("Year_selected", $_GET['Year'], $expire,'/');
|
38 |
+
if ($_GET['Year'] != 0)
|
39 |
+
$Year_selected_var = $_GET['Year'];
|
40 |
+
} elseif (isset($_COOKIE['Year_selected']) && $_COOKIE['Year_selected'] != 0)
|
41 |
+
$Year_selected_var = $_COOKIE['Year_selected'];
|
42 |
+
|
43 |
+
|
44 |
+
if (isset($Make_selected_var))
|
45 |
+
$where .= " (products_car_make='".$Make_selected_var."' or products_car_make='') ";
|
46 |
+
|
47 |
+
if (isset($Model_selected_var))
|
48 |
+
$where .= ($where != '' ? ' and ' : '') . " (products_car_model='".$Model_selected_var."' or products_car_model='') ";
|
49 |
+
|
50 |
+
if (isset($Year_selected_var))
|
51 |
+
$where .= ($where != '' ? ' and ' : '') . " ((products_car_year_bof <= '".$Year_selected_var."' and products_car_year_eof >= '".$Year_selected_var."') or (products_car_year_bof=0 and products_car_year_eof=0)) ";
|
52 |
+
|
53 |
+
|
54 |
+
if ($where != ''){
|
55 |
+
|
56 |
+
$resource = Mage::getSingleton('core/resource');
|
57 |
+
$read= $resource->getConnection('core_read');
|
58 |
+
$ymmTable = $resource->getTableName('ymm');
|
59 |
+
$select = $read->select()
|
60 |
+
->distinct()
|
61 |
+
->from($ymmTable,array('products_id'))
|
62 |
+
->where($where);
|
63 |
+
$rows = $read->fetchAll($select);
|
64 |
+
|
65 |
+
$ids = array();
|
66 |
+
|
67 |
+
if (count($rows) > 0)
|
68 |
+
foreach ($rows as $r)
|
69 |
+
$ids [] = $r['products_id'];
|
70 |
+
|
71 |
+
$productTable = $resource->getTableName('catalog_product_entity');
|
72 |
+
$select = $read->select()
|
73 |
+
->distinct()
|
74 |
+
->from($productTable,array('entity_id'))
|
75 |
+
->where("entity_id not in (SELECT DISTINCT products_id FROM ymm)");
|
76 |
+
$rows = $read->fetchAll($select);
|
77 |
+
|
78 |
+
if (count($rows) > 0)
|
79 |
+
foreach ($rows as $r)
|
80 |
+
$ids [] = $r['entity_id'];
|
81 |
+
|
82 |
+
$collection = Mage::getResourceModel('catalog/product_collection')
|
83 |
+
->setStoreId($this->getStoreId())
|
84 |
+
->addCategoryFilter($this)
|
85 |
+
->addIdFilter($ids);
|
86 |
+
|
87 |
+
} else {
|
88 |
+
|
89 |
+
$collection = Mage::getResourceModel('catalog/product_collection')
|
90 |
+
->setStoreId($this->getStoreId())
|
91 |
+
->addCategoryFilter($this);
|
92 |
+
}
|
93 |
+
|
94 |
+
return $collection;
|
95 |
+
}
|
96 |
+
|
97 |
+
}
|
app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Pektsekye_Ymm_Block_Adminhtml_Ymm extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_ymm';
|
7 |
+
$this->_blockGroup = 'ymm';
|
8 |
+
$this->_headerText = Mage::helper('ymm')->__('Item Manager');
|
9 |
+
$this->_addButtonLabel = Mage::helper('ymm')->__('Add Item');
|
10 |
+
parent::__construct();
|
11 |
+
}
|
12 |
+
}
|
app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Edit.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Ymm_Block_Adminhtml_Ymm_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'id';
|
10 |
+
$this->_blockGroup = 'ymm';
|
11 |
+
$this->_controller = 'adminhtml_ymm';
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', Mage::helper('ymm')->__('Save Item'));
|
14 |
+
$this->_updateButton('delete', 'label', Mage::helper('ymm')->__('Delete Item'));
|
15 |
+
|
16 |
+
$this->_addButton('saveandcontinue', array(
|
17 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
18 |
+
'onclick' => 'saveAndContinueEdit()',
|
19 |
+
'class' => 'save',
|
20 |
+
), -100);
|
21 |
+
|
22 |
+
$this->_formScripts[] = "
|
23 |
+
function toggleEditor() {
|
24 |
+
if (tinyMCE.getInstanceById('ymm_content') == null) {
|
25 |
+
tinyMCE.execCommand('mceAddControl', false, 'ymm_content');
|
26 |
+
} else {
|
27 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'ymm_content');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
function saveAndContinueEdit(){
|
32 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
33 |
+
}
|
34 |
+
";
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getHeaderText()
|
38 |
+
{
|
39 |
+
if( Mage::registry('ymm_data') && Mage::registry('ymm_data')->getId() ) {
|
40 |
+
return Mage::helper('ymm')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('ymm_data')->getTitle()));
|
41 |
+
} else {
|
42 |
+
return Mage::helper('ymm')->__('Add Item');
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Edit/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Ymm_Block_Adminhtml_Ymm_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form(array(
|
8 |
+
'id' => 'edit_form',
|
9 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
10 |
+
'method' => 'post',
|
11 |
+
'enctype' => 'multipart/form-data'
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Ymm_Block_Adminhtml_Ymm_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form();
|
8 |
+
$this->setForm($form);
|
9 |
+
$fieldset = $form->addFieldset('ymm_form', array('legend'=>Mage::helper('ymm')->__('Item information')));
|
10 |
+
|
11 |
+
$fieldset->addField('products_id', 'text', array(
|
12 |
+
'label' => Mage::helper('ymm')->__('Products ID'),
|
13 |
+
'required' => true,
|
14 |
+
'name' => 'products_id',
|
15 |
+
));
|
16 |
+
|
17 |
+
$fieldset->addField('products_car_make', 'text', array(
|
18 |
+
'label' => Mage::helper('ymm')->__('Vehicle Make'),
|
19 |
+
'required' => true,
|
20 |
+
'name' => 'products_car_make',
|
21 |
+
));
|
22 |
+
|
23 |
+
$fieldset->addField('products_car_model', 'text', array(
|
24 |
+
'label' => Mage::helper('ymm')->__('Vehicle Model'),
|
25 |
+
'required' => false,
|
26 |
+
'name' => 'products_car_model',
|
27 |
+
));
|
28 |
+
|
29 |
+
$fieldset->addField('products_car_year_bof', 'text', array(
|
30 |
+
'label' => Mage::helper('ymm')->__('From Year (dddd)'),
|
31 |
+
'required' => false,
|
32 |
+
'name' => 'products_car_year_bof',
|
33 |
+
));
|
34 |
+
|
35 |
+
$fieldset->addField('products_car_year_eof', 'text', array(
|
36 |
+
'label' => Mage::helper('ymm')->__('To Year (dddd)'),
|
37 |
+
'required' => false,
|
38 |
+
'name' => 'products_car_year_eof',
|
39 |
+
));
|
40 |
+
|
41 |
+
if ( Mage::getSingleton('adminhtml/session')->getYmmData() )
|
42 |
+
{
|
43 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getYmmData());
|
44 |
+
Mage::getSingleton('adminhtml/session')->setYmmData(null);
|
45 |
+
} elseif ( Mage::registry('ymm_data') ) {
|
46 |
+
$form->setValues(Mage::registry('ymm_data')->getData());
|
47 |
+
}
|
48 |
+
return parent::_prepareForm();
|
49 |
+
}
|
50 |
+
}
|
app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Edit/Tabs.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Ymm_Block_Adminhtml_Ymm_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('ymm_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('ymm')->__('Item Information'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => Mage::helper('ymm')->__('Item Information'),
|
18 |
+
'title' => Mage::helper('ymm')->__('Item Information'),
|
19 |
+
'content' => $this->getLayout()->createBlock('ymm/adminhtml_ymm_edit_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
return parent::_beforeToHtml();
|
23 |
+
}
|
24 |
+
}
|
app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Grid.php
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Ymm_Block_Adminhtml_Ymm_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
// $this->setEmptyText(Mage::helper('ymm')->__('This product is set to be always shown'));
|
9 |
+
$this->setId('ymmGrid');
|
10 |
+
$this->setDefaultSort('id');
|
11 |
+
$this->setDefaultDir('ASC');
|
12 |
+
$this->setSaveParametersInSession(true);
|
13 |
+
}
|
14 |
+
|
15 |
+
protected function _prepareCollection()
|
16 |
+
{
|
17 |
+
$collection = Mage::getModel('ymm/ymm')->getCollection();
|
18 |
+
$this->setCollection($collection);
|
19 |
+
return parent::_prepareCollection();
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _prepareColumns()
|
23 |
+
{
|
24 |
+
$this->addColumn('id', array(
|
25 |
+
'header' => Mage::helper('ymm')->__('ID'),
|
26 |
+
'align' =>'right',
|
27 |
+
'width' => '50px',
|
28 |
+
'index' => 'id',
|
29 |
+
));
|
30 |
+
|
31 |
+
$this->addColumn('products_id', array(
|
32 |
+
'header' => Mage::helper('ymm')->__('Products ID'),
|
33 |
+
'align' =>'left',
|
34 |
+
'index' => 'products_id',
|
35 |
+
));
|
36 |
+
|
37 |
+
$this->addColumn('products_car_make', array(
|
38 |
+
'header' => Mage::helper('ymm')->__('Vehicle Make'),
|
39 |
+
'align' =>'left',
|
40 |
+
'index' => 'products_car_make',
|
41 |
+
));
|
42 |
+
|
43 |
+
$this->addColumn('products_car_model', array(
|
44 |
+
'header' => Mage::helper('ymm')->__('Vehicle Model'),
|
45 |
+
'align' =>'left',
|
46 |
+
'index' => 'products_car_model',
|
47 |
+
));
|
48 |
+
|
49 |
+
$this->addColumn('products_car_year_bof', array(
|
50 |
+
'header' => Mage::helper('ymm')->__('From Year'),
|
51 |
+
'align' =>'left',
|
52 |
+
'index' => 'products_car_year_bof',
|
53 |
+
));
|
54 |
+
|
55 |
+
$this->addColumn('products_car_year_eof', array(
|
56 |
+
'header' => Mage::helper('ymm')->__('To Year'),
|
57 |
+
'align' =>'left',
|
58 |
+
'index' => 'products_car_year_eof',
|
59 |
+
));
|
60 |
+
|
61 |
+
$this->addColumn('action',
|
62 |
+
array(
|
63 |
+
'header' => Mage::helper('ymm')->__('Action'),
|
64 |
+
'width' => '100',
|
65 |
+
'type' => 'action',
|
66 |
+
'getter' => 'getId',
|
67 |
+
'actions' => array(
|
68 |
+
array(
|
69 |
+
'caption' => Mage::helper('ymm')->__('Edit'),
|
70 |
+
'url' => array('base'=> '*/*/edit'),
|
71 |
+
'field' => 'id'
|
72 |
+
)
|
73 |
+
),
|
74 |
+
'filter' => false,
|
75 |
+
'sortable' => false,
|
76 |
+
'index' => 'stores',
|
77 |
+
'is_system' => true,
|
78 |
+
));
|
79 |
+
|
80 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('ymm')->__('CSV'));
|
81 |
+
$this->addExportType('*/*/exportXml', Mage::helper('ymm')->__('XML'));
|
82 |
+
|
83 |
+
return parent::_prepareColumns();
|
84 |
+
}
|
85 |
+
|
86 |
+
protected function _prepareMassaction()
|
87 |
+
{
|
88 |
+
$this->setMassactionIdField('id');
|
89 |
+
$this->getMassactionBlock()->setFormFieldName('ymm');
|
90 |
+
|
91 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
92 |
+
'label' => Mage::helper('ymm')->__('Delete'),
|
93 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
94 |
+
'confirm' => Mage::helper('ymm')->__('Are you sure?')
|
95 |
+
));
|
96 |
+
|
97 |
+
$statuses = Mage::getSingleton('ymm/status')->getOptionArray();
|
98 |
+
|
99 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
100 |
+
$this->getMassactionBlock()->addItem('status', array(
|
101 |
+
'label'=> Mage::helper('ymm')->__('Change status'),
|
102 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
103 |
+
'additional' => array(
|
104 |
+
'visibility' => array(
|
105 |
+
'name' => 'status',
|
106 |
+
'type' => 'select',
|
107 |
+
'class' => 'required-entry',
|
108 |
+
'label' => Mage::helper('ymm')->__('Status'),
|
109 |
+
'values' => $statuses
|
110 |
+
)
|
111 |
+
)
|
112 |
+
));
|
113 |
+
return $this;
|
114 |
+
}
|
115 |
+
|
116 |
+
public function getRowUrl($row)
|
117 |
+
{
|
118 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
119 |
+
}
|
120 |
+
|
121 |
+
}
|
app/code/local/Pektsekye/Ymm/Block/Ymm.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Pektsekye_Ymm_Block_Ymm extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
public function _prepareLayout()
|
5 |
+
{
|
6 |
+
return parent::_prepareLayout();
|
7 |
+
}
|
8 |
+
|
9 |
+
public function getYmm()
|
10 |
+
{
|
11 |
+
if (!$this->hasData('ymm')) {
|
12 |
+
$this->setData('ymm', Mage::registry('ymm'));
|
13 |
+
}
|
14 |
+
return $this->getData('ymm');
|
15 |
+
|
16 |
+
}
|
17 |
+
}
|
app/code/local/Pektsekye/Ymm/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Ymm_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/local/Pektsekye/Ymm/Model/Mysql4/Ymm.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Ymm_Model_Mysql4_Ymm extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the ymm_id refers to the key field in your database table.
|
8 |
+
$this->_init('ymm/ymm', 'id');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Pektsekye/Ymm/Model/Mysql4/Ymm/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Ymm_Model_Mysql4_Ymm_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('ymm/ymm');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Pektsekye/Ymm/Model/Status.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Ymm_Model_Status extends Varien_Object
|
4 |
+
{
|
5 |
+
const STATUS_ENABLED = 1;
|
6 |
+
const STATUS_DISABLED = 2;
|
7 |
+
|
8 |
+
static public function getOptionArray()
|
9 |
+
{
|
10 |
+
return array(
|
11 |
+
self::STATUS_ENABLED => Mage::helper('ymm')->__('Enabled'),
|
12 |
+
self::STATUS_DISABLED => Mage::helper('ymm')->__('Disabled')
|
13 |
+
);
|
14 |
+
}
|
15 |
+
}
|
app/code/local/Pektsekye/Ymm/Model/Ymm.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Ymm_Model_Ymm extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('ymm/ymm');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Pektsekye/Ymm/controllers/Adminhtml/YmmController.php
ADDED
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Ymm_Adminhtml_YmmController extends Mage_Adminhtml_Controller_action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('ymm/items')
|
9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function indexAction() {
|
15 |
+
$this->_initAction()
|
16 |
+
->renderLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function editAction() {
|
20 |
+
$id = $this->getRequest()->getParam('id');
|
21 |
+
$model = Mage::getModel('ymm/ymm')->load($id);
|
22 |
+
|
23 |
+
if ($model->getId() || $id == 0) {
|
24 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
25 |
+
if (!empty($data)) {
|
26 |
+
$model->setData($data);
|
27 |
+
}
|
28 |
+
|
29 |
+
Mage::register('ymm_data', $model);
|
30 |
+
|
31 |
+
$this->loadLayout();
|
32 |
+
$this->_setActiveMenu('ymm/items');
|
33 |
+
|
34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
35 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
36 |
+
|
37 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
38 |
+
|
39 |
+
$this->_addContent($this->getLayout()->createBlock('ymm/adminhtml_ymm_edit'))
|
40 |
+
->_addLeft($this->getLayout()->createBlock('ymm/adminhtml_ymm_edit_tabs'));
|
41 |
+
|
42 |
+
$this->renderLayout();
|
43 |
+
} else {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ymm')->__('Item does not exist'));
|
45 |
+
$this->_redirect('*/*/');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function newAction() {
|
50 |
+
$this->_forward('edit');
|
51 |
+
}
|
52 |
+
|
53 |
+
public function saveAction() {
|
54 |
+
if ($data = $this->getRequest()->getPost()) {
|
55 |
+
|
56 |
+
if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
|
57 |
+
try {
|
58 |
+
/* Starting upload */
|
59 |
+
$uploader = new Varien_File_Uploader('filename');
|
60 |
+
|
61 |
+
// Any extention would work
|
62 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
63 |
+
$uploader->setAllowRenameFiles(false);
|
64 |
+
|
65 |
+
// Set the file upload mode
|
66 |
+
// false -> get the file directly in the specified folder
|
67 |
+
// true -> get the file in the product like folders
|
68 |
+
// (file.jpg will go in something like /media/f/i/file.jpg)
|
69 |
+
$uploader->setFilesDispersion(false);
|
70 |
+
|
71 |
+
// We set media as the upload dir
|
72 |
+
$path = Mage::getBaseDir('media') . DS ;
|
73 |
+
$uploader->save($path, $_FILES['filename']['name'] );
|
74 |
+
|
75 |
+
} catch (Exception $e) {
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
//this way the name is saved in DB
|
80 |
+
$data['filename'] = $_FILES['filename']['name'];
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
$model = Mage::getModel('ymm/ymm');
|
85 |
+
$model->setData($data)
|
86 |
+
->setId($this->getRequest()->getParam('id'));
|
87 |
+
|
88 |
+
try {
|
89 |
+
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
|
90 |
+
$model->setCreatedTime(now())
|
91 |
+
->setUpdateTime(now());
|
92 |
+
} else {
|
93 |
+
$model->setUpdateTime(now());
|
94 |
+
}
|
95 |
+
|
96 |
+
$model->save();
|
97 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('ymm')->__('Item was successfully saved'));
|
98 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
99 |
+
|
100 |
+
if ($this->getRequest()->getParam('back')) {
|
101 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
$this->_redirect('*/*/');
|
105 |
+
return;
|
106 |
+
} catch (Exception $e) {
|
107 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
108 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
109 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ymm')->__('Unable to find item to save'));
|
114 |
+
$this->_redirect('*/*/');
|
115 |
+
}
|
116 |
+
|
117 |
+
public function deleteAction() {
|
118 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
119 |
+
try {
|
120 |
+
$model = Mage::getModel('ymm/ymm');
|
121 |
+
|
122 |
+
$model->setId($this->getRequest()->getParam('id'))
|
123 |
+
->delete();
|
124 |
+
|
125 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
126 |
+
$this->_redirect('*/*/');
|
127 |
+
} catch (Exception $e) {
|
128 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
129 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
130 |
+
}
|
131 |
+
}
|
132 |
+
$this->_redirect('*/*/');
|
133 |
+
}
|
134 |
+
|
135 |
+
public function massDeleteAction() {
|
136 |
+
$ymmIds = $this->getRequest()->getParam('ymm');
|
137 |
+
if(!is_array($ymmIds)) {
|
138 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
139 |
+
} else {
|
140 |
+
try {
|
141 |
+
foreach ($ymmIds as $ymmId) {
|
142 |
+
$ymm = Mage::getModel('ymm/ymm')->load($ymmId);
|
143 |
+
$ymm->delete();
|
144 |
+
}
|
145 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
146 |
+
Mage::helper('adminhtml')->__(
|
147 |
+
'Total of %d record(s) were successfully deleted', count($ymmIds)
|
148 |
+
)
|
149 |
+
);
|
150 |
+
} catch (Exception $e) {
|
151 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
152 |
+
}
|
153 |
+
}
|
154 |
+
$this->_redirect('*/*/index');
|
155 |
+
}
|
156 |
+
|
157 |
+
public function massStatusAction()
|
158 |
+
{
|
159 |
+
$ymmIds = $this->getRequest()->getParam('ymm');
|
160 |
+
if(!is_array($ymmIds)) {
|
161 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
|
162 |
+
} else {
|
163 |
+
try {
|
164 |
+
foreach ($ymmIds as $ymmId) {
|
165 |
+
$ymm = Mage::getSingleton('ymm/ymm')
|
166 |
+
->load($ymmId)
|
167 |
+
->setStatus($this->getRequest()->getParam('status'))
|
168 |
+
->setIsMassupdate(true)
|
169 |
+
->save();
|
170 |
+
}
|
171 |
+
$this->_getSession()->addSuccess(
|
172 |
+
$this->__('Total of %d record(s) were successfully updated', count($ymmIds))
|
173 |
+
);
|
174 |
+
} catch (Exception $e) {
|
175 |
+
$this->_getSession()->addError($e->getMessage());
|
176 |
+
}
|
177 |
+
}
|
178 |
+
$this->_redirect('*/*/index');
|
179 |
+
}
|
180 |
+
|
181 |
+
public function exportCsvAction()
|
182 |
+
{
|
183 |
+
$fileName = 'ymm.csv';
|
184 |
+
$content = $this->getLayout()->createBlock('ymm/adminhtml_ymm_grid')
|
185 |
+
->getCsv();
|
186 |
+
|
187 |
+
$this->_sendUploadResponse($fileName, $content);
|
188 |
+
}
|
189 |
+
|
190 |
+
public function exportXmlAction()
|
191 |
+
{
|
192 |
+
$fileName = 'ymm.xml';
|
193 |
+
$content = $this->getLayout()->createBlock('ymm/adminhtml_ymm_grid')
|
194 |
+
->getXml();
|
195 |
+
|
196 |
+
$this->_sendUploadResponse($fileName, $content);
|
197 |
+
}
|
198 |
+
|
199 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
200 |
+
{
|
201 |
+
$response = $this->getResponse();
|
202 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
203 |
+
$response->setHeader('Pragma', 'public', true);
|
204 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
205 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
206 |
+
$response->setHeader('Last-Modified', date('r'));
|
207 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
208 |
+
$response->setHeader('Content-Length', strlen($content));
|
209 |
+
$response->setHeader('Content-type', $contentType);
|
210 |
+
$response->setBody($content);
|
211 |
+
$response->sendResponse();
|
212 |
+
die;
|
213 |
+
}
|
214 |
+
}
|
app/code/local/Pektsekye/Ymm/controllers/IndexController.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Ymm_IndexController extends Mage_Core_Controller_Front_Action
|
4 |
+
{
|
5 |
+
public function indexAction()
|
6 |
+
{
|
7 |
+
$this->loadLayout();
|
8 |
+
$this->renderLayout();
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Pektsekye/Ymm/etc/config.xml
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Pektsekye_Ymm>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Pektsekye_Ymm>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<ymm>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Pektsekye_Ymm</module>
|
14 |
+
<frontName>ymm</frontName>
|
15 |
+
</args>
|
16 |
+
</ymm>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<ymm>
|
21 |
+
<file>ymm.xml</file>
|
22 |
+
</ymm>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<ymm>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>Pektsekye_Ymm</module>
|
32 |
+
<frontName>ymm</frontName>
|
33 |
+
</args>
|
34 |
+
</ymm>
|
35 |
+
</routers>
|
36 |
+
</admin>
|
37 |
+
<adminhtml>
|
38 |
+
<menu>
|
39 |
+
<ymm module="ymm">
|
40 |
+
<title>Ymm</title>
|
41 |
+
<sort_order>71</sort_order>
|
42 |
+
<children>
|
43 |
+
<items module="ymm">
|
44 |
+
<title>Manage Items</title>
|
45 |
+
<sort_order>0</sort_order>
|
46 |
+
<action>ymm/adminhtml_ymm</action>
|
47 |
+
</items>
|
48 |
+
</children>
|
49 |
+
</ymm>
|
50 |
+
</menu>
|
51 |
+
<acl>
|
52 |
+
<resources>
|
53 |
+
<all>
|
54 |
+
<title>Allow Everything</title>
|
55 |
+
</all>
|
56 |
+
<admin>
|
57 |
+
<children>
|
58 |
+
<Pektsekye_Ymm>
|
59 |
+
<title>Ymm Module</title>
|
60 |
+
<sort_order>10</sort_order>
|
61 |
+
</Pektsekye_Ymm>
|
62 |
+
</children>
|
63 |
+
</admin>
|
64 |
+
</resources>
|
65 |
+
</acl>
|
66 |
+
<layout>
|
67 |
+
<updates>
|
68 |
+
<ymm>
|
69 |
+
<file>ymm.xml</file>
|
70 |
+
</ymm>
|
71 |
+
</updates>
|
72 |
+
</layout>
|
73 |
+
</adminhtml>
|
74 |
+
<global>
|
75 |
+
<models>
|
76 |
+
<catalog>
|
77 |
+
<rewrite>
|
78 |
+
<category>Pektsekye_Catalog_Model_Category</category>
|
79 |
+
</rewrite>
|
80 |
+
</catalog>
|
81 |
+
<ymm>
|
82 |
+
<class>Pektsekye_Ymm_Model</class>
|
83 |
+
<resourceModel>ymm_mysql4</resourceModel>
|
84 |
+
</ymm>
|
85 |
+
<ymm_mysql4>
|
86 |
+
<class>Pektsekye_Ymm_Model_Mysql4</class>
|
87 |
+
<entities>
|
88 |
+
<ymm>
|
89 |
+
<table>ymm</table>
|
90 |
+
</ymm>
|
91 |
+
</entities>
|
92 |
+
</ymm_mysql4>
|
93 |
+
</models>
|
94 |
+
<resources>
|
95 |
+
<ymm_setup>
|
96 |
+
<setup>
|
97 |
+
<module>Pektsekye_Ymm</module>
|
98 |
+
</setup>
|
99 |
+
<connection>
|
100 |
+
<use>core_setup</use>
|
101 |
+
</connection>
|
102 |
+
</ymm_setup>
|
103 |
+
<ymm_write>
|
104 |
+
<connection>
|
105 |
+
<use>core_write</use>
|
106 |
+
</connection>
|
107 |
+
</ymm_write>
|
108 |
+
<ymm_read>
|
109 |
+
<connection>
|
110 |
+
<use>core_read</use>
|
111 |
+
</connection>
|
112 |
+
</ymm_read>
|
113 |
+
</resources>
|
114 |
+
<blocks>
|
115 |
+
<ymm>
|
116 |
+
<class>Pektsekye_Ymm_Block</class>
|
117 |
+
</ymm>
|
118 |
+
</blocks>
|
119 |
+
<helpers>
|
120 |
+
<ymm>
|
121 |
+
<class>Pektsekye_Ymm_Helper</class>
|
122 |
+
</ymm>
|
123 |
+
</helpers>
|
124 |
+
</global>
|
125 |
+
</config>
|
app/code/local/Pektsekye/Ymm/sql/ymm_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//core_resource table
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
DROP TABLE IF EXISTS {$this->getTable('ymm')};
|
10 |
+
CREATE TABLE {$this->getTable('ymm')} (
|
11 |
+
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
12 |
+
`products_id` INT NOT NULL ,
|
13 |
+
`products_car_make` VARCHAR( 100 ) NOT NULL ,
|
14 |
+
`products_car_model` VARCHAR( 100 ) NOT NULL ,
|
15 |
+
`products_car_year_bof` INT NOT NULL ,
|
16 |
+
`products_car_year_eof` INT NOT NULL
|
17 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
18 |
+
|
19 |
+
");
|
20 |
+
|
21 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/ymm.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<ymm_adminhtml_ymm_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="ymm/adminhtml_ymm" name="ymm" />
|
6 |
+
</reference>
|
7 |
+
</ymm_adminhtml_ymm_index>
|
8 |
+
</layout>
|
app/design/frontend/default/default/layout/ymm.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<catalog_category_view>
|
4 |
+
<reference name="right">
|
5 |
+
<block type="ymm/ymm" name="ymm" template="ymm/ymm.phtml" />
|
6 |
+
</reference>
|
7 |
+
</catalog_category_view>
|
8 |
+
</layout>
|
app/design/frontend/default/default/template/ymm/ymm.phtml
ADDED
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Written by pektsekye@gmail.com on Monday Jul 20 2009
|
4 |
+
version 1.0
|
5 |
+
*/
|
6 |
+
|
7 |
+
$resource = Mage::getSingleton('core/resource');
|
8 |
+
$read= $resource->getConnection('core_read');
|
9 |
+
$ymmTable = $resource->getTableName('ymm');
|
10 |
+
|
11 |
+
$select = $read->select()
|
12 |
+
->distinct()
|
13 |
+
->from($ymmTable,array('products_car_make','products_car_model','products_car_year_bof','products_car_year_eof'))
|
14 |
+
->where('products_car_make != ?','')
|
15 |
+
->where('products_car_model != ?','')
|
16 |
+
->where('products_car_year_bof != ?',0)
|
17 |
+
->where('products_car_year_eof != ?',0)
|
18 |
+
->order(array('products_car_make', 'products_car_model', 'products_car_year_bof', 'products_car_year_eof')) ;
|
19 |
+
|
20 |
+
$rows = $read->fetchAll($select);
|
21 |
+
|
22 |
+
if (count($rows) > 0) {
|
23 |
+
|
24 |
+
$Make_array[] = array('id' => 'all', 'text' => 'Choose Vehicle');
|
25 |
+
$Model_array[] = array('id' => 'all', 'text' => 'Choose Model');
|
26 |
+
$Year_array[] = array('id' => 0, 'text' => 'Choose Year');
|
27 |
+
|
28 |
+
$javascript = '<script language="javascript" type="text/javascript">
|
29 |
+
var a = new Array();
|
30 |
+
var b = new Array();
|
31 |
+
var c = new Array();';
|
32 |
+
|
33 |
+
$y = array();
|
34 |
+
$M_a = array();
|
35 |
+
$products_car_make_old = '';
|
36 |
+
$products_car_model_old = '';
|
37 |
+
|
38 |
+
foreach ($rows as $Makes) {
|
39 |
+
|
40 |
+
if (!isset($M_a [$Makes['products_car_make']]))
|
41 |
+
$Make_array[] = array('id' => $Makes['products_car_make'], 'text' => $Makes['products_car_make']);
|
42 |
+
|
43 |
+
|
44 |
+
if (!isset($M_a [$Makes['products_car_make']][$Makes['products_car_model']]) && count($y) > 0){
|
45 |
+
$M_a [$products_car_make_old][$products_car_model_old]=$y;
|
46 |
+
$y = array();
|
47 |
+
}
|
48 |
+
|
49 |
+
if ($Makes['products_car_year_bof'] != 0 && $Makes['products_car_year_eof'] != 0){
|
50 |
+
if ($Makes['products_car_year_bof'] == $Makes['products_car_year_eof']){
|
51 |
+
$y [$Makes['products_car_year_bof']] = 1;
|
52 |
+
} elseif ($Makes['products_car_year_bof'] < $Makes['products_car_year_eof']){
|
53 |
+
while ($Makes['products_car_year_bof'] <= $Makes['products_car_year_eof']){
|
54 |
+
$y [$Makes['products_car_year_bof']] = 1;
|
55 |
+
$Makes['products_car_year_bof']++;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
$products_car_make_old = $Makes['products_car_make'];
|
60 |
+
$products_car_model_old = $Makes['products_car_model'];
|
61 |
+
$M_a [$Makes['products_car_make']][$Makes['products_car_model']] = array();
|
62 |
+
}
|
63 |
+
|
64 |
+
$M_a [$products_car_make_old][$products_car_model_old]=$y;
|
65 |
+
|
66 |
+
|
67 |
+
|
68 |
+
$i = 0;
|
69 |
+
foreach ($M_a as $k =>$v){
|
70 |
+
$javascript .= 'a['.$i.']="'.$k.'";b['.$i.']=new Array(';
|
71 |
+
$ii = 0;
|
72 |
+
$s = '';
|
73 |
+
foreach ($M_a[$k] as $kk =>$vv){
|
74 |
+
$javascript .= ($ii != 0 ? ',' : '').'"'.$kk.'"';
|
75 |
+
$ss = '';
|
76 |
+
$iii = 0;
|
77 |
+
foreach ($M_a[$k][$kk] as $kkk => $vvv){
|
78 |
+
$ss .= ($iii != 0 ? ',' : '').$kkk;
|
79 |
+
$iii++;
|
80 |
+
}
|
81 |
+
if ($iii == 1)
|
82 |
+
$ss = '"'.$ss.'"';
|
83 |
+
$s .= 'c['.$i.']['.$ii.']=new Array('.$ss.');';
|
84 |
+
$ii++;
|
85 |
+
}
|
86 |
+
$javascript .= ');c['.$i.']=new Array();'.$s;
|
87 |
+
$i++;
|
88 |
+
}
|
89 |
+
|
90 |
+
$javascript .= '
|
91 |
+
function pop_model(){
|
92 |
+
|
93 |
+
var o ="<select name=\"Model\" onChange=\"pop_year();\" style=\"width: 100%\"><option value=\"all\">Choose Model</option>";
|
94 |
+
var sv = document.make_model_year.Make.value;
|
95 |
+
if(sv != "all"){
|
96 |
+
var v = a.length;
|
97 |
+
while(v--) if(sv == a[v]) break;
|
98 |
+
for(var i = 0; i < b[v].length; i++)
|
99 |
+
o+="<option value=\""+b[v][i]+"\">"+b[v][i]+"</option>";
|
100 |
+
}
|
101 |
+
o+="</select>";
|
102 |
+
document.getElementById("model_select").innerHTML= o;
|
103 |
+
document.getElementById("year_select").innerHTML= "<select name=\"Year\" style=\"width: 100%\"><option value=\"0\">Choose Year</option></select>";
|
104 |
+
}
|
105 |
+
function pop_year(){
|
106 |
+
|
107 |
+
var o ="<select name=\"Year\" style=\"width: 100%\" onChange=\"document.make_model_year.submit();\"><option value=\"0\">Choose Year</option>";
|
108 |
+
var sv = document.make_model_year.Make.value;
|
109 |
+
if(sv != "all"){
|
110 |
+
var v = a.length;
|
111 |
+
while(v--) if(sv == a[v]) break;
|
112 |
+
var sv2 = document.make_model_year.Model.value;
|
113 |
+
if(sv2 != "all"){
|
114 |
+
var v2 = b[v].length;
|
115 |
+
while(v2--) if(sv2 == b[v][v2]) break;
|
116 |
+
for(var i = 0; i < c[v][v2].length; i++)
|
117 |
+
o+="<option value=\""+c[v][v2][i]+"\">"+c[v][v2][i]+"</option>";
|
118 |
+
}
|
119 |
+
}
|
120 |
+
o+="</select>";
|
121 |
+
document.getElementById("year_select").innerHTML= o;
|
122 |
+
}
|
123 |
+
</script>';
|
124 |
+
|
125 |
+
if (isset($_GET['Make'])){
|
126 |
+
if($_GET['Make'] != 'all')
|
127 |
+
$Make_selected_var = $_GET['Make'];
|
128 |
+
} elseif (isset($_COOKIE['Make_selected']) && $_COOKIE['Make_selected'] != 'all')
|
129 |
+
$Make_selected_var = $_COOKIE['Make_selected'];
|
130 |
+
|
131 |
+
if (isset($_GET['Model'])){
|
132 |
+
if($_GET['Model'] != 'all')
|
133 |
+
$Model_selected_var = $_GET['Model'];
|
134 |
+
} elseif (isset($_COOKIE['Model_selected']) && $_COOKIE['Model_selected'] != 'all')
|
135 |
+
$Model_selected_var = $_COOKIE['Model_selected'];
|
136 |
+
|
137 |
+
if (isset($_GET['Year'])){
|
138 |
+
if($_GET['Year'] != 0)
|
139 |
+
$Year_selected_var = $_GET['Year'];
|
140 |
+
} elseif (isset($_COOKIE['Year_selected']) && $_COOKIE['Year_selected'] != 0)
|
141 |
+
$Year_selected_var = $_COOKIE['Year_selected'];
|
142 |
+
|
143 |
+
if (isset($Make_selected_var) && isset($M_a[$Make_selected_var]))
|
144 |
+
foreach ($M_a[$Make_selected_var] as $k => $v)
|
145 |
+
$Model_array[] = array('id' => $k, 'text' => $k);
|
146 |
+
if (isset($Make_selected_var) && isset($Model_selected_var) && isset($M_a[$Make_selected_var][$Model_selected_var]))
|
147 |
+
foreach ($M_a[$Make_selected_var][$Model_selected_var] as $k => $v)
|
148 |
+
$Year_array[] = array('id' => $k, 'text' => $k);
|
149 |
+
|
150 |
+
echo $javascript;
|
151 |
+
|
152 |
+
?>
|
153 |
+
<div class="box base-mini mini-poll">
|
154 |
+
<div class="head">
|
155 |
+
<h4><span><?php echo $this->__('Select Vehicle') ?></span></h4>
|
156 |
+
</div>
|
157 |
+
<form name="make_model_year" method="get">
|
158 |
+
<div class="content">
|
159 |
+
<select name="Make" onChange="pop_model();" style="width: 100%">
|
160 |
+
<?php
|
161 |
+
foreach($Make_array as $option)
|
162 |
+
echo '<option value="'.$option['id'].'" '.(isset($Make_selected_var) && $Make_selected_var == $option['id'] ? 'SELECTED' : '').'>'.$option['text'].'</option>';
|
163 |
+
?>
|
164 |
+
</select><br><br>
|
165 |
+
<span id="model_select">
|
166 |
+
<select name="Model" onChange="pop_year();" style="width: 100%">
|
167 |
+
<?php
|
168 |
+
foreach($Model_array as $option)
|
169 |
+
echo '<option value="'.$option['id'].'" '.(isset($Model_selected_var) && $Model_selected_var == $option['id'] ? 'SELECTED' : '').'>'.$option['text'].'</option>';
|
170 |
+
?>
|
171 |
+
</select></span><br><br>
|
172 |
+
<span id="year_select">
|
173 |
+
<select name="Year" onChange="document.make_model_year.submit();" style="width: 100%">
|
174 |
+
<?php
|
175 |
+
foreach($Year_array as $option)
|
176 |
+
echo '<option value="'.$option['id'].'" '.(isset($Year_selected_var) && $Year_selected_var == $option['id'] ? 'SELECTED' : '').'>'.$option['text'].'</option>';
|
177 |
+
?>
|
178 |
+
</select></span><br><br>
|
179 |
+
</div>
|
180 |
+
<div class="actions">
|
181 |
+
<button class="form-button-alt right" type="submit"><span><?php echo $this->__('Go') ?></span></button>
|
182 |
+
<a href="?Make=all&Model=all&Year=0">Clear Vehicle</a>
|
183 |
+
</div>
|
184 |
+
</form>
|
185 |
+
</div>
|
186 |
+
<?php
|
187 |
+
}
|
188 |
+
?>
|
app/etc/modules/Pektsekye_Catalog.xml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<Pektsekye_Catalog>
|
4 |
+
<active>true</active>
|
5 |
+
<codePool>local</codePool>
|
6 |
+
</Pektsekye_Catalog>
|
7 |
+
</config>
|
app/etc/modules/Pektsekye_Ymm.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Pektsekye_Ymm>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Pektsekye_Ymm>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Year_Make_Model_Filter_Box</name>
|
4 |
+
<version>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>Year Make Model (YMM) "Select Vehicle" filter box for Auto Parts web sites</summary>
|
10 |
+
<description>This small extension makes it impossible for a customer to filter products by vehicle make, model and year.
|
11 |
+
|
12 |
+
HOW TO USE:
|
13 |
+
Go to your Magento admin panel -> Ymm -> Manage Items and add YMM items to all your products.
|
14 |
+
|
15 |
+
If you need to set a product to be shown for all models type word "all" instead of the model name.
|
16 |
+
|
17 |
+
NOTE: The products without model/make/year/ set are treated as for all models, all years, all makes.
|
18 |
+
If you want to select BMW and see only BMW products all the other products should be set to another car.
|
19 |
+
So you have to add YMM items to all your products to see the effect.
|
20 |
+
|
21 |
+
|
22 |
+
NOTE: You should know your product id to be able to add an YMM item to it.
|
23 |
+
You can find product id in the product description page url:
|
24 |
+
http://yoursite.com/magento/catalog/product/view/id/119/s/coalesce-functioning-on-impatience-t-shirt/category/4/
|
25 |
+
The number 119 is the product id in the url.</description>
|
26 |
+
<notes>If you have ideas for improvements or find bugs, please send them to pektsekye@gmail.com</notes>
|
27 |
+
<authors><author><name>Stanislav</name><user>auto-converted</user><email>pektsekye@gmail.com</email></author></authors>
|
28 |
+
<date>2009-07-20</date>
|
29 |
+
<time>19:34:44</time>
|
30 |
+
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="ymm.xml" hash="07bb5759f6ff145da493c94452f029af"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="ymm.xml" hash="1db60ab2dc6f85b6866d9162a252a4ad"/></dir><dir name="template"><dir name="ymm"><file name="ymm.phtml" hash="d0405a01c8ae9f9600c88adec34c40f6"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Pektsekye_Catalog.xml" hash="89e3ec6056b4ba53d06df1370b347d42"/><file name="Pektsekye_Ymm.xml" hash="990f4f561816481bd0c517f4fa131436"/></dir></target><target name="magelocal"><dir name="Pektsekye"><dir name="Catalog"><dir name="Model"><file name="Category.php" hash="adb2fc5d69c5c122033d336236a3c88f"/></dir></dir><dir name="Ymm"><dir name="Block"><dir name="Adminhtml"><dir name="Ymm"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="37e926941c2510b54e4d3048f7ee1b18"/></dir><file name="Form.php" hash="dd81999c40ba81c9a1b95861b95092e4"/><file name="Tabs.php" hash="9048cfd443135e36e2b9cb5de38fcb47"/></dir><file name="Edit.php" hash="d00f46695fe1865cb9a2665711bbf0bb"/><file name="Grid.php" hash="3f5d7dfb16b57021cf29a566f73dea76"/></dir><file name="Ymm.php" hash="2c2d280c93d8839cd67515cd2d6c7ddd"/></dir><file name="Ymm.php" hash="3b7b316856d66630a6a926b5645cd4db"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="YmmController.php" hash="07c3c929064c954ac3b59148608b48a2"/></dir><file name="IndexController.php" hash="241a989b18c6309977568c050215730a"/></dir><dir name="etc"><file name="config.xml" hash="eee12b305f8d257fc0ee95f310be1479"/></dir><dir name="Helper"><file name="Data.php" hash="0cd0de912f0412670f9657b395861d90"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Ymm"><file name="Collection.php" hash="1c6a50ea1416ce936892156806d20e15"/></dir><file name="Ymm.php" hash="8ac41d6fdf44dbf5bea1e9b01a0a0389"/></dir><file name="Status.php" hash="a10da0eebafef60fcceb6a8c396ad201"/><file name="Ymm.php" hash="fdf6dbac2b9595f7183ca1f951538b97"/></dir><dir name="sql"><dir name="ymm_setup"><file name="mysql4-install-0.1.0.php" hash="8f20e954febeb598712160fec4ac7109"/></dir></dir></dir></dir></target></contents>
|
31 |
+
<compatible/>
|
32 |
+
<dependencies/>
|
33 |
+
</package>
|