Version Notes
The first version. The code is based on YMM extension v 4.4
Download this release
Release Info
Developer | Magento Core Team |
Extension | Manufacturer_Model_Number |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- app/code/local/Pektsekye/Catalog/Model/Category.php +33 -0
- app/code/local/Pektsekye/Catalog/Model/Resource/Eav/Mysql4/Category.php +58 -0
- app/code/local/Pektsekye/CatalogSearch/Model/Layer.php +73 -0
- app/code/local/Pektsekye/Mmn/Block/Adminhtml/Mmn.php +12 -0
- app/code/local/Pektsekye/Mmn/Block/Adminhtml/Mmn/Edit.php +45 -0
- app/code/local/Pektsekye/Mmn/Block/Adminhtml/Mmn/Edit/Form.php +18 -0
- app/code/local/Pektsekye/Mmn/Block/Adminhtml/Mmn/Edit/Tab/Form.php +45 -0
- app/code/local/Pektsekye/Mmn/Block/Adminhtml/Mmn/Edit/Tabs.php +24 -0
- app/code/local/Pektsekye/Mmn/Block/Adminhtml/Mmn/Grid.php +91 -0
- app/code/local/Pektsekye/Mmn/Block/Adminhtml/Mmn/ImportExport.php +10 -0
- app/code/local/Pektsekye/Mmn/Block/Mmn.php +23 -0
- app/code/local/Pektsekye/Mmn/Block/Product/Result.php +93 -0
- app/code/local/Pektsekye/Mmn/Helper/Data.php +62 -0
- app/code/local/Pektsekye/Mmn/Model/Mmn.php +10 -0
- app/code/local/Pektsekye/Mmn/Model/Mysql4/Mmn.php +10 -0
- app/code/local/Pektsekye/Mmn/Model/Mysql4/Mmn/Collection.php +10 -0
- app/code/local/Pektsekye/Mmn/Model/Status.php +15 -0
- app/code/local/Pektsekye/Mmn/controllers/Adminhtml/MmnController.php +290 -0
- app/code/local/Pektsekye/Mmn/controllers/IndexController.php +10 -0
- app/code/local/Pektsekye/Mmn/controllers/ProductController.php +23 -0
- app/code/local/Pektsekye/Mmn/etc/config.xml +153 -0
- app/code/local/Pektsekye/Mmn/etc/system.xml +37 -0
- app/code/local/Pektsekye/Mmn/sql/mmn_setup/mysql4-install-0.1.0.php +19 -0
- app/design/adminhtml/default/default/layout/mmn.xml +8 -0
- app/design/adminhtml/default/default/template/mmn/importExport.phtml +38 -0
- app/design/frontend/default/default/layout/mmn.xml +24 -0
- app/design/frontend/default/default/template/mmn/mmn.phtml +185 -0
- app/etc/modules/Pektsekye_Catalog.xml +7 -0
- app/etc/modules/Pektsekye_CatalogSearch.xml +7 -0
- app/etc/modules/Pektsekye_Mmn.xml +9 -0
- package.xml +21 -0
app/code/local/Pektsekye/Catalog/Model/Category.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Catalog_Model_Category extends Mage_Catalog_Model_Category
|
4 |
+
{
|
5 |
+
|
6 |
+
/** Override core magento function
|
7 |
+
* Get category products collection
|
8 |
+
*
|
9 |
+
* @return Varien_Data_Collection_Db
|
10 |
+
*/
|
11 |
+
public function getProductCollection()
|
12 |
+
{
|
13 |
+
|
14 |
+
$ids = Mage::helper('mmn')->getProductIds();
|
15 |
+
|
16 |
+
if($ids){
|
17 |
+
|
18 |
+
$collection = Mage::getResourceModel('catalog/product_collection')
|
19 |
+
->setStoreId($this->getStoreId())
|
20 |
+
->addCategoryFilter($this)
|
21 |
+
->addIdFilter($ids);
|
22 |
+
|
23 |
+
} else {
|
24 |
+
|
25 |
+
$collection = Mage::getResourceModel('catalog/product_collection')
|
26 |
+
->setStoreId($this->getStoreId())
|
27 |
+
->addCategoryFilter($this);
|
28 |
+
}
|
29 |
+
|
30 |
+
return $collection;
|
31 |
+
}
|
32 |
+
|
33 |
+
}
|
app/code/local/Pektsekye/Catalog/Model/Resource/Eav/Mysql4/Category.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Catalog_Model_Resource_Eav_Mysql4_Category extends Mage_Catalog_Model_Resource_Eav_Mysql4_Category
|
4 |
+
{
|
5 |
+
|
6 |
+
|
7 |
+
/**Override core magento class
|
8 |
+
* Retrieve categories
|
9 |
+
*
|
10 |
+
* @param integer $parent
|
11 |
+
* @param integer $recursionLevel
|
12 |
+
* @param boolean|string $sorted
|
13 |
+
* @param boolean $asCollection
|
14 |
+
* @param boolean $toLoad
|
15 |
+
* @return Varien_Data_Tree_Node_Collection|Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection
|
16 |
+
*/
|
17 |
+
public function getCategories($parent, $recursionLevel = 0, $sorted=false, $asCollection=false, $toLoad=true)
|
18 |
+
{
|
19 |
+
$tree = Mage::getResourceModel('catalog/category_tree');
|
20 |
+
/** @var $tree Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Tree */
|
21 |
+
|
22 |
+
if(Mage::getStoreConfig('catalog/navigation/filtering', Mage::app()->getStore()->getStoreId())){
|
23 |
+
|
24 |
+
$ids = Mage::helper('mmn')->getProductIds();
|
25 |
+
|
26 |
+
if($ids){
|
27 |
+
|
28 |
+
$pids = implode(',',$ids);
|
29 |
+
$resource = Mage::getSingleton('core/resource');
|
30 |
+
$read= $resource->getConnection('core_read');
|
31 |
+
$categoryTable = $resource->getTableName('catalog_category_entity');
|
32 |
+
$category_productTable = $resource->getTableName('catalog/category_product_index');
|
33 |
+
$rows = $read->fetchAll("SELECT entity_id FROM $categoryTable WHERE entity_id NOT IN (SELECT DISTINCT category_id FROM $category_productTable WHERE product_id in ($pids)) ");
|
34 |
+
|
35 |
+
if(count($rows)>0)
|
36 |
+
foreach ($rows as $r)
|
37 |
+
$ids [] = $r['entity_id'];
|
38 |
+
|
39 |
+
$tree->addInactiveCategoryIds($ids);
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
$nodes = $tree->loadNode($parent)
|
46 |
+
->loadChildren($recursionLevel)
|
47 |
+
->getChildren();
|
48 |
+
|
49 |
+
$tree->addCollectionData(null, $sorted, $parent, $toLoad, true);
|
50 |
+
|
51 |
+
if ($asCollection) {
|
52 |
+
return $tree->getCollection();
|
53 |
+
}
|
54 |
+
return $nodes;
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
}
|
app/code/local/Pektsekye/CatalogSearch/Model/Layer.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Pektsekye_CatalogSearch_Model_Layer extends Mage_CatalogSearch_Model_Layer
|
5 |
+
{
|
6 |
+
|
7 |
+
/**Override core magento method
|
8 |
+
* Get current layer product collection
|
9 |
+
*
|
10 |
+
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
|
11 |
+
*/
|
12 |
+
public function getProductCollection()
|
13 |
+
{
|
14 |
+
if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) {
|
15 |
+
$collection = $this->_productCollections[$this->getCurrentCategory()->getId()];
|
16 |
+
}
|
17 |
+
else {
|
18 |
+
|
19 |
+
$ids = Mage::helper('mmn')->getProductIds();
|
20 |
+
|
21 |
+
if($ids){
|
22 |
+
|
23 |
+
if(Mage::helper('catalogSearch')->getEscapedQueryText() && Mage::getStoreConfig('catalog/search/filtering', Mage::app()->getStore()->getStoreId())){
|
24 |
+
$collection = Mage::getResourceModel('catalogsearch/fulltext_collection')
|
25 |
+
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
|
26 |
+
->addSearchFilter(Mage::helper('catalogSearch')->getEscapedQueryText())
|
27 |
+
->addIdFilter($ids)
|
28 |
+
->setStore(Mage::app()->getStore())
|
29 |
+
->addMinimalPrice()
|
30 |
+
->addFinalPrice()
|
31 |
+
->addTaxPercents()
|
32 |
+
->addStoreFilter()
|
33 |
+
->addUrlRewrite();
|
34 |
+
|
35 |
+
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
|
36 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
|
37 |
+
|
38 |
+
} elseif (!Mage::helper('catalogSearch')->getEscapedQueryText()){
|
39 |
+
|
40 |
+
$collection = Mage::getResourceModel('catalog/product_collection')
|
41 |
+
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
|
42 |
+
->addIdFilter($ids)
|
43 |
+
->setStore(Mage::app()->getStore())
|
44 |
+
->addMinimalPrice()
|
45 |
+
->addFinalPrice()
|
46 |
+
->addTaxPercents()
|
47 |
+
->addStoreFilter()
|
48 |
+
->addUrlRewrite();
|
49 |
+
|
50 |
+
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
|
51 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
|
52 |
+
|
53 |
+
} else {
|
54 |
+
|
55 |
+
$collection = Mage::getResourceModel('catalogsearch/fulltext_collection');
|
56 |
+
$this->prepareProductCollection($collection);
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
} else {
|
62 |
+
|
63 |
+
$collection = Mage::getResourceModel('catalogsearch/fulltext_collection');
|
64 |
+
$this->prepareProductCollection($collection);
|
65 |
+
}
|
66 |
+
|
67 |
+
$this->_productCollections[$this->getCurrentCategory()->getId()] = $collection;
|
68 |
+
}
|
69 |
+
|
70 |
+
return $collection;
|
71 |
+
}
|
72 |
+
|
73 |
+
}
|
app/code/local/Pektsekye/Mmn/Block/Adminhtml/Mmn.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Pektsekye_Mmn_Block_Adminhtml_Mmn extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_mmn';
|
7 |
+
$this->_blockGroup = 'mmn';
|
8 |
+
$this->_headerText = Mage::helper('mmn')->__('Item Manager');
|
9 |
+
$this->_addButtonLabel = Mage::helper('mmn')->__('Add Item');
|
10 |
+
parent::__construct();
|
11 |
+
}
|
12 |
+
}
|
app/code/local/Pektsekye/Mmn/Block/Adminhtml/Mmn/Edit.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Mmn_Block_Adminhtml_Mmn_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 = 'mmn';
|
11 |
+
$this->_controller = 'adminhtml_mmn';
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', Mage::helper('mmn')->__('Save Item'));
|
14 |
+
$this->_updateButton('delete', 'label', Mage::helper('mmn')->__('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('mmn_content') == null) {
|
25 |
+
tinyMCE.execCommand('mceAddControl', false, 'mmn_content');
|
26 |
+
} else {
|
27 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'mmn_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('mmn_data') && Mage::registry('mmn_data')->getId() ) {
|
40 |
+
return Mage::helper('mmn')->__('Edit Item');
|
41 |
+
} else {
|
42 |
+
return Mage::helper('mmn')->__('Add Item');
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
app/code/local/Pektsekye/Mmn/Block/Adminhtml/Mmn/Edit/Form.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Mmn_Block_Adminhtml_Mmn_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 |
+
)
|
12 |
+
);
|
13 |
+
|
14 |
+
$form->setUseContainer(true);
|
15 |
+
$this->setForm($form);
|
16 |
+
return parent::_prepareForm();
|
17 |
+
}
|
18 |
+
}
|
app/code/local/Pektsekye/Mmn/Block/Adminhtml/Mmn/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Mmn_Block_Adminhtml_Mmn_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('mmn_form', array('legend'=>Mage::helper('mmn')->__('Item information')));
|
10 |
+
|
11 |
+
$fieldset->addField('entity_id', 'text', array(
|
12 |
+
'label' => Mage::helper('mmn')->__('Products ID'),
|
13 |
+
'required' => true,
|
14 |
+
'name' => 'entity_id',
|
15 |
+
));
|
16 |
+
|
17 |
+
$fieldset->addField('manufacturer', 'text', array(
|
18 |
+
'label' => Mage::helper('mmn')->__('Printer Manufacturer'),
|
19 |
+
'required' => true,
|
20 |
+
'name' => 'manufacturer',
|
21 |
+
));
|
22 |
+
|
23 |
+
$fieldset->addField('model', 'text', array(
|
24 |
+
'label' => Mage::helper('mmn')->__('Printer Model'),
|
25 |
+
'required' => false,
|
26 |
+
'name' => 'model',
|
27 |
+
));
|
28 |
+
|
29 |
+
$fieldset->addField('number', 'text', array(
|
30 |
+
'label' => Mage::helper('mmn')->__('Printer Number'),
|
31 |
+
'required' => false,
|
32 |
+
'name' => 'number',
|
33 |
+
));
|
34 |
+
|
35 |
+
|
36 |
+
if ( Mage::getSingleton('adminhtml/session')->getMmnData() )
|
37 |
+
{
|
38 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getMmnData());
|
39 |
+
Mage::getSingleton('adminhtml/session')->setMmnData(null);
|
40 |
+
} elseif ( Mage::registry('mmn_data') ) {
|
41 |
+
$form->setValues(Mage::registry('mmn_data')->getData());
|
42 |
+
}
|
43 |
+
return parent::_prepareForm();
|
44 |
+
}
|
45 |
+
}
|
app/code/local/Pektsekye/Mmn/Block/Adminhtml/Mmn/Edit/Tabs.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Mmn_Block_Adminhtml_Mmn_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('mmn_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('mmn')->__('Item Information'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => Mage::helper('mmn')->__('Item Information'),
|
18 |
+
'title' => Mage::helper('mmn')->__('Item Information'),
|
19 |
+
'content' => $this->getLayout()->createBlock('mmn/adminhtml_mmn_edit_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
return parent::_beforeToHtml();
|
23 |
+
}
|
24 |
+
}
|
app/code/local/Pektsekye/Mmn/Block/Adminhtml/Mmn/Grid.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Mmn_Block_Adminhtml_Mmn_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('mmnGrid');
|
9 |
+
$this->setDefaultSort('mmn_id');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection()
|
15 |
+
{
|
16 |
+
$collection = Mage::getModel('mmn/mmn')->getCollection();
|
17 |
+
$this->setCollection($collection);
|
18 |
+
return parent::_prepareCollection();
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareColumns()
|
22 |
+
{
|
23 |
+
|
24 |
+
$this->addColumn('entity_id', array(
|
25 |
+
'header' => Mage::helper('mmn')->__('Products ID'),
|
26 |
+
'align' =>'left',
|
27 |
+
'index' => 'entity_id',
|
28 |
+
));
|
29 |
+
|
30 |
+
$this->addColumn('manufacturer', array(
|
31 |
+
'header' => Mage::helper('mmn')->__('Printer Manufacturer'),
|
32 |
+
'align' =>'left',
|
33 |
+
'index' => 'manufacturer',
|
34 |
+
));
|
35 |
+
|
36 |
+
$this->addColumn('model', array(
|
37 |
+
'header' => Mage::helper('mmn')->__('Printer Model'),
|
38 |
+
'align' =>'left',
|
39 |
+
'index' => 'model',
|
40 |
+
));
|
41 |
+
|
42 |
+
$this->addColumn('number', array(
|
43 |
+
'header' => Mage::helper('mmn')->__('Printer Number'),
|
44 |
+
'align' =>'left',
|
45 |
+
'index' => 'number',
|
46 |
+
));
|
47 |
+
|
48 |
+
|
49 |
+
$this->addColumn('action',
|
50 |
+
array(
|
51 |
+
'header' => Mage::helper('mmn')->__('Action'),
|
52 |
+
'width' => '100',
|
53 |
+
'type' => 'action',
|
54 |
+
'getter' => 'getId',
|
55 |
+
'actions' => array(
|
56 |
+
array(
|
57 |
+
'caption' => Mage::helper('mmn')->__('Edit'),
|
58 |
+
'url' => array('base'=> '*/*/edit'),
|
59 |
+
'field' => 'id'
|
60 |
+
)
|
61 |
+
),
|
62 |
+
'filter' => false,
|
63 |
+
'sortable' => false,
|
64 |
+
'index' => 'stores',
|
65 |
+
'is_system' => true,
|
66 |
+
));
|
67 |
+
|
68 |
+
|
69 |
+
return parent::_prepareColumns();
|
70 |
+
}
|
71 |
+
|
72 |
+
protected function _prepareMassaction()
|
73 |
+
{
|
74 |
+
$this->setMassactionIdField('mmn_id');
|
75 |
+
$this->getMassactionBlock()->setFormFieldName('mmn');
|
76 |
+
|
77 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
78 |
+
'label' => Mage::helper('mmn')->__('Delete'),
|
79 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
80 |
+
'confirm' => Mage::helper('mmn')->__('Are you sure?')
|
81 |
+
));
|
82 |
+
|
83 |
+
return $this;
|
84 |
+
}
|
85 |
+
|
86 |
+
public function getRowUrl($row)
|
87 |
+
{
|
88 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
89 |
+
}
|
90 |
+
|
91 |
+
}
|
app/code/local/Pektsekye/Mmn/Block/Adminhtml/Mmn/ImportExport.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Mmn_Block_Adminhtml_Mmn_importExport extends Mage_Adminhtml_Block_Widget
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setTemplate('mmn/importExport.phtml');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Pektsekye/Mmn/Block/Mmn.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Pektsekye_Mmn_Block_Mmn extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
|
5 |
+
public function _prepareLayout()
|
6 |
+
{
|
7 |
+
if(Mage::getStoreConfig('catalog/navigation/filtering', Mage::app()->getStore()->getStoreId())){
|
8 |
+
Mage::app()->cleanCache(array(Mage_Catalog_Model_Category::CACHE_TAG));
|
9 |
+
}
|
10 |
+
|
11 |
+
return parent::_prepareLayout();
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getMmn()
|
15 |
+
{
|
16 |
+
if (!$this->hasData('mmn')) {
|
17 |
+
$this->setData('mmn', Mage::registry('mmn'));
|
18 |
+
}
|
19 |
+
return $this->getData('mmn');
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
}
|
app/code/local/Pektsekye/Mmn/Block/Product/Result.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Pektsekye_Mmn_Block_Product_Result extends Mage_Catalog_Block_Product_Abstract
|
5 |
+
{
|
6 |
+
protected $_productCollection;
|
7 |
+
|
8 |
+
protected function _prepareLayout()
|
9 |
+
{
|
10 |
+
$title = $this->getHeaderText();
|
11 |
+
$this->getLayout()->getBlock('head')->setTitle($title);
|
12 |
+
$this->getLayout()->getBlock('root')->setHeaderTitle($title);
|
13 |
+
return parent::_prepareLayout();
|
14 |
+
}
|
15 |
+
|
16 |
+
public function setListOrders() {
|
17 |
+
$this->getChild('search_result_list')
|
18 |
+
->setAvailableOrders(array(
|
19 |
+
'name' => Mage::helper('mmn')->__('Name'),
|
20 |
+
'price'=>Mage::helper('mmn')->__('Price'))
|
21 |
+
);
|
22 |
+
}
|
23 |
+
|
24 |
+
public function setListModes() {
|
25 |
+
$this->getChild('search_result_list')
|
26 |
+
->setModes(array(
|
27 |
+
'grid' => Mage::helper('mmn')->__('Grid'),
|
28 |
+
'list' => Mage::helper('mmn')->__('List'))
|
29 |
+
);
|
30 |
+
}
|
31 |
+
|
32 |
+
public function setListCollection() {
|
33 |
+
$this->getChild('search_result_list')
|
34 |
+
->setCollection($this->_getProductCollection());
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getProductListHtml()
|
38 |
+
{
|
39 |
+
return $this->getChildHtml('search_result_list');
|
40 |
+
}
|
41 |
+
|
42 |
+
protected function _getProductCollection()
|
43 |
+
{
|
44 |
+
|
45 |
+
if (is_null($this->_productCollection)) {
|
46 |
+
$this->_productCollection = Mage::getSingleton('catalogsearch/layer')->getProductCollection();
|
47 |
+
}
|
48 |
+
|
49 |
+
return $this->_productCollection;
|
50 |
+
}
|
51 |
+
|
52 |
+
public function getResultCount()
|
53 |
+
{
|
54 |
+
if (!$this->getData('result_count')) {
|
55 |
+
$size = $this->_getProductCollection()->getSize();
|
56 |
+
$this->setResultCount($size);
|
57 |
+
}
|
58 |
+
return $this->getData('result_count');
|
59 |
+
}
|
60 |
+
|
61 |
+
public function getHeaderText()
|
62 |
+
{
|
63 |
+
|
64 |
+
$manufacturer = $this->getRequest()->getParam('Manufacturer');
|
65 |
+
$model = $this->getRequest()->getParam('Model');
|
66 |
+
$number = $this->getRequest()->getParam('Number');
|
67 |
+
|
68 |
+
if($manufacturer && $manufacturer != 'all') {
|
69 |
+
$manufacturer = $this->getRequest()->getParam('Manufacturer');
|
70 |
+
|
71 |
+
if($model == 'all')
|
72 |
+
$model = '';
|
73 |
+
|
74 |
+
if($number == 0)
|
75 |
+
$number = '';
|
76 |
+
|
77 |
+
return Mage::helper('mmn')->__("Products for %s", $this->htmlEscape("$manufacturer $model $number"));
|
78 |
+
|
79 |
+
} else {
|
80 |
+
return false;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
public function getSubheaderText()
|
85 |
+
{
|
86 |
+
return false;
|
87 |
+
}
|
88 |
+
|
89 |
+
public function getNoResultText()
|
90 |
+
{
|
91 |
+
return Mage::helper('mmn')->__('No matches found.');
|
92 |
+
}
|
93 |
+
}
|
app/code/local/Pektsekye/Mmn/Helper/Data.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Mmn_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
public function getProductIds()
|
7 |
+
{
|
8 |
+
$where = '';
|
9 |
+
|
10 |
+
if (isset($_GET['Manufacturer'])){
|
11 |
+
if ($_GET['Manufacturer'] != 'all')
|
12 |
+
$Manufacturer_selected_var = $_GET['Manufacturer'];
|
13 |
+
} elseif (isset($_COOKIE['Manufacturer_selected']) && $_COOKIE['Manufacturer_selected'] != 'all')
|
14 |
+
$Manufacturer_selected_var = $_COOKIE['Manufacturer_selected'];
|
15 |
+
|
16 |
+
if (isset($_GET['Model'])){
|
17 |
+
if ($_GET['Model'] != 'all')
|
18 |
+
$Model_selected_var = $_GET['Model'];
|
19 |
+
} elseif (isset($_COOKIE['Model_selected']) && $_COOKIE['Model_selected'] != 'all')
|
20 |
+
$Model_selected_var = $_COOKIE['Model_selected'];
|
21 |
+
|
22 |
+
if (isset($_GET['Number'])){
|
23 |
+
if ($_GET['Number'] != 'all')
|
24 |
+
$Number_selected_var = $_GET['Number'];
|
25 |
+
} elseif (isset($_COOKIE['Number_selected']) && $_COOKIE['Number_selected'] != 'all')
|
26 |
+
$Number_selected_var = $_COOKIE['Number_selected'];
|
27 |
+
|
28 |
+
|
29 |
+
if (isset($Manufacturer_selected_var))
|
30 |
+
$where .= " (manufacturer='".$Manufacturer_selected_var."' or manufacturer='') ";
|
31 |
+
|
32 |
+
if (isset($Model_selected_var))
|
33 |
+
$where .= ($where != '' ? ' and ' : '') . " (model='".$Model_selected_var."' or model='') ";
|
34 |
+
|
35 |
+
if (isset($Number_selected_var))
|
36 |
+
$where .= ($where != '' ? ' and ' : '') . " (number='".$Number_selected_var."' or number='') ";
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
if ($where != ''){
|
41 |
+
|
42 |
+
$resource = Mage::getSingleton('core/resource');
|
43 |
+
$read= $resource->getConnection('core_read');
|
44 |
+
$productTable = $resource->getTableName('catalog_product_entity');
|
45 |
+
$mmnTable = $resource->getTableName('mmn');
|
46 |
+
$rows = $read->fetchAll("SELECT entity_id FROM $productTable LEFT JOIN $mmnTable USING (entity_id) WHERE $where");//mmn_id IS NULL OR
|
47 |
+
|
48 |
+
if(count($rows)>0){
|
49 |
+
foreach ($rows as $r)
|
50 |
+
$ids [] = $r['entity_id'];
|
51 |
+
|
52 |
+
return $ids;
|
53 |
+
|
54 |
+
} else return false;
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
return false;
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
}
|
app/code/local/Pektsekye/Mmn/Model/Mmn.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Mmn_Model_Mmn extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('mmn/mmn');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Pektsekye/Mmn/Model/Mysql4/Mmn.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Mmn_Model_Mysql4_Mmn extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the mmn_id refers to the key field in your database table.
|
8 |
+
$this->_init('mmn/mmn', 'mmn_id');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Pektsekye/Mmn/Model/Mysql4/Mmn/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Mmn_Model_Mysql4_Mmn_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('mmn/mmn');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Pektsekye/Mmn/Model/Status.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Mmn_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('mmn')->__('Enabled'),
|
12 |
+
self::STATUS_DISABLED => Mage::helper('mmn')->__('Disabled')
|
13 |
+
);
|
14 |
+
}
|
15 |
+
}
|
app/code/local/Pektsekye/Mmn/controllers/Adminhtml/MmnController.php
ADDED
@@ -0,0 +1,290 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Mmn_Adminhtml_MmnController extends Mage_Adminhtml_Controller_action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('mmn/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('mmn/mmn')->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('mmn_data', $model);
|
30 |
+
|
31 |
+
$this->loadLayout();
|
32 |
+
$this->_setActiveMenu('mmn/items');
|
33 |
+
|
34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
35 |
+
|
36 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
37 |
+
|
38 |
+
$this->_addContent($this->getLayout()->createBlock('mmn/adminhtml_mmn_edit'))
|
39 |
+
->_addLeft($this->getLayout()->createBlock('mmn/adminhtml_mmn_edit_tabs'));
|
40 |
+
|
41 |
+
$this->renderLayout();
|
42 |
+
} else {
|
43 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('mmn')->__('Item does not exist'));
|
44 |
+
$this->_redirect('*/*/');
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
public function newAction() {
|
49 |
+
$this->_forward('edit');
|
50 |
+
}
|
51 |
+
|
52 |
+
public function saveAction() {
|
53 |
+
if ($data = $this->getRequest()->getPost()) {
|
54 |
+
|
55 |
+
$data ['entity_id'] = (int) $data ['entity_id'];
|
56 |
+
$data ['manufacturer'] = trim(preg_replace('/[^\w\s-]/','',$data ['manufacturer']));
|
57 |
+
$data ['model'] = trim(preg_replace('/[^\w\s-]/','',$data ['model']));
|
58 |
+
$data ['number'] = trim(preg_replace('/[^\w\s-]/','',$data ['number']));
|
59 |
+
|
60 |
+
$model = Mage::getModel('mmn/mmn');
|
61 |
+
$model->setData($data)
|
62 |
+
->setId($this->getRequest()->getParam('id'));
|
63 |
+
|
64 |
+
try {
|
65 |
+
|
66 |
+
$model->save();
|
67 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('mmn')->__('Item was successfully saved'));
|
68 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
69 |
+
|
70 |
+
if ($this->getRequest()->getParam('back')) {
|
71 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
72 |
+
return;
|
73 |
+
}
|
74 |
+
$this->_redirect('*/*/');
|
75 |
+
return;
|
76 |
+
} catch (Exception $e) {
|
77 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
78 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
79 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('mmn')->__('Unable to find item to save'));
|
84 |
+
$this->_redirect('*/*/');
|
85 |
+
}
|
86 |
+
|
87 |
+
public function deleteAction() {
|
88 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
89 |
+
try {
|
90 |
+
$model = Mage::getModel('mmn/mmn');
|
91 |
+
|
92 |
+
$model->setId($this->getRequest()->getParam('id'))
|
93 |
+
->delete();
|
94 |
+
|
95 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
96 |
+
$this->_redirect('*/*/');
|
97 |
+
} catch (Exception $e) {
|
98 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
99 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
100 |
+
}
|
101 |
+
}
|
102 |
+
$this->_redirect('*/*/');
|
103 |
+
}
|
104 |
+
|
105 |
+
public function massDeleteAction() {
|
106 |
+
$mmnIds = $this->getRequest()->getParam('mmn');
|
107 |
+
if(!is_array($mmnIds)) {
|
108 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
109 |
+
} else {
|
110 |
+
try {
|
111 |
+
foreach ($mmnIds as $mmnId) {
|
112 |
+
$mmn = Mage::getModel('mmn/mmn')->load($mmnId);
|
113 |
+
$mmn->delete();
|
114 |
+
}
|
115 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
116 |
+
Mage::helper('adminhtml')->__(
|
117 |
+
'Total of %d record(s) were successfully deleted', count($mmnIds)
|
118 |
+
)
|
119 |
+
);
|
120 |
+
} catch (Exception $e) {
|
121 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
122 |
+
}
|
123 |
+
}
|
124 |
+
$this->_redirect('*/*/index');
|
125 |
+
}
|
126 |
+
|
127 |
+
public function massStatusAction()
|
128 |
+
{
|
129 |
+
$mmnIds = $this->getRequest()->getParam('mmn');
|
130 |
+
if(!is_array($mmnIds)) {
|
131 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
|
132 |
+
} else {
|
133 |
+
try {
|
134 |
+
foreach ($mmnIds as $mmnId) {
|
135 |
+
$mmn = Mage::getSingleton('mmn/mmn')
|
136 |
+
->load($mmnId)
|
137 |
+
->setStatus($this->getRequest()->getParam('status'))
|
138 |
+
->setIsMassupdate(true)
|
139 |
+
->save();
|
140 |
+
}
|
141 |
+
$this->_getSession()->addSuccess(
|
142 |
+
$this->__('Total of %d record(s) were successfully updated', count($mmnIds))
|
143 |
+
);
|
144 |
+
} catch (Exception $e) {
|
145 |
+
$this->_getSession()->addError($e->getMessage());
|
146 |
+
}
|
147 |
+
}
|
148 |
+
$this->_redirect('*/*/index');
|
149 |
+
}
|
150 |
+
|
151 |
+
|
152 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
153 |
+
{
|
154 |
+
$response = $this->getResponse();
|
155 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
156 |
+
$response->setHeader('Pragma', 'public', true);
|
157 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
158 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
159 |
+
$response->setHeader('Last-Modified', date('r'));
|
160 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
161 |
+
$response->setHeader('Content-Length', strlen($content));
|
162 |
+
$response->setHeader('Content-type', $contentType);
|
163 |
+
$response->setBody($content);
|
164 |
+
$response->sendResponse();
|
165 |
+
die;
|
166 |
+
}
|
167 |
+
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Import and export Page
|
171 |
+
*
|
172 |
+
*/
|
173 |
+
public function importExportAction()
|
174 |
+
{
|
175 |
+
$this->loadLayout()
|
176 |
+
->_setActiveMenu('mmn/import')
|
177 |
+
->_addContent($this->getLayout()->createBlock('mmn/adminhtml_mmn_importExport'))
|
178 |
+
->renderLayout();
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* import action from import/export mmn
|
183 |
+
*
|
184 |
+
*/
|
185 |
+
public function importPostAction()
|
186 |
+
{
|
187 |
+
if ($this->getRequest()->isPost() && !empty($_FILES['import_mmn_file']['tmp_name'])) {
|
188 |
+
try {
|
189 |
+
$number = $this->_importMmn();
|
190 |
+
|
191 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('mmn')->__('%d new item(s) were imported',$number));
|
192 |
+
}
|
193 |
+
catch (Mage_Core_Exception $e) {
|
194 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
195 |
+
}
|
196 |
+
catch (Exception $e) {
|
197 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('mmn')->__('Invalid file upload attempt'));
|
198 |
+
}
|
199 |
+
}
|
200 |
+
else {
|
201 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('mmn')->__('Invalid file upload attempt'));
|
202 |
+
}
|
203 |
+
$this->_redirect('*/*/importExport');
|
204 |
+
}
|
205 |
+
|
206 |
+
protected function _importMmn()
|
207 |
+
{
|
208 |
+
$fileName = $_FILES['import_mmn_file']['tmp_name'];
|
209 |
+
$csvObject = new Varien_File_Csv();
|
210 |
+
$csvData = $csvObject->getData($fileName);
|
211 |
+
$number = 0;
|
212 |
+
/** checks columns */
|
213 |
+
$csvFields = array(
|
214 |
+
0 => Mage::helper('mmn')->__('Products ID'),
|
215 |
+
1 => Mage::helper('mmn')->__('Printer Manufacturer'),
|
216 |
+
2 => Mage::helper('mmn')->__('Printer Model'),
|
217 |
+
3 => Mage::helper('mmn')->__('Printer Number')
|
218 |
+
);
|
219 |
+
|
220 |
+
if ($csvData[0] == $csvFields) {
|
221 |
+
foreach ($csvData as $k => $v) {
|
222 |
+
if ($k == 0) {
|
223 |
+
continue;
|
224 |
+
}
|
225 |
+
|
226 |
+
//end of file has more then one empty lines
|
227 |
+
if (count($v) <= 1 && !strlen($v[0])) {
|
228 |
+
continue;
|
229 |
+
}
|
230 |
+
|
231 |
+
if (count($csvFields) != count($v)) {
|
232 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('mmn')->__('Invalid file upload attempt'));
|
233 |
+
}
|
234 |
+
|
235 |
+
if (!empty($v[0]) && is_numeric($v[0]) && !empty($v[1])) {
|
236 |
+
|
237 |
+
$v[1] = trim(preg_replace('/[^\w\s-]/','',$v[1]));
|
238 |
+
$v[2] = trim(preg_replace('/[^\w\s-]/','',$v[2]));
|
239 |
+
$v[3] = trim(preg_replace('/[^\w\s-]/','',$v[3]));
|
240 |
+
|
241 |
+
$resource = Mage::getSingleton('core/resource');
|
242 |
+
$read= $resource->getConnection('core_read');
|
243 |
+
$mmnTable = $resource->getTableName('mmn');
|
244 |
+
$select = $read->select()
|
245 |
+
->from($mmnTable,array('mmn_id'))
|
246 |
+
->where("entity_id=?",(int)$v[0])
|
247 |
+
->where("manufacturer=?",$v[1])
|
248 |
+
->where("model=?",$v[2])
|
249 |
+
->where("number=?",$v[3])
|
250 |
+
->limit(1);
|
251 |
+
|
252 |
+
if($read->fetchOne($select)){
|
253 |
+
continue;
|
254 |
+
}
|
255 |
+
|
256 |
+
$data = array(
|
257 |
+
'entity_id'=>$v[0],
|
258 |
+
'manufacturer' => $v[1],
|
259 |
+
'model' => $v[2],
|
260 |
+
'number' => $v[3]
|
261 |
+
);
|
262 |
+
|
263 |
+
$model = Mage::getModel('mmn/mmn');
|
264 |
+
$model->setData($data);
|
265 |
+
$model->save();
|
266 |
+
$number++;
|
267 |
+
}
|
268 |
+
}
|
269 |
+
}
|
270 |
+
else {
|
271 |
+
Mage::throwException(Mage::helper('mmn')->__('Invalid file format upload attempt'));
|
272 |
+
}
|
273 |
+
|
274 |
+
return $number;
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* export action from import/export tax
|
279 |
+
*
|
280 |
+
*/
|
281 |
+
public function exportPostAction()
|
282 |
+
{
|
283 |
+
$fileName = 'mmn.csv';
|
284 |
+
$content = $this->getLayout()->createBlock('mmn/adminhtml_mmn_grid')
|
285 |
+
->getCsv();
|
286 |
+
|
287 |
+
$this->_sendUploadResponse($fileName, $content);
|
288 |
+
}
|
289 |
+
|
290 |
+
}
|
app/code/local/Pektsekye/Mmn/controllers/IndexController.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Mmn_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/Mmn/controllers/ProductController.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Pektsekye_Mmn_ProductController extends Mage_Core_Controller_Front_Action
|
4 |
+
{
|
5 |
+
|
6 |
+
public function listAction()
|
7 |
+
{
|
8 |
+
if(!$this->getRequest()->getParam('Manufacturer') || $this->getRequest()->getParam('Manufacturer') == 'all') {
|
9 |
+
$this->getResponse()->setRedirect(Mage::getBaseUrl());
|
10 |
+
return;
|
11 |
+
}
|
12 |
+
|
13 |
+
if(!Mage::helper('mmn')->getProductIds()){
|
14 |
+
$this->getResponse()->setRedirect(Mage::getBaseUrl());
|
15 |
+
return;
|
16 |
+
}
|
17 |
+
|
18 |
+
$this->loadLayout();
|
19 |
+
$this->_initLayoutMessages('checkout/session');
|
20 |
+
$this->_initLayoutMessages('tag/session');
|
21 |
+
$this->renderLayout();
|
22 |
+
}
|
23 |
+
}
|
app/code/local/Pektsekye/Mmn/etc/config.xml
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Pektsekye_Mmn>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Pektsekye_Mmn>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<mmn>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Pektsekye_Mmn</module>
|
14 |
+
<frontName>mmn</frontName>
|
15 |
+
</args>
|
16 |
+
</mmn>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<mmn>
|
21 |
+
<file>mmn.xml</file>
|
22 |
+
</mmn>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<mmn>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>Pektsekye_Mmn</module>
|
32 |
+
<frontName>mmn</frontName>
|
33 |
+
</args>
|
34 |
+
</mmn>
|
35 |
+
</routers>
|
36 |
+
</admin>
|
37 |
+
<adminhtml>
|
38 |
+
<menu>
|
39 |
+
<mmn module="mmn">
|
40 |
+
<title>Mmn</title>
|
41 |
+
<sort_order>71</sort_order>
|
42 |
+
<children>
|
43 |
+
<items module="mmn">
|
44 |
+
<title>Manage Items</title>
|
45 |
+
<sort_order>0</sort_order>
|
46 |
+
<action>mmn/adminhtml_mmn</action>
|
47 |
+
</items>
|
48 |
+
<import module="mmn">
|
49 |
+
<title>Import / Export</title>
|
50 |
+
<sort_order>1</sort_order>
|
51 |
+
<action>mmn/adminhtml_mmn/importExport</action>
|
52 |
+
</import>
|
53 |
+
</children>
|
54 |
+
</mmn>
|
55 |
+
</menu>
|
56 |
+
<acl>
|
57 |
+
<resources>
|
58 |
+
<all>
|
59 |
+
<title>Allow Everything</title>
|
60 |
+
</all>
|
61 |
+
<admin>
|
62 |
+
<children>
|
63 |
+
<Pektsekye_Mmn>
|
64 |
+
<title>Mmn Module</title>
|
65 |
+
<sort_order>10</sort_order>
|
66 |
+
</Pektsekye_Mmn>
|
67 |
+
</children>
|
68 |
+
</admin>
|
69 |
+
</resources>
|
70 |
+
</acl>
|
71 |
+
<layout>
|
72 |
+
<updates>
|
73 |
+
<mmn>
|
74 |
+
<file>mmn.xml</file>
|
75 |
+
</mmn>
|
76 |
+
</updates>
|
77 |
+
</layout>
|
78 |
+
</adminhtml>
|
79 |
+
<global>
|
80 |
+
<models>
|
81 |
+
<catalog>
|
82 |
+
<rewrite>
|
83 |
+
<category>Pektsekye_Catalog_Model_Category</category>
|
84 |
+
</rewrite>
|
85 |
+
</catalog>
|
86 |
+
<catalog_resource_eav_mysql4>
|
87 |
+
<rewrite>
|
88 |
+
<category>Pektsekye_Catalog_Model_Resource_Eav_Mysql4_Category</category>
|
89 |
+
</rewrite>
|
90 |
+
</catalog_resource_eav_mysql4>
|
91 |
+
<catalogsearch>
|
92 |
+
<rewrite>
|
93 |
+
<layer>Pektsekye_CatalogSearch_Model_Layer</layer>
|
94 |
+
</rewrite>
|
95 |
+
</catalogsearch>
|
96 |
+
<mmn>
|
97 |
+
<class>Pektsekye_Mmn_Model</class>
|
98 |
+
<resourceModel>mmn_mysql4</resourceModel>
|
99 |
+
</mmn>
|
100 |
+
<mmn_mysql4>
|
101 |
+
<class>Pektsekye_Mmn_Model_Mysql4</class>
|
102 |
+
<entities>
|
103 |
+
<mmn>
|
104 |
+
<table>mmn</table>
|
105 |
+
</mmn>
|
106 |
+
</entities>
|
107 |
+
</mmn_mysql4>
|
108 |
+
</models>
|
109 |
+
<resources>
|
110 |
+
|
111 |
+
<mmn_setup>
|
112 |
+
<setup>
|
113 |
+
<module>Pektsekye_Mmn</module>
|
114 |
+
</setup>
|
115 |
+
<connection>
|
116 |
+
<use>core_setup</use>
|
117 |
+
</connection>
|
118 |
+
</mmn_setup>
|
119 |
+
<mmn_write>
|
120 |
+
<connection>
|
121 |
+
<use>core_write</use>
|
122 |
+
</connection>
|
123 |
+
</mmn_write>
|
124 |
+
<mmn_read>
|
125 |
+
<connection>
|
126 |
+
<use>core_read</use>
|
127 |
+
</connection>
|
128 |
+
</mmn_read>
|
129 |
+
</resources>
|
130 |
+
<blocks>
|
131 |
+
<mmn>
|
132 |
+
<class>Pektsekye_Mmn_Block</class>
|
133 |
+
</mmn>
|
134 |
+
</blocks>
|
135 |
+
<helpers>
|
136 |
+
<mmn>
|
137 |
+
<class>Pektsekye_Mmn_Helper</class>
|
138 |
+
</mmn>
|
139 |
+
</helpers>
|
140 |
+
</global>
|
141 |
+
|
142 |
+
<default>
|
143 |
+
<catalog>
|
144 |
+
<navigation>
|
145 |
+
<filtering>1</filtering>
|
146 |
+
</navigation>
|
147 |
+
<search>
|
148 |
+
<filtering>1</filtering>
|
149 |
+
</search>
|
150 |
+
</catalog>
|
151 |
+
</default>
|
152 |
+
|
153 |
+
</config>
|
app/code/local/Pektsekye/Mmn/etc/system.xml
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<sections>
|
5 |
+
<catalog translate="label" module="catalog">
|
6 |
+
<groups>
|
7 |
+
<navigation translate="label">
|
8 |
+
<fields>
|
9 |
+
<filtering translate="label">
|
10 |
+
<label>Enable MMN Filtering</label>
|
11 |
+
<frontend_type>select</frontend_type>
|
12 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
13 |
+
<sort_order>2</sort_order>
|
14 |
+
<show_in_default>1</show_in_default>
|
15 |
+
<show_in_website>1</show_in_website>
|
16 |
+
<show_in_store>1</show_in_store>
|
17 |
+
<comment>cache refresh needed</comment>
|
18 |
+
</filtering>
|
19 |
+
</fields>
|
20 |
+
</navigation>
|
21 |
+
<search translate="label">
|
22 |
+
<fields>
|
23 |
+
<filtering translate="label">
|
24 |
+
<label>Enable MMN Filtering</label>
|
25 |
+
<frontend_type>select</frontend_type>
|
26 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
27 |
+
<sort_order>6</sort_order>
|
28 |
+
<show_in_default>1</show_in_default>
|
29 |
+
<show_in_website>1</show_in_website>
|
30 |
+
<show_in_store>1</show_in_store>
|
31 |
+
</filtering>
|
32 |
+
</fields>
|
33 |
+
</search>
|
34 |
+
</groups>
|
35 |
+
</catalog>
|
36 |
+
</sections>
|
37 |
+
</config>
|
app/code/local/Pektsekye/Mmn/sql/mmn_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//core_resource table
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
DROP TABLE IF EXISTS {$this->getTable('mmn')};
|
9 |
+
CREATE TABLE {$this->getTable('mmn')} (
|
10 |
+
`mmn_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
11 |
+
`entity_id` INT NOT NULL ,
|
12 |
+
`manufacturer` VARCHAR( 100 ) NOT NULL ,
|
13 |
+
`model` VARCHAR( 100 ) NOT NULL ,
|
14 |
+
`number` VARCHAR( 100 ) NOT NULL
|
15 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
16 |
+
|
17 |
+
");
|
18 |
+
|
19 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/mmn.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<mmn_adminhtml_mmn_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="mmn/adminhtml_mmn" name="mmn" />
|
6 |
+
</reference>
|
7 |
+
</mmn_adminhtml_mmn_index>
|
8 |
+
</layout>
|
app/design/adminhtml/default/default/template/mmn/importExport.phtml
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="content-header">
|
2 |
+
<table cellspacing="0">
|
3 |
+
<tr>
|
4 |
+
<td><h3 class="icon-head head-tax-rate-importExport"><?php echo Mage::helper('mmn')->__('Import / Export') ?></h3></td>
|
5 |
+
</tr>
|
6 |
+
</table>
|
7 |
+
</div>
|
8 |
+
<div class="entry-edit">
|
9 |
+
<div class="box-left">
|
10 |
+
<form id="import_form" action="<?php echo $this->getUrl('*/*/importPost') ?>" method="post" enctype="multipart/form-data">
|
11 |
+
<?php echo $this->getBlockHtml('formkey')?>
|
12 |
+
<div class="entry-edit-head">
|
13 |
+
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('mmn')->__('Import MMN items') ?></h4>
|
14 |
+
</div>
|
15 |
+
<fieldset>
|
16 |
+
<legend><?php echo Mage::helper('mmn')->__('Import MMN items') ?></legend>
|
17 |
+
<input type="file" name="import_mmn_file" class="input-file required-entry"/>
|
18 |
+
<?php echo $this->getButtonHtml('Import MMN items', "this.form.submit()") ?>
|
19 |
+
</fieldset>
|
20 |
+
</form>
|
21 |
+
<script type="text/javascript">
|
22 |
+
var importForm = new varienForm('import_form');
|
23 |
+
</script>
|
24 |
+
</div>
|
25 |
+
<div class="box-right">
|
26 |
+
<form id="export_form" action="<?php echo $this->getUrl('*/*/exportPost') ?>" method="post" enctype="multipart/form-data">
|
27 |
+
<?php echo $this->getBlockHtml('formkey')?>
|
28 |
+
<div class="entry-edit-head">
|
29 |
+
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('mmn')->__('Export MMN items') ?></h4>
|
30 |
+
</div>
|
31 |
+
<fieldset>
|
32 |
+
<legend><?php echo Mage::helper('mmn')->__('Export MMN items') ?></legend>
|
33 |
+
<?php echo $this->getButtonHtml('Export MMN items', "this.form.submit()") ?>
|
34 |
+
</fieldset>
|
35 |
+
</form>
|
36 |
+
</div>
|
37 |
+
<div class="clear"></div>
|
38 |
+
</div>
|
app/design/frontend/default/default/layout/mmn.xml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
|
4 |
+
<default>
|
5 |
+
<reference name="right">
|
6 |
+
<block type="mmn/mmn" name="mmn" before="-" template="mmn/mmn.phtml"/>
|
7 |
+
</reference>
|
8 |
+
</default>
|
9 |
+
|
10 |
+
<mmn_product_list>
|
11 |
+
<reference name="right">
|
12 |
+
<block type="catalogsearch/layer" name="catalogsearch.leftnav" after="mmn" template="catalog/layer/view.phtml"/>
|
13 |
+
</reference>
|
14 |
+
<reference name="content">
|
15 |
+
<block type="mmn/product_result" name="mmn_products" template="catalogsearch/result.phtml">
|
16 |
+
<block type="catalog/product_list" name="search_result_list" template="catalog/product/list.phtml"></block>
|
17 |
+
<action method="setListOrders"/>
|
18 |
+
<action method="setListModes"/>
|
19 |
+
<action method="setListCollection"/>
|
20 |
+
</block>
|
21 |
+
</reference>
|
22 |
+
</mmn_product_list>
|
23 |
+
|
24 |
+
</layout>
|
app/design/frontend/default/default/template/mmn/mmn.phtml
ADDED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$request = $this->getRequest();
|
4 |
+
$module = $request->getModuleName() .'_'. $request->getControllerName() .'_'. $request->getActionName();
|
5 |
+
$resource = Mage::getSingleton('core/resource');
|
6 |
+
$read= $resource->getConnection('core_read');
|
7 |
+
$mmnTable = $resource->getTableName('mmn');
|
8 |
+
|
9 |
+
$select = $read->select()
|
10 |
+
->distinct()
|
11 |
+
->from($mmnTable,array('manufacturer','model','number'))
|
12 |
+
->where('manufacturer != ?','')
|
13 |
+
->where('model != ?','')
|
14 |
+
->where('model != ?','')
|
15 |
+
->order(array('manufacturer', 'model', 'number')) ;
|
16 |
+
|
17 |
+
$rows = $read->fetchAll($select);
|
18 |
+
|
19 |
+
if (count($rows) > 0) {
|
20 |
+
|
21 |
+
$Manufacturer_array[] = array('id' => 'all', 'text' => 'Choose Manufacturer');
|
22 |
+
$Model_array[] = array('id' => 'all', 'text' => 'Choose Model');
|
23 |
+
$Number_array[] = array('id' => 'all', 'text' => 'Choose Number');
|
24 |
+
|
25 |
+
$javascript = '<script language="javascript" type="text/javascript">
|
26 |
+
var a = new Array();
|
27 |
+
var b = new Array();
|
28 |
+
var c = new Array();';
|
29 |
+
|
30 |
+
$M_a = array();
|
31 |
+
|
32 |
+
foreach ($rows as $r) {
|
33 |
+
|
34 |
+
if (!isset($M_a [$r['manufacturer']]))
|
35 |
+
$Manufacturer_array[] = array('id' => $r['manufacturer'], 'text' => $r['manufacturer']);
|
36 |
+
|
37 |
+
$M_a [$r['manufacturer']][$r['model']][$r['number']] = 1;
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
$i = 0;
|
42 |
+
foreach ($M_a as $k =>$v){
|
43 |
+
$javascript .= 'a['.$i.']="'.$k.'";b['.$i.']=new Array(';
|
44 |
+
$ii = 0;
|
45 |
+
$s = '';
|
46 |
+
foreach ($M_a[$k] as $kk =>$vv){
|
47 |
+
$javascript .= ($ii != 0 ? ',' : '').'"'.$kk.'"';
|
48 |
+
$ss = '';
|
49 |
+
$iii = 0;
|
50 |
+
foreach ($M_a[$k][$kk] as $kkk => $vvv){
|
51 |
+
$ss .= ($iii != 0 ? ',' : '').'"'.$kkk.'"';
|
52 |
+
$iii++;
|
53 |
+
}
|
54 |
+
$s .= 'c['.$i.']['.$ii.']=new Array('.$ss.');';
|
55 |
+
$ii++;
|
56 |
+
}
|
57 |
+
$javascript .= ');c['.$i.']=new Array();'.$s;
|
58 |
+
$i++;
|
59 |
+
}
|
60 |
+
|
61 |
+
$javascript .= '
|
62 |
+
function pop_model(){
|
63 |
+
|
64 |
+
var o ="<select name=\"Model\" onChange=\"pop_number();\" style=\"width: 100%\"><option value=\"all\">Choose Model</option>";
|
65 |
+
var sv = document.manufacturer_model_number.Manufacturer.value;
|
66 |
+
if(sv != "all"){
|
67 |
+
var v = a.length;
|
68 |
+
while(v--) if(sv == a[v]) break;
|
69 |
+
for(var i = 0; i < b[v].length; i++)
|
70 |
+
o+="<option value=\""+b[v][i]+"\">"+b[v][i]+"</option>";
|
71 |
+
}
|
72 |
+
o+="</select>";
|
73 |
+
document.getElementById("model_select").innerHTML= o;
|
74 |
+
document.getElementById("number_select").innerHTML= "<select name=\"Number\" style=\"width: 100%\"><option value=\"all\">Choose Number</option></select>";
|
75 |
+
}
|
76 |
+
function pop_number(){
|
77 |
+
|
78 |
+
var o ="<select name=\"Number\" style=\"width: 100%\" onChange=\"document.manufacturer_model_number.submit();\"><option value=\"all\">Choose Number</option>";
|
79 |
+
var sv = document.manufacturer_model_number.Manufacturer.value;
|
80 |
+
if(sv != "all"){
|
81 |
+
var v = a.length;
|
82 |
+
while(v--) if(sv == a[v]) break;
|
83 |
+
var sv2 = document.manufacturer_model_number.Model.value;
|
84 |
+
if(sv2 != "all"){
|
85 |
+
var v2 = b[v].length;
|
86 |
+
while(v2--) if(sv2 == b[v][v2]) break;
|
87 |
+
for(var i = 0; i < c[v][v2].length; i++)
|
88 |
+
o+="<option value=\""+c[v][v2][i]+"\">"+c[v][v2][i]+"</option>";
|
89 |
+
}
|
90 |
+
}
|
91 |
+
o+="</select>";
|
92 |
+
document.getElementById("number_select").innerHTML= o;
|
93 |
+
}
|
94 |
+
</script>';
|
95 |
+
|
96 |
+
$expire = time()+60*60*24*90;
|
97 |
+
|
98 |
+
if (isset($_GET['Manufacturer'])){
|
99 |
+
setcookie("Manufacturer_selected", $_GET['Manufacturer'], $expire,'/');
|
100 |
+
if ($_GET['Manufacturer'] != 'all')
|
101 |
+
$Manufacturer_selected_var = $_GET['Manufacturer'];
|
102 |
+
} elseif (isset($_COOKIE['Manufacturer_selected']) && $_COOKIE['Manufacturer_selected'] != 'all')
|
103 |
+
$Manufacturer_selected_var = $_COOKIE['Manufacturer_selected'];
|
104 |
+
|
105 |
+
if (isset($_GET['Model'])){
|
106 |
+
setcookie("Model_selected", $_GET['Model'], $expire,'/');
|
107 |
+
if ($_GET['Model'] != 'all')
|
108 |
+
$Model_selected_var = $_GET['Model'];
|
109 |
+
} elseif (isset($_COOKIE['Model_selected']) && $_COOKIE['Model_selected'] != 'all')
|
110 |
+
$Model_selected_var = $_COOKIE['Model_selected'];
|
111 |
+
|
112 |
+
if (isset($_GET['Number'])){
|
113 |
+
setcookie("Number_selected", $_GET['Number'], $expire,'/');
|
114 |
+
if ($_GET['Number'] != 'all')
|
115 |
+
$Number_selected_var = $_GET['Number'];
|
116 |
+
} elseif (isset($_COOKIE['Number_selected']) && $_COOKIE['Number_selected'] != 'all')
|
117 |
+
$Number_selected_var = $_COOKIE['Number_selected'];
|
118 |
+
|
119 |
+
if (isset($Manufacturer_selected_var) && isset($M_a[$Manufacturer_selected_var]))
|
120 |
+
foreach ($M_a[$Manufacturer_selected_var] as $k => $v)
|
121 |
+
$Model_array[] = array('id' => $k, 'text' => $k);
|
122 |
+
if (isset($Manufacturer_selected_var) && isset($Model_selected_var) && isset($M_a[$Manufacturer_selected_var][$Model_selected_var]))
|
123 |
+
foreach ($M_a[$Manufacturer_selected_var][$Model_selected_var] as $k => $v)
|
124 |
+
$Number_array[] = array('id' => $k, 'text' => $k);
|
125 |
+
|
126 |
+
echo $javascript;
|
127 |
+
|
128 |
+
?>
|
129 |
+
<div class="box base-mini mini-poll">
|
130 |
+
<div class="head">
|
131 |
+
<h4><span><?php echo $this->__('Select Printer') ?></span></h4>
|
132 |
+
</div>
|
133 |
+
<form name="manufacturer_model_number" action="<?php
|
134 |
+
$hidden = '';
|
135 |
+
if($module == 'catalog_category_view'){
|
136 |
+
echo '';
|
137 |
+
} elseif ($module == 'catalogsearch_result_index' && Mage::getStoreConfig('catalog/search/filtering', Mage::app()->getStore()->getStoreId())){
|
138 |
+
$hidden = '<input type="hidden" name="q" value="' . $request->getParam('q') . '">';
|
139 |
+
} else {
|
140 |
+
echo Mage::getUrl('mmn/product/list');
|
141 |
+
}
|
142 |
+
|
143 |
+
?>" method="get">
|
144 |
+
<?php echo $hidden; ?>
|
145 |
+
<div class="content">
|
146 |
+
<select name="Manufacturer" onChange="pop_model();" style="width: 100%">
|
147 |
+
<?php
|
148 |
+
foreach($Manufacturer_array as $option)
|
149 |
+
echo '<option value="'.$option['id'].'" '.(isset($Manufacturer_selected_var) && $Manufacturer_selected_var == $option['id'] ? 'SELECTED' : '').'>'.$option['text'].'</option>';
|
150 |
+
?>
|
151 |
+
</select><br><br>
|
152 |
+
<span id="model_select">
|
153 |
+
<select name="Model" onChange="pop_number();" style="width: 100%">
|
154 |
+
<?php
|
155 |
+
foreach($Model_array as $option)
|
156 |
+
echo '<option value="'.$option['id'].'" '.(isset($Model_selected_var) && $Model_selected_var == $option['id'] ? 'SELECTED' : '').'>'.$option['text'].'</option>';
|
157 |
+
?>
|
158 |
+
</select></span><br><br>
|
159 |
+
<span id="number_select">
|
160 |
+
<select name="Number" onChange="document.manufacturer_model_number.submit();" style="width: 100%">
|
161 |
+
<?php
|
162 |
+
foreach($Number_array as $option)
|
163 |
+
echo '<option value="'.$option['id'].'" '.(isset($Number_selected_var) && $Number_selected_var == $option['id'] ? 'SELECTED' : '').'>'.$option['text'].'</option>';
|
164 |
+
?>
|
165 |
+
</select></span><br><br>
|
166 |
+
</div>
|
167 |
+
<div class="actions">
|
168 |
+
<button class="form-button-alt right" type="submit"><span><?php echo $this->__('Go') ?></span></button>
|
169 |
+
<?php if(isset($Manufacturer_selected_var)): ?>
|
170 |
+
<a href="<?php
|
171 |
+
if($module == 'catalog_category_view'){
|
172 |
+
echo '?';
|
173 |
+
} elseif ($module == 'catalogsearch_result_index' && Mage::getStoreConfig('catalog/search/filtering', Mage::app()->getStore()->getStoreId())){
|
174 |
+
echo '?q=' . $request->getParam('q') . '&';
|
175 |
+
} else {
|
176 |
+
echo Mage::getBaseUrl() . '?';
|
177 |
+
}
|
178 |
+
?>Manufacturer=all&Model=all&Number=all">Clear Printer</a>
|
179 |
+
<?php endif ?>
|
180 |
+
</div>
|
181 |
+
</form>
|
182 |
+
</div>
|
183 |
+
<?php
|
184 |
+
}
|
185 |
+
?>
|
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_CatalogSearch.xml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<Pektsekye_CatalogSearch>
|
4 |
+
<active>true</active>
|
5 |
+
<codePool>local</codePool>
|
6 |
+
</Pektsekye_CatalogSearch>
|
7 |
+
</config>
|
app/etc/modules/Pektsekye_Mmn.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Pektsekye_Mmn>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Pektsekye_Mmn>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Manufacturer_Model_Number</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>Manufacturer Model Number (MMN) "Select Printer" filter box for Printer Cartridges web sites</summary>
|
10 |
+
<description>This small extension makes it impossible for a customer to filter products by Printer manufacturer, model and number.
|
11 |
+
|
12 |
+
HOW TO USE:
|
13 |
+
Go to your Magento admin panel ->Mmn -> Manage Items and add MMN items to all your products.</description>
|
14 |
+
<notes>The first version. The code is based on YMM extension v 4.4</notes>
|
15 |
+
<authors><author><name>Stanislav</name><user>auto-converted</user><email>pektsekye@gmail.com</email></author></authors>
|
16 |
+
<date>2009-08-08</date>
|
17 |
+
<time>18:00:19</time>
|
18 |
+
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="mmn.xml" hash="ccce6ec54f314a5cba835ed503aab154"/></dir><dir name="template"><dir name="mmn"><file name="importExport.phtml" hash="23a7b58d473f29f66b943f5ca678dd8f"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="mmn.xml" hash="8252b14ca06d69664202ed9cbdd7a41b"/></dir><dir name="template"><dir name="mmn"><file name="mmn.phtml" hash="cde2986d19c003210757ac97d1049b30"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Pektsekye_Catalog.xml" hash="89e3ec6056b4ba53d06df1370b347d42"/><file name="Pektsekye_CatalogSearch.xml" hash="c1152b8350ae4906db9736369c8e5edf"/><file name="Pektsekye_Mmn.xml" hash="44dbf66ea36b134b159edb1d51878a2a"/></dir></target><target name="magelocal"><dir name="Pektsekye"><dir name="Catalog"><dir name="Model"><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Category.php" hash="581fafac71ce0965cb48543bc8b26d80"/></dir></dir></dir><file name="Category.php" hash="418df457636d063fbcbc0e7266b2cf0b"/></dir></dir><dir name="CatalogSearch"><dir name="Model"><file name="Layer.php" hash="92da80a8187107d6eeebd25eaa718655"/></dir></dir><dir name="Mmn"><dir name="Block"><dir name="Adminhtml"><dir name="Mmn"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="c43285bb92566f85d1451297cb83f81a"/></dir><file name="Form.php" hash="3e2719346ecd021383a091efa5621611"/><file name="Tabs.php" hash="566c0485654104d853ccc55c78336cc4"/></dir><file name="Edit.php" hash="75610373c3eb5e335a3ff344716a1ea3"/><file name="Grid.php" hash="f0c4dbcbc1272a417780865d959da86f"/><file name="ImportExport.php" hash="a475879ab7f6c831aa01fc9927fda212"/></dir><file name="Mmn.php" hash="6ff0685d30001b1d32511bc0cd091c02"/></dir><dir name="Product"><file name="Result.php" hash="00641875e34a3bc2851f6785a9975f81"/></dir><file name="Mmn.php" hash="9c6bc640466ef349fc9fac3023f9f332"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="MmnController.php" hash="23e03d59bdf2065d3d6bd9b3e6edd36b"/></dir><file name="IndexController.php" hash="aa43963369f7166820a20bec5c2d1c8b"/><file name="ProductController.php" hash="6f36953551c101f2d0e890b2569b8444"/></dir><dir name="etc"><file name="config.xml" hash="c4ebca715b08af7a55f5a96fb9e1d73f"/><file name="system.xml" hash="9d2b000bba821307bde419a4e2b2fb13"/></dir><dir name="Helper"><file name="Data.php" hash="8b54f296fe7c06784a9fba900f9b0c35"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Mmn"><file name="Collection.php" hash="7a9240e2cef54b5e1796fb12d2d9369f"/></dir><file name="Mmn.php" hash="c67333dbda050636e9a85e7cfd963bdb"/></dir><file name="Mmn.php" hash="cef143b02735b99c273a8188efee3a38"/><file name="Status.php" hash="7706d422d80badeac80e81985fc2fe79"/></dir><dir name="sql"><dir name="mmn_setup"><file name="mysql4-install-0.1.0.php" hash="e0b1a7ec159b3ff8aa0d16cc4c3d32a0"/></dir></dir></dir></dir></target></contents>
|
19 |
+
<compatible/>
|
20 |
+
<dependencies/>
|
21 |
+
</package>
|