Version Notes
Import feature was added
Download this release
Release Info
| Developer | Magento Core Team |
| Extension | Year_Make_Model_Filter_Box |
| Version | 2.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.1 to 2.0
- app/code/local/Pektsekye/Adminhtml/Block/Page/Footer.php +0 -26
- app/code/local/Pektsekye/Adminhtml/etc/config.xml +0 -17
- app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Edit.php +1 -1
- app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Edit/Form.php +1 -2
- app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Grid.php +4 -29
- app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/ImportExport.php +10 -0
- app/code/local/Pektsekye/Ymm/controllers/Adminhtml/YmmController.php +132 -53
- app/code/local/Pektsekye/Ymm/etc/config.xml +7 -2
- app/code/local/Pektsekye/Ymm/sql/ymm_setup/mysql4-install-0.1.0.php +1 -2
- app/design/adminhtml/default/default/template/ymm/importExport.phtml +38 -0
- app/design/frontend/default/default/template/ymm/ymm.phtml +23 -19
- package.xml +5 -6
app/code/local/Pektsekye/Adminhtml/Block/Page/Footer.php
DELETED
|
@@ -1,26 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
Written by pektsekye@gmail.com on Tuesday Jul 21 2009
|
| 4 |
-
version 1.0
|
| 5 |
-
*/
|
| 6 |
-
|
| 7 |
-
class Pektsekye_Adminhtml_Block_Page_Footer extends Mage_Adminhtml_Block_Page_Footer
|
| 8 |
-
{
|
| 9 |
-
|
| 10 |
-
/**
|
| 11 |
-
* Override Mage Adminhtml footer block
|
| 12 |
-
*/
|
| 13 |
-
public function getLanguageSelect()
|
| 14 |
-
{
|
| 15 |
-
$html = $this->getLayout()->createBlock('adminhtml/html_select')
|
| 16 |
-
->setName('locale')
|
| 17 |
-
->setId('interface_locale')
|
| 18 |
-
->setTitle(Mage::helper('page')->__('Interface Language'))
|
| 19 |
-
->setExtraParams('style="width:200px"')
|
| 20 |
-
->setValue(Mage::app()->getLocale()->getLocaleCode())
|
| 21 |
-
->setOptions(Mage::app()->getLocale()->getOptionLocales())
|
| 22 |
-
->getHtml();
|
| 23 |
-
return $html;
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Pektsekye/Adminhtml/etc/config.xml
DELETED
|
@@ -1,17 +0,0 @@
|
|
| 1 |
-
<?xml version="1.0"?>
|
| 2 |
-
<config>
|
| 3 |
-
<modules>
|
| 4 |
-
<Pektsekye_Adminhtml>
|
| 5 |
-
<version>0.1.0</version>
|
| 6 |
-
</Pektsekye_Adminhtml>
|
| 7 |
-
</modules>
|
| 8 |
-
<global>
|
| 9 |
-
<blocks>
|
| 10 |
-
<adminhtml>
|
| 11 |
-
<rewrite>
|
| 12 |
-
<page_footer>Pektsekye_Adminhtml_Block_Page_Footer</page_footer>
|
| 13 |
-
</rewrite>
|
| 14 |
-
</adminhtml>
|
| 15 |
-
</blocks>
|
| 16 |
-
</global>
|
| 17 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Edit.php
CHANGED
|
@@ -37,7 +37,7 @@ class Pektsekye_Ymm_Block_Adminhtml_Ymm_Edit extends Mage_Adminhtml_Block_Widget
|
|
| 37 |
public function getHeaderText()
|
| 38 |
{
|
| 39 |
if( Mage::registry('ymm_data') && Mage::registry('ymm_data')->getId() ) {
|
| 40 |
-
return Mage::helper('ymm')->__(
|
| 41 |
} else {
|
| 42 |
return Mage::helper('ymm')->__('Add Item');
|
| 43 |
}
|
| 37 |
public function getHeaderText()
|
| 38 |
{
|
| 39 |
if( Mage::registry('ymm_data') && Mage::registry('ymm_data')->getId() ) {
|
| 40 |
+
return Mage::helper('ymm')->__('Edit Item');
|
| 41 |
} else {
|
| 42 |
return Mage::helper('ymm')->__('Add Item');
|
| 43 |
}
|
app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Edit/Form.php
CHANGED
|
@@ -7,8 +7,7 @@ class Pektsekye_Ymm_Block_Adminhtml_Ymm_Edit_Form extends Mage_Adminhtml_Block_W
|
|
| 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 |
|
| 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 |
|
app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/Grid.php
CHANGED
|
@@ -4,8 +4,7 @@ class Pektsekye_Ymm_Block_Adminhtml_Ymm_Grid extends Mage_Adminhtml_Block_Widget
|
|
| 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');
|
|
@@ -21,12 +20,6 @@ class Pektsekye_Ymm_Block_Adminhtml_Ymm_Grid extends Mage_Adminhtml_Block_Widget
|
|
| 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'),
|
|
@@ -76,9 +69,7 @@ class Pektsekye_Ymm_Block_Adminhtml_Ymm_Grid extends Mage_Adminhtml_Block_Widget
|
|
| 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 |
}
|
|
@@ -92,24 +83,8 @@ class Pektsekye_Ymm_Block_Adminhtml_Ymm_Grid extends Mage_Adminhtml_Block_Widget
|
|
| 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 |
|
| 4 |
{
|
| 5 |
public function __construct()
|
| 6 |
{
|
| 7 |
+
parent::__construct();
|
|
|
|
| 8 |
$this->setId('ymmGrid');
|
| 9 |
$this->setDefaultSort('id');
|
| 10 |
$this->setDefaultDir('ASC');
|
| 20 |
|
| 21 |
protected function _prepareColumns()
|
| 22 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
$this->addColumn('products_id', array(
|
| 25 |
'header' => Mage::helper('ymm')->__('Products ID'),
|
| 69 |
'index' => 'stores',
|
| 70 |
'is_system' => true,
|
| 71 |
));
|
| 72 |
+
|
|
|
|
|
|
|
| 73 |
|
| 74 |
return parent::_prepareColumns();
|
| 75 |
}
|
| 83 |
'label' => Mage::helper('ymm')->__('Delete'),
|
| 84 |
'url' => $this->getUrl('*/*/massDelete'),
|
| 85 |
'confirm' => Mage::helper('ymm')->__('Are you sure?')
|
| 86 |
+
));
|
| 87 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
return $this;
|
| 89 |
}
|
| 90 |
|
app/code/local/Pektsekye/Ymm/Block/Adminhtml/Ymm/ImportExport.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Pektsekye_Ymm_Block_Adminhtml_Ymm_importExport extends Mage_Adminhtml_Block_Widget
|
| 4 |
+
{
|
| 5 |
+
public function __construct()
|
| 6 |
+
{
|
| 7 |
+
parent::__construct();
|
| 8 |
+
$this->setTemplate('ymm/importExport.phtml');
|
| 9 |
+
}
|
| 10 |
+
}
|
app/code/local/Pektsekye/Ymm/controllers/Adminhtml/YmmController.php
CHANGED
|
@@ -32,7 +32,6 @@ class Pektsekye_Ymm_Adminhtml_YmmController extends Mage_Adminhtml_Controller_ac
|
|
| 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 |
|
|
@@ -53,45 +52,17 @@ class Pektsekye_Ymm_Adminhtml_YmmController extends Mage_Adminhtml_Controller_ac
|
|
| 53 |
public function saveAction() {
|
| 54 |
if ($data = $this->getRequest()->getPost()) {
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 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'));
|
|
@@ -178,23 +149,6 @@ class Pektsekye_Ymm_Adminhtml_YmmController extends Mage_Adminhtml_Controller_ac
|
|
| 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 |
{
|
|
@@ -210,5 +164,130 @@ class Pektsekye_Ymm_Adminhtml_YmmController extends Mage_Adminhtml_Controller_ac
|
|
| 210 |
$response->setBody($content);
|
| 211 |
$response->sendResponse();
|
| 212 |
die;
|
| 213 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
}
|
| 32 |
$this->_setActiveMenu('ymm/items');
|
| 33 |
|
| 34 |
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
|
|
|
| 35 |
|
| 36 |
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
| 37 |
|
| 52 |
public function saveAction() {
|
| 53 |
if ($data = $this->getRequest()->getPost()) {
|
| 54 |
|
| 55 |
+
$data ['products_id'] = (int) $data ['products_id'];
|
| 56 |
+
$data ['products_car_make'] = trim(preg_replace('/[^\w\s-]/','',$data ['products_car_make']));
|
| 57 |
+
$data ['products_car_model'] = trim(preg_replace('/[^\w\s-]/','',$data ['products_car_model']));
|
| 58 |
+
$data ['products_car_year_bof'] = (int) $data ['products_car_year_bof'];
|
| 59 |
+
$data ['products_car_year_eof'] = (int) $data ['products_car_year_eof'];
|
| 60 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
$model = Mage::getModel('ymm/ymm');
|
| 62 |
$model->setData($data)
|
| 63 |
->setId($this->getRequest()->getParam('id'));
|
| 64 |
|
| 65 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
$model->save();
|
| 68 |
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('ymm')->__('Item was successfully saved'));
|
| 149 |
$this->_redirect('*/*/index');
|
| 150 |
}
|
| 151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
| 154 |
{
|
| 164 |
$response->setBody($content);
|
| 165 |
$response->sendResponse();
|
| 166 |
die;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
/**
|
| 171 |
+
* Import and export Page
|
| 172 |
+
*
|
| 173 |
+
*/
|
| 174 |
+
public function importExportAction()
|
| 175 |
+
{
|
| 176 |
+
$this->loadLayout()
|
| 177 |
+
->_setActiveMenu('ymm/import')
|
| 178 |
+
->_addContent($this->getLayout()->createBlock('ymm/adminhtml_ymm_importExport'))
|
| 179 |
+
->renderLayout();
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
/**
|
| 183 |
+
* import action from import/export ymm
|
| 184 |
+
*
|
| 185 |
+
*/
|
| 186 |
+
public function importPostAction()
|
| 187 |
+
{
|
| 188 |
+
if ($this->getRequest()->isPost() && !empty($_FILES['import_ymm_file']['tmp_name'])) {
|
| 189 |
+
try {
|
| 190 |
+
$number = $this->_importYmm();
|
| 191 |
+
|
| 192 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('ymm')->__('%d new item(s) were imported',$number));
|
| 193 |
+
}
|
| 194 |
+
catch (Mage_Core_Exception $e) {
|
| 195 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 196 |
+
}
|
| 197 |
+
catch (Exception $e) {
|
| 198 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ymm')->__('Invalid file upload attempt'));
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
else {
|
| 202 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ymm')->__('Invalid file upload attempt'));
|
| 203 |
+
}
|
| 204 |
+
$this->_redirect('*/*/importExport');
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
protected function _importYmm()
|
| 208 |
+
{
|
| 209 |
+
$fileName = $_FILES['import_ymm_file']['tmp_name'];
|
| 210 |
+
$csvObject = new Varien_File_Csv();
|
| 211 |
+
$csvData = $csvObject->getData($fileName);
|
| 212 |
+
$number = 0;
|
| 213 |
+
/** checks columns */
|
| 214 |
+
$csvFields = array(
|
| 215 |
+
0 => Mage::helper('ymm')->__('Products ID'),
|
| 216 |
+
1 => Mage::helper('ymm')->__('Vehicle Make'),
|
| 217 |
+
2 => Mage::helper('ymm')->__('Vehicle Model'),
|
| 218 |
+
3 => Mage::helper('ymm')->__('From Year'),
|
| 219 |
+
4 => Mage::helper('ymm')->__('To Year')
|
| 220 |
+
);
|
| 221 |
+
|
| 222 |
+
if ($csvData[0] == $csvFields) {
|
| 223 |
+
foreach ($csvData as $k => $v) {
|
| 224 |
+
if ($k == 0) {
|
| 225 |
+
continue;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
//end of file has more then one empty lines
|
| 229 |
+
if (count($v) <= 1 && !strlen($v[0])) {
|
| 230 |
+
continue;
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
if (count($csvFields) != count($v)) {
|
| 234 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ymm')->__('Invalid file upload attempt'));
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
if (!empty($v[0]) && is_numeric($v[0]) && !empty($v[1])) {
|
| 238 |
+
|
| 239 |
+
$v[1] = trim(preg_replace('/[^\w\s-]/','',$v[1]));
|
| 240 |
+
$v[2] = trim(preg_replace('/[^\w\s-]/','',$v[2]));
|
| 241 |
+
|
| 242 |
+
$resource = Mage::getSingleton('core/resource');
|
| 243 |
+
$read= $resource->getConnection('core_read');
|
| 244 |
+
$ymmTable = $resource->getTableName('ymm');
|
| 245 |
+
$select = $read->select()
|
| 246 |
+
->from($ymmTable,array('id'))
|
| 247 |
+
->where("products_id=?",(int)$v[0])
|
| 248 |
+
->where("products_car_make=?",$v[1])
|
| 249 |
+
->where("products_car_model=?",$v[2])
|
| 250 |
+
->where("products_car_year_bof=?",(int)$v[3])
|
| 251 |
+
->where("products_car_year_eof=?",(int)$v[4])
|
| 252 |
+
->limit(1);
|
| 253 |
+
|
| 254 |
+
if($read->fetchOne($select)){
|
| 255 |
+
continue;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
$data = array(
|
| 259 |
+
'products_id'=>$v[0],
|
| 260 |
+
'products_car_make' => $v[1],
|
| 261 |
+
'products_car_model' => $v[2],
|
| 262 |
+
'products_car_year_bof' => $v[3],
|
| 263 |
+
'products_car_year_eof'=>$v[4],
|
| 264 |
+
);
|
| 265 |
+
|
| 266 |
+
$model = Mage::getModel('ymm/ymm');
|
| 267 |
+
$model->setData($data);
|
| 268 |
+
$model->save();
|
| 269 |
+
$number++;
|
| 270 |
+
}
|
| 271 |
+
}
|
| 272 |
+
}
|
| 273 |
+
else {
|
| 274 |
+
Mage::throwException(Mage::helper('tax')->__('Invalid file format upload attempt'));
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
return $number;
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
/**
|
| 281 |
+
* export action from import/export tax
|
| 282 |
+
*
|
| 283 |
+
*/
|
| 284 |
+
public function exportPostAction()
|
| 285 |
+
{
|
| 286 |
+
$fileName = 'ymm.csv';
|
| 287 |
+
$content = $this->getLayout()->createBlock('ymm/adminhtml_ymm_grid')
|
| 288 |
+
->getCsv();
|
| 289 |
+
|
| 290 |
+
$this->_sendUploadResponse($fileName, $content);
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
}
|
app/code/local/Pektsekye/Ymm/etc/config.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<Pektsekye_Ymm>
|
| 5 |
-
<version>0.
|
| 6 |
</Pektsekye_Ymm>
|
| 7 |
</modules>
|
| 8 |
<frontend>
|
|
@@ -44,7 +44,12 @@
|
|
| 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>
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<Pektsekye_Ymm>
|
| 5 |
+
<version>0.2.0</version>
|
| 6 |
</Pektsekye_Ymm>
|
| 7 |
</modules>
|
| 8 |
<frontend>
|
| 44 |
<title>Manage Items</title>
|
| 45 |
<sort_order>0</sort_order>
|
| 46 |
<action>ymm/adminhtml_ymm</action>
|
| 47 |
+
</items>
|
| 48 |
+
<import module="ymm">
|
| 49 |
+
<title>Import / Export</title>
|
| 50 |
+
<sort_order>1</sort_order>
|
| 51 |
+
<action>ymm/adminhtml_ymm/importExport</action>
|
| 52 |
+
</import>
|
| 53 |
</children>
|
| 54 |
</ymm>
|
| 55 |
</menu>
|
app/code/local/Pektsekye/Ymm/sql/ymm_setup/mysql4-install-0.1.0.php
CHANGED
|
@@ -4,8 +4,7 @@ $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 ,
|
| 4 |
|
| 5 |
$installer->startSetup();
|
| 6 |
|
| 7 |
+
$installer->run("
|
|
|
|
| 8 |
DROP TABLE IF EXISTS {$this->getTable('ymm')};
|
| 9 |
CREATE TABLE {$this->getTable('ymm')} (
|
| 10 |
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
app/design/adminhtml/default/default/template/ymm/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('ymm')->__('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('ymm')->__('Import YMM items') ?></h4>
|
| 14 |
+
</div>
|
| 15 |
+
<fieldset>
|
| 16 |
+
<legend><?php echo Mage::helper('ymm')->__('Import YMM items') ?></legend>
|
| 17 |
+
<input type="file" name="import_ymm_file" class="input-file required-entry"/>
|
| 18 |
+
<?php echo $this->getButtonHtml('Import YMM 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('ymm')->__('Export YMM items') ?></h4>
|
| 30 |
+
</div>
|
| 31 |
+
<fieldset>
|
| 32 |
+
<legend><?php echo Mage::helper('ymm')->__('Export YMM items') ?></legend>
|
| 33 |
+
<?php echo $this->getButtonHtml('Export YMM items', "this.form.submit()") ?>
|
| 34 |
+
</fieldset>
|
| 35 |
+
</form>
|
| 36 |
+
</div>
|
| 37 |
+
<div class="clear"></div>
|
| 38 |
+
</div>
|
app/design/frontend/default/default/template/ymm/ymm.phtml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
<?php
|
| 2 |
/*
|
| 3 |
-
Written by pektsekye@gmail.com on
|
| 4 |
version 1.0
|
| 5 |
*/
|
| 6 |
|
|
@@ -32,36 +32,40 @@ var c = new Array();';
|
|
| 32 |
|
| 33 |
$y = array();
|
| 34 |
$M_a = array();
|
| 35 |
-
$
|
| 36 |
-
$
|
| 37 |
|
| 38 |
foreach ($rows as $Makes) {
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
$M_a [$products_car_make_old][$products_car_model_old]=$y;
|
| 46 |
$y = array();
|
| 47 |
}
|
| 48 |
|
| 49 |
-
if ($
|
| 50 |
-
if ($
|
| 51 |
-
$y [$
|
| 52 |
-
} elseif ($
|
| 53 |
-
while ($
|
| 54 |
-
$y [$
|
| 55 |
-
$
|
| 56 |
}
|
| 57 |
}
|
| 58 |
}
|
| 59 |
-
$
|
| 60 |
-
$
|
| 61 |
-
$M_a [$
|
| 62 |
}
|
| 63 |
|
| 64 |
-
$M_a [$
|
| 65 |
|
| 66 |
|
| 67 |
|
| 1 |
<?php
|
| 2 |
/*
|
| 3 |
+
Written by pektsekye@gmail.com on Friday Jul 24 2009
|
| 4 |
version 1.0
|
| 5 |
*/
|
| 6 |
|
| 32 |
|
| 33 |
$y = array();
|
| 34 |
$M_a = array();
|
| 35 |
+
$make_old = '';
|
| 36 |
+
$model_old = '';
|
| 37 |
|
| 38 |
foreach ($rows as $Makes) {
|
| 39 |
|
| 40 |
+
$make = $Makes['products_car_make'];
|
| 41 |
+
$model = $Makes['products_car_model'];
|
| 42 |
+
$year_bof = $Makes['products_car_year_bof'];
|
| 43 |
+
$year_eof = $Makes['products_car_year_eof'];
|
| 44 |
+
|
| 45 |
+
if (!isset($M_a [$make]))
|
| 46 |
+
$Make_array[] = array('id' => $make, 'text' => $make);
|
| 47 |
|
| 48 |
+
if (!isset($M_a [$make][$model]) && count($y) > 0){
|
| 49 |
+
$M_a [$make_old][$model_old]=$y;
|
|
|
|
| 50 |
$y = array();
|
| 51 |
}
|
| 52 |
|
| 53 |
+
if ($year_bof != 0 && $year_eof != 0){
|
| 54 |
+
if ($year_bof == $year_eof){
|
| 55 |
+
$y [$year_bof] = 1;
|
| 56 |
+
} elseif ($year_bof < $year_eof){
|
| 57 |
+
while ($year_bof <= $year_eof){
|
| 58 |
+
$y [$year_bof] = 1;
|
| 59 |
+
$year_bof++;
|
| 60 |
}
|
| 61 |
}
|
| 62 |
}
|
| 63 |
+
$make_old = $make;
|
| 64 |
+
$model_old = $model;
|
| 65 |
+
$M_a [$make][$model] = array();
|
| 66 |
}
|
| 67 |
|
| 68 |
+
$M_a [$make_old][$model_old]=$y;
|
| 69 |
|
| 70 |
|
| 71 |
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Year_Make_Model_Filter_Box</name>
|
| 4 |
-
<version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -12,7 +12,6 @@
|
|
| 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.
|
|
@@ -23,11 +22,11 @@ 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>
|
| 27 |
<authors><author><name>Stanislav</name><user>auto-converted</user><email>pektsekye@gmail.com</email></author></authors>
|
| 28 |
-
<date>2009-07-
|
| 29 |
-
<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="
|
| 31 |
<compatible/>
|
| 32 |
<dependencies/>
|
| 33 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Year_Make_Model_Filter_Box</name>
|
| 4 |
+
<version>2.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>
|
| 12 |
HOW TO USE:
|
| 13 |
Go to your Magento admin panel -> Ymm -> Manage Items and add YMM items to all your products.
|
| 14 |
|
|
|
|
| 15 |
|
| 16 |
NOTE: The products without model/make/year/ set are treated as for all models, all years, all makes.
|
| 17 |
If you want to select BMW and see only BMW products all the other products should be set to another car.
|
| 22 |
You can find product id in the product description page url:
|
| 23 |
http://yoursite.com/magento/catalog/product/view/id/119/s/coalesce-functioning-on-impatience-t-shirt/category/4/
|
| 24 |
The number 119 is the product id in the url.</description>
|
| 25 |
+
<notes>Import feature was added</notes>
|
| 26 |
<authors><author><name>Stanislav</name><user>auto-converted</user><email>pektsekye@gmail.com</email></author></authors>
|
| 27 |
+
<date>2009-07-24</date>
|
| 28 |
+
<time>02:30:33</time>
|
| 29 |
+
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="ymm.xml" hash="07bb5759f6ff145da493c94452f029af"/></dir><dir name="template"><dir name="ymm"><file name="importExport.phtml" hash="962cd5005434dfb5878b59af757f796e"/></dir></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="fa5b0beff2dbf244f077385019f1bdd8"/></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="c673af9d5e772ee2230a838971a633e1"/><file name="Tabs.php" hash="9048cfd443135e36e2b9cb5de38fcb47"/></dir><file name="Edit.php" hash="fb03b2d7cc9d282221af18c6ce9f6f9f"/><file name="Grid.php" hash="57d72d01ed8140f55b2490a8b08b8409"/><file name="ImportExport.php" hash="e1b161394a704c51c454ead1ca04e6cd"/></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="bef44e8dc00bfd6e0cf20bbfaf4f3fad"/></dir><file name="IndexController.php" hash="241a989b18c6309977568c050215730a"/></dir><dir name="etc"><file name="config.xml" hash="8290182a510c6e471fe0396a61419283"/></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="9e4d9d55d8996105775b26c667eff6d1"/></dir></dir></dir></dir></target></contents>
|
| 30 |
<compatible/>
|
| 31 |
<dependencies/>
|
| 32 |
</package>
|
