megabile - Version 0.0.1

Version Notes

initial release. Post all issues or bugs at magazento.com/ticket

Download this release

Release Info

Developer volgodark
Extension megabile
Version 0.0.1
Comparing to
See all releases


Version 0.0.1

Files changed (27) hide show
  1. app/code/community/Magazento/Megabile/Block/Admin/Item.php +23 -0
  2. app/code/community/Magazento/Megabile/Block/Admin/Item/Edit.php +58 -0
  3. app/code/community/Magazento/Megabile/Block/Admin/Item/Edit/Form.php +32 -0
  4. app/code/community/Magazento/Megabile/Block/Admin/Item/Edit/Tab/Form.php +97 -0
  5. app/code/community/Magazento/Megabile/Block/Admin/Item/Edit/Tab/Related.php +149 -0
  6. app/code/community/Magazento/Megabile/Block/Admin/Item/Edit/Tabs.php +47 -0
  7. app/code/community/Magazento/Megabile/Block/Admin/Item/Grid.php +125 -0
  8. app/code/community/Magazento/Megabile/Block/Admin/Item/Grid/Renderer/Action.php +43 -0
  9. app/code/community/Magazento/Megabile/Block/Admin/Item/Grid/Renderer/Category.php +43 -0
  10. app/code/community/Magazento/Megabile/Block/Admin/Item/Grid/Renderer/Link.php +47 -0
  11. app/code/community/Magazento/Megabile/Block/Admin/Item/Grid/Renderer/Products.php +50 -0
  12. app/code/community/Magazento/Megabile/Block/Admin/Item/Grid/Renderer/Time.php +50 -0
  13. app/code/community/Magazento/Megabile/Helper/Data.php +21 -0
  14. app/code/community/Magazento/Megabile/Helper/Product.php +13 -0
  15. app/code/community/Magazento/Megabile/Model/Data.php +99 -0
  16. app/code/community/Magazento/Megabile/Model/Item.php +153 -0
  17. app/code/community/Magazento/Megabile/Model/Mysql4/Item.php +30 -0
  18. app/code/community/Magazento/Megabile/Model/Mysql4/Item/Collection.php +27 -0
  19. app/code/community/Magazento/Megabile/controllers/Admin/CatalogController.php +46 -0
  20. app/code/community/Magazento/Megabile/controllers/Admin/ItemController.php +173 -0
  21. app/code/community/Magazento/Megabile/etc/config.xml +124 -0
  22. app/code/community/Magazento/Megabile/etc/system.xml +45 -0
  23. app/code/community/Magazento/Megabile/sql/megabile_setup/mysql4-install-0.0.1.php +39 -0
  24. app/design/adminhtml/default/default/template/magazento_megabile/cattree.phtml +128 -0
  25. app/etc/modules/Magazento_Megabile.xml +9 -0
  26. package.xml +19 -0
  27. skin/adminhtml/default/default/magazento_megabile/style.css +1 -0
app/code/community/Magazento/Megabile/Block/Admin/Item.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on April 4, 2012
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com - ecommerceoffice.com
5
+ * Copyright Proskuryakov Ivan. ecommerceoffice.com © 2011. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php
10
+
11
+ class Magazento_Megabile_Block_Admin_Item extends Mage_Adminhtml_Block_Widget_Grid_Container
12
+ {
13
+
14
+ public function __construct()
15
+ {
16
+ $this->_controller = 'admin_item';
17
+ $this->_blockGroup = 'megabile';
18
+ $this->_headerText = Mage::helper('megabile')->__('Megabile Export Tool');
19
+ $this->_addButtonLabel = Mage::helper('megabile')->__('Add Profile');
20
+ parent::__construct();
21
+ }
22
+
23
+ }
app/code/community/Magazento/Megabile/Block/Admin/Item/Edit.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Aug 16, 2011
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com
5
+ * Copyright Proskuryakov Ivan. Magazento.com © 2011. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php
10
+
11
+ class Magazento_Megabile_Block_Admin_Item_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
12
+ {
13
+
14
+ public function __construct()
15
+ {
16
+ $this->_objectId = 'item_id';
17
+ $this->_controller = 'admin_item';
18
+ $this->_blockGroup = 'megabile';
19
+
20
+ parent::__construct();
21
+
22
+ $this->_updateButton('save', 'label', Mage::helper('megabile')->__('Save Item'));
23
+ $this->_updateButton('delete', 'label', Mage::helper('megabile')->__('Delete Item'));
24
+
25
+ $this->_addButton('saveandcontinue', array(
26
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
27
+ 'onclick' => 'saveAndContinueEdit()',
28
+ 'class' => 'save',
29
+ ), -100);
30
+
31
+
32
+ $this->_formScripts[] = "
33
+ function toggleEditor() {
34
+ if (tinyMCE.getInstanceById('block_content') == null) {
35
+ tinyMCE.execCommand('mceAddControl', false, 'block_content');
36
+ } else {
37
+ tinyMCE.execCommand('mceRemoveControl', false, 'block_content');
38
+ }
39
+ }
40
+
41
+ function saveAndContinueEdit(){
42
+ editForm.submit($('edit_form').action+'back/edit/');
43
+ }
44
+
45
+ ";
46
+ }
47
+
48
+ public function getHeaderText()
49
+ {
50
+ if (Mage::registry('megabile_item')->getId()) {
51
+ return Mage::helper('megabile')->__("Edit #%s", $this->htmlEscape(Mage::registry('megabile_item')->getId()));
52
+ }
53
+ else {
54
+ return Mage::helper('megabile')->__('New');
55
+ }
56
+ }
57
+
58
+ }
app/code/community/Magazento/Megabile/Block/Admin/Item/Edit/Form.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Aug 16, 2011
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com
5
+ * Copyright Proskuryakov Ivan. Magazento.com © 2011. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php
10
+
11
+ class Magazento_Megabile_Block_Admin_Item_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
12
+ {
13
+
14
+
15
+ protected function _prepareForm()
16
+ {
17
+ $form = new Varien_Data_Form(array(
18
+ 'id' => 'edit_form',
19
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
20
+ 'method' => 'post',
21
+ 'enctype' => 'multipart/form-data'
22
+ )
23
+ );
24
+
25
+ $form->setUseContainer(true);
26
+ $this->setForm($form);
27
+ return parent::_prepareForm();
28
+ }
29
+
30
+
31
+
32
+ }
app/code/community/Magazento/Megabile/Block/Admin/Item/Edit/Tab/Form.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Aug 16, 2011
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com
5
+ * Copyright Proskuryakov Ivan. Magazento.com © 2011. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php
10
+
11
+ class Magazento_Megabile_Block_Admin_Item_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
12
+
13
+
14
+ protected function _prepareForm() {
15
+ $model = Mage::registry('megabile_item');
16
+ $form = new Varien_Data_Form(array('id' => 'edit_form_item', 'action' => $this->getData('action'), 'method' => 'post'));
17
+ $form->setHtmlIdPrefix('item_');
18
+ $fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('megabile')->__('General'), 'class' => 'fieldset-wide'));
19
+ if ($model->getItemId()) {
20
+ $fieldset->addField('item_id', 'hidden', array(
21
+ 'name' => 'item_id',
22
+ ));
23
+ }
24
+
25
+
26
+ $fieldset->addField('filename', 'text', array(
27
+ 'label' => Mage::helper('megabile')->__('Filename'),
28
+ 'note' => Mage::helper('pdfproduct')->__('example: megabile_general.xml'),
29
+ 'name' => 'filename',
30
+ 'required' => true,
31
+ ));
32
+
33
+ $fieldset->addField('root_category', 'select', array(
34
+ 'label' => Mage::helper('megabile')->__('Root Category'),
35
+ 'name' => 'root_category',
36
+ 'required' => true,
37
+ 'values' => Mage::getModel('megabile/data')->storeCategories4Form(),
38
+ 'style' => 'width:100%',
39
+ ));
40
+
41
+ $fieldset->addField('products_for_export', 'select', array(
42
+ 'label' => Mage::helper('megabile')->__('Products For Export'),
43
+ 'name' => 'products_for_export',
44
+ 'required' => true,
45
+ 'options' => array(
46
+ '0' => Mage::helper('megabile')->__('All Produdcts'),
47
+ '1' => Mage::helper('megabile')->__('Only Selected'),
48
+ ),
49
+ 'note' => Mage::helper('pdfproduct')->__('If "only selected" you will need to select products'),
50
+ ));
51
+
52
+ $fieldset->addField('use_attributes', 'select', array(
53
+ 'label' => Mage::helper('megabile')->__('Use attributes'),
54
+ 'name' => 'use_attributes',
55
+ 'required' => true,
56
+ 'options' => array(
57
+ '0' => Mage::helper('megabile')->__('Disabled'),
58
+ '1' => Mage::helper('megabile')->__('Enabled'),
59
+ ),
60
+ ));
61
+
62
+ $fieldset->addField('product_attributes', 'multiselect', array(
63
+ 'label' => Mage::helper('megabile')->__('Extra attributes'),
64
+ 'note' => Mage::helper('pdfproduct')->__('We will put them in the bottom of product description'),
65
+ 'name' => 'product_attributes',
66
+ 'values' => Mage::getModel('megabile/data')->storeAttributes4Form(),
67
+ 'required' => false,
68
+ 'style' => 'height:250px',
69
+ ));
70
+
71
+
72
+ if (!Mage::app()->isSingleStoreMode()) {
73
+ $fieldset->addField('store_id', 'select', array(
74
+ 'label' => Mage::helper('megabile')->__('Store View'),
75
+ 'title' => Mage::helper('megabile')->__('Store View'),
76
+ 'name' => 'store_id',
77
+ 'required' => true,
78
+ 'value' => $model->getStoreId(),
79
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm()
80
+ ));
81
+ }
82
+ else {
83
+ $fieldset->addField('store_id', 'hidden', array(
84
+ 'name' => 'store_id',
85
+ 'value' => Mage::app()->getStore(true)->getId()
86
+ ));
87
+ $model->setStoreId(Mage::app()->getStore(true)->getId());
88
+ }
89
+
90
+
91
+ $form->setValues($model->getData());
92
+ $this->setForm($form);
93
+
94
+ return parent::_prepareForm();
95
+ }
96
+
97
+ }
app/code/community/Magazento/Megabile/Block/Admin/Item/Edit/Tab/Related.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Dec 6, 2012
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com - Magazento.com
5
+ * Copyright Proskuryakov Ivan. Magazento.com © 2012. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php
10
+ class Magazento_Megabile_Block_Admin_Item_Edit_Tab_Related extends Mage_Adminhtml_Block_Widget_Grid {
11
+
12
+ public function __construct() {
13
+
14
+ parent::__construct();
15
+ $this->setId('related');
16
+ $this->setDefaultSort('entity_id');
17
+ $this->setDefaultDir('ASC');
18
+ $this->setSaveParametersInSession(true);
19
+ $this->setUseAjax(true);
20
+ }
21
+
22
+ protected function _prepareCollection() {
23
+ $collection = Mage::getModel('catalog/product')->getCollection()
24
+ ->addAttributeToSelect('sku')
25
+ ->addAttributeToSelect('name')
26
+ ->addAttributeToSelect('price')
27
+ ->addAttributeToSelect('attribute_set_id')
28
+ ->addAttributeToSelect('type_id')
29
+ ->addAttributeToSelect('status');
30
+ $this->setCollection($collection);
31
+
32
+ return parent::_prepareCollection();
33
+ }
34
+ protected function _getStore()
35
+ {
36
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
37
+ return Mage::app()->getStore($storeId);
38
+ }
39
+ protected function _prepareColumns() {
40
+ $this->addColumn('in_products', array(
41
+ 'header_css_class' => 'a-center',
42
+ 'type' => 'checkbox',
43
+ 'field_name'=> 'related_prodlist[]',
44
+ 'values' => $this->_getSelectedProducts(),
45
+ 'align' => 'center',
46
+ 'index' => 'entity_id'
47
+ ));
48
+ $this->addColumn('entity_id', array(
49
+ 'header' => Mage::helper('catalog')->__('ID'),
50
+ 'width' => '50px',
51
+ 'type' => 'number',
52
+ 'index' => 'entity_id',
53
+ ));
54
+ $this->addColumn('name', array(
55
+ 'header' => Mage::helper('catalog')->__('Name'),
56
+ 'index' => 'name',
57
+ ));
58
+ $store = $this->_getStore();
59
+ if ($store->getId()) {
60
+ $this->addColumn('custom_name', array(
61
+ 'header' => Mage::helper('catalog')->__('Name in %s', $store->getName()),
62
+ 'index' => 'custom_name',
63
+ ));
64
+ }
65
+
66
+ $this->addColumn('type', array(
67
+ 'header' => Mage::helper('catalog')->__('Type'),
68
+ 'width' => '60px',
69
+ 'index' => 'type_id',
70
+ 'type' => 'options',
71
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
72
+ ));
73
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
74
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
75
+ ->load()
76
+ ->toOptionHash();
77
+
78
+ $this->addColumn('set_name', array(
79
+ 'header' => Mage::helper('catalog')->__('Attrib. Set Name'),
80
+ 'width' => 130,
81
+ 'index' => 'attribute_set_id',
82
+ 'type' => 'options',
83
+ 'options' => $sets,
84
+ ));
85
+ $this->addColumn('sku', array(
86
+ 'header' => Mage::helper('catalog')->__('SKU'),
87
+ 'width' => '80px',
88
+ 'index' => 'sku',
89
+ ));
90
+ $store = $this->_getStore();
91
+ $this->addColumn('price', array(
92
+ 'header' => Mage::helper('catalog')->__('Price'),
93
+ 'type' => 'price',
94
+ 'currency_code' => $store->getBaseCurrency()->getCode(),
95
+ 'index' => 'price',
96
+ ));
97
+ $this->addColumn('mstatus', array(
98
+ 'header' => Mage::helper('catalog')->__('Status'),
99
+ 'width' => '70px',
100
+ 'index' => 'status',
101
+ 'type' => 'options',
102
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
103
+ ));
104
+ return parent::_prepareColumns();
105
+ }
106
+
107
+ public function getGridUrl()
108
+ {
109
+ return $this->getData('grid_url')
110
+ ? $this->getData('grid_url')
111
+ : $this->getUrl('*/*/relatedGrid', array('_current' => true));
112
+ }
113
+
114
+
115
+ protected function _addColumnFilterToCollection($column)
116
+ {
117
+ if ($column->getId() == 'in_products') {
118
+ $productIds = $this->_getSelectedProducts();
119
+ if (empty($productIds)) {
120
+ $productIds = 0;
121
+ }
122
+ if ($column->getFilter()->getValue()) {
123
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
124
+ } else {
125
+ if($productIds) {
126
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
127
+ }
128
+ }
129
+ } else {
130
+ parent::_addColumnFilterToCollection($column);
131
+ }
132
+ return $this;
133
+ }
134
+
135
+ protected function _getSelectedProducts()
136
+ {
137
+ $products = $this->getRequest()->getPost('products', null);
138
+
139
+ if (!is_array($products)) {
140
+ $id = Mage::app()->getFrontController()->getRequest()->get('item_id');
141
+ $model = Mage::getModel('megabile/item')->load($id);
142
+ $products = explode(",",$model->getData('products'));
143
+ }
144
+ return $products;
145
+ }
146
+
147
+ }
148
+
149
+ ?>
app/code/community/Magazento/Megabile/Block/Admin/Item/Edit/Tabs.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Aug 16, 2011
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com
5
+ * Copyright Proskuryakov Ivan. Magazento.com © 2011. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php
10
+
11
+ class Magazento_Megabile_Block_Admin_Item_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
12
+
13
+ public function __construct() {
14
+ parent::__construct();
15
+ $this->setId('megabile_tabs');
16
+ $this->setDestElementId('edit_form');
17
+ $this->setTitle(Mage::helper('megabile')->__('Megabile Export'));
18
+ }
19
+
20
+ protected function _prepareLayout()
21
+ {
22
+ parent::_prepareLayout();
23
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
24
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
25
+ }
26
+ }
27
+
28
+ protected function _beforeToHtml() {
29
+ $this->addTab('form_section_item', array(
30
+ 'label' => Mage::helper('megabile')->__('General information'),
31
+ 'title' => Mage::helper('megabile')->__('General information'),
32
+ 'content' => $this->getLayout()->createBlock('megabile/admin_item_edit_tab_form')->toHtml(),
33
+ ));
34
+
35
+ $this->addTab('related', array(
36
+ 'label' => Mage::helper('catalog')->__('Products'),
37
+ 'url' => $this->getUrl('*/*/related', array('_current' => true)),
38
+ 'class' => 'ajax',
39
+ ));
40
+
41
+ return parent::_beforeToHtml();
42
+ }
43
+
44
+
45
+
46
+
47
+ }
app/code/community/Magazento/Megabile/Block/Admin/Item/Grid.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Items grid
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ */
34
+ class Magazento_Megabile_Block_Admin_Item_Grid extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+
37
+ public function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setId('itemGrid');
41
+ $this->setDefaultSort('item_id');
42
+
43
+ }
44
+
45
+ protected function _prepareCollection()
46
+ {
47
+ $collection = Mage::getModel('megabile/item')->getCollection();
48
+ /* @var $collection Mage_Item_Model_Mysql4_Item_Collection */
49
+ $this->setCollection($collection);
50
+ return parent::_prepareCollection();
51
+ }
52
+
53
+ protected function _prepareColumns()
54
+ {
55
+ $this->addColumn('item_id', array(
56
+ 'header' => Mage::helper('megabile')->__('ID'),
57
+ 'width' => '50px',
58
+ 'index' => 'item_id'
59
+ ));
60
+
61
+ $this->addColumn('link', array(
62
+ 'header' => Mage::helper('megabile')->__('Files & Links'),
63
+ 'renderer' => 'megabile/admin_item_grid_renderer_link',
64
+ ));
65
+
66
+ $this->addColumn('root_category', array(
67
+ 'header' => Mage::helper('megabile')->__('Root Category'),
68
+ 'renderer' => 'megabile/admin_item_grid_renderer_category',
69
+ ));
70
+
71
+ $this->addColumn('products', array(
72
+ 'header' => Mage::helper('megabile')->__('Products'),
73
+ 'renderer' => 'megabile/admin_item_grid_renderer_products',
74
+ ));
75
+
76
+ $this->addColumn('from_time', array(
77
+ 'header' => Mage::helper('megabile')->__('Time Created'),
78
+ 'width' => '150px',
79
+ 'index' => 'from_time',
80
+ 'type' => 'datetime',
81
+ ));
82
+
83
+ if (!Mage::app()->isSingleStoreMode()) {
84
+ $this->addColumn('store_id', array(
85
+ 'header' => Mage::helper('megabile')->__('Store View'),
86
+ 'index' => 'store_id',
87
+ 'type' => 'store',
88
+ 'width' => '150px',
89
+ ));
90
+ }
91
+
92
+ $this->addColumn('action', array(
93
+ 'header' => Mage::helper('megabile')->__('Action'),
94
+ 'filter' => false,
95
+ 'sortable' => false,
96
+ 'width' => '200px',
97
+ 'renderer' => 'megabile/admin_item_grid_renderer_action'
98
+ ));
99
+
100
+ return parent::_prepareColumns();
101
+ }
102
+
103
+ /**
104
+ * Row click url
105
+ *
106
+ * @return string
107
+ */
108
+ // public function getRowUrl($row)
109
+ // {
110
+ // return $this->getUrl('*/*/edit', array('item_id' => $row->getId()));
111
+ // }
112
+
113
+
114
+ protected function _afterLoadCollection() {
115
+ $this->getCollection()->walk('afterLoad');
116
+ parent::_afterLoadCollection();
117
+ }
118
+
119
+ protected function _filterStoreCondition($collection, $column) {
120
+ if (!$value = $column->getFilter()->getValue()) {
121
+ return;
122
+ }
123
+ $this->getCollection()->addStoreFilter($value);
124
+ }
125
+ }
app/code/community/Magazento/Megabile/Block/Admin/Item/Grid/Renderer/Action.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Sitemap grid action column renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Sitemap
32
+ */
33
+ class Magazento_Megabile_Block_Admin_Item_Grid_Renderer_Action extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
34
+ {
35
+ public function render(Varien_Object $row)
36
+ {
37
+
38
+ $edit_link = '<a href="'.$this->getUrl('*/*/edit', array('item_id' => $row->getId())).'">'.Mage::helper('megabile')->__('Edit').'</a>';
39
+ $generate_link = '<a href="'.$this->getUrl('*/admin_catalog/save', array('id' => $row->getId())).'">'.Mage::helper('megabile')->__('Generate XML').'</a>';
40
+
41
+ return $edit_link.' | '.$generate_link;
42
+ }
43
+ }
app/code/community/Magazento/Megabile/Block/Admin/Item/Grid/Renderer/Category.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Sitemap grid action column renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Sitemap
32
+ */
33
+ class Magazento_Megabile_Block_Admin_Item_Grid_Renderer_Category extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
34
+ {
35
+
36
+ public function render(Varien_Object $row)
37
+ {
38
+ $category_id = $row->getData('root_category');
39
+ $store_id = $row->getData('store_id');
40
+ $category = Mage::getModel('catalog/category') ->setStoreId($store_id) ->load($category_id);
41
+ return $category->getName();
42
+ }
43
+ }
app/code/community/Magazento/Megabile/Block/Admin/Item/Grid/Renderer/Link.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Sitemap grid action column renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Sitemap
32
+ */
33
+ class Magazento_Megabile_Block_Admin_Item_Grid_Renderer_Link extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
34
+ {
35
+
36
+
37
+ public function render(Varien_Object $row)
38
+ {
39
+ $fileName = $row->getFilename();
40
+ $url = $this->htmlEscape(Mage::app()->getStore($row->getStoreId())->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . $fileName);
41
+
42
+ if (file_exists(BP . DS . $fileName)) {
43
+ return sprintf('<a target="_blank" href="%1$s">%1$s</a>', $url).'<br/>'.BP . DS . $fileName;
44
+ }
45
+ return $url;
46
+ }
47
+ }
app/code/community/Magazento/Megabile/Block/Admin/Item/Grid/Renderer/Products.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Sitemap grid action column renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Sitemap
32
+ */
33
+ class Magazento_Megabile_Block_Admin_Item_Grid_Renderer_Products extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
34
+ {
35
+
36
+ public function render(Varien_Object $row)
37
+ {
38
+ $count = "0";
39
+ if ($row->getData('products_for_export')) {
40
+ if ($row->getData('products')) {
41
+ $productsArray = explode(",",$row->getData('products'));
42
+ $count = count($productsArray);
43
+ }
44
+ } else {
45
+ $count = Mage::getModel('megabile/data')->getStoreProductsCount($row->getData('store_id'));
46
+ }
47
+
48
+ return $count;
49
+ }
50
+ }
app/code/community/Magazento/Megabile/Block/Admin/Item/Grid/Renderer/Time.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Item grid link column renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Item
32
+ */
33
+ class Magazento_Megabile_Block_Admin_Item_Grid_Renderer_Time extends Mage_Adminhtml_Widget_Grid_Column_Renderer_Abstract
34
+ {
35
+
36
+ /**
37
+ * Prepare link to display in grid
38
+ *
39
+ * @param Varien_Object $row
40
+ * @return string
41
+ */
42
+ public function render(Varien_Object $row)
43
+ {
44
+ $time = date('Y-m-d H:i:s', strtotime($row->getTime()) + Mage::getSingleton('core/date')->getGmtOffset());
45
+
46
+ return $time;
47
+ }
48
+
49
+ }
50
+
app/code/community/Magazento/Megabile/Helper/Data.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Aug 16, 2011
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com
5
+ * Copyright Proskuryakov Ivan. Magazento.com © 2011. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php class Magazento_Megabile_Helper_Data extends Mage_Core_Helper_Abstract {
10
+
11
+ public function versionUseAdminTitle() {
12
+ $info = explode('.', Mage::getVersion());
13
+ if ($info[0] > 1) {
14
+ return true;
15
+ }
16
+ if ($info[1] > 3) {
17
+ return true;
18
+ }
19
+ return false;
20
+ }
21
+ }
app/code/community/Magazento/Megabile/Helper/Product.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Aug 16, 2011
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com
5
+ * Copyright Proskuryakov Ivan. Magazento.com © 2011. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php class Magazento_Megabile_Helper_Product extends Mage_Core_Helper_Abstract {
10
+
11
+
12
+
13
+ }
app/code/community/Magazento/Megabile/Model/Data.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Created on Mar 16, 2011
5
+ * Author Ivan Proskuryakov - volgodark@gmail.com - Magazento.com
6
+ * Copyright Proskuryakov Ivan. Magazento.com © 2011. All Rights Reserved.
7
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
8
+ */
9
+ ?>
10
+ <?php
11
+
12
+ class Magazento_Megabile_Model_Data {
13
+
14
+ public function storeCategories4Form() {
15
+
16
+
17
+ $collection = Mage::getModel('catalog/category')
18
+ ->getCollection()
19
+ ->addAttributeToSelect('*')
20
+ ->addAttributeToSelect('name')
21
+ ->addIsActiveFilter()
22
+ ->addOrderField('path', 'ASC');
23
+
24
+ $items = array();
25
+ foreach ($collection as $value) {
26
+ if ($value['name']) {
27
+ $level = $value['level'] - 2;
28
+ $label = @str_repeat("--", $level) . $value['name'];
29
+
30
+ $v = array('label' => $label,
31
+ 'value' => $value['entity_id']
32
+ );
33
+ array_push($items, $v);
34
+ }
35
+ }
36
+ return $items;
37
+ }
38
+
39
+ public function storeAttributes4Form() {
40
+
41
+ $collection = Mage::getResourceModel('catalog/product_attribute_collection')->addVisibleFilter();
42
+ $array = array();
43
+ foreach ($collection as $item) {
44
+ if ($item->getData('frontend_label')) {
45
+ $data = array('value' => $item->getData('attribute_code'), 'label' => $item->getData('frontend_label'));
46
+ array_push($array, $data);
47
+ }
48
+ }
49
+ return $array;
50
+ }
51
+
52
+
53
+ public function getProductCollection($storeId) {
54
+ $collection = Mage::getModel('catalog/product')->getCollection();
55
+
56
+ Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
57
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
58
+ $collection->addAttributeToFilter('small_image',array('notnull'=>'','neq'=>'no_selection'));
59
+
60
+ $collection->addAttributeToSelect('*')
61
+ ->addStoreFilter($storeId)
62
+ ->addAttributeToFilter('price', array('gt' => 1))
63
+ ->addAttributeToFilter('status', 1)
64
+ ->addAttributeToFilter('is_saleable', TRUE)
65
+ // ->addAttributeToFilter('type_id', array('eq' => 'simple'))
66
+ // ->addAttributeToFilter('type_id', array('neq' => 'configurable'))
67
+ ->addAttributeToFilter('type_id', array('neq' => 'bundle'))
68
+ ->addAttributeToFilter('type_id', array('neq' => 'grouped'))
69
+ ->addAttributeToFilter('small_image', array('neq' => 'no_selection'))
70
+ ;
71
+
72
+ return $collection;
73
+ }
74
+
75
+
76
+ public function getStoreProductsCount($storeId) {
77
+
78
+ $collection = $this->getProductCollection($storeId);
79
+
80
+ return $collection->getSize();
81
+ }
82
+
83
+
84
+
85
+ public function getAllProductsForStore($storeId) {
86
+ $collection = $this->getProductCollection($storeId);
87
+ return $collection->getSize();
88
+ }
89
+
90
+ public function getProductIds($storeId) {
91
+ $collection = $this->getProductCollection($storeId);
92
+ $array = array();
93
+ foreach ($collection as $product) {
94
+ $array[]=$product->getId();
95
+ }
96
+ return $array;
97
+ }
98
+
99
+ }
app/code/community/Magazento/Megabile/Model/Item.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on April 4, 2012
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com - ecommerceoffice.com
5
+ * Copyright Proskuryakov Ivan. ecommerceoffice.com © 2011. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php
10
+ class Magazento_Megabile_Model_Item extends Mage_Core_Model_Abstract
11
+ {
12
+ const CACHE_TAG = 'megabile_admin_item';
13
+ protected $_cacheTag = 'megabile_admin_item';
14
+
15
+ protected function _construct()
16
+ {
17
+ $this->_init('megabile/item');
18
+ }
19
+
20
+
21
+
22
+
23
+ public function prepareField($field) {
24
+ $field = htmlentities(trim($field));
25
+ $field = trim($field);
26
+ return $field;
27
+ }
28
+
29
+
30
+ public function buildXML($profile) {
31
+
32
+ $products = explode(",",$profile->getProducts());
33
+ // $use_attributes = $profile->getUseAttributes();
34
+ // $attributes = explode(",",$profile->getAttributes());
35
+ $root_category = $profile->getRootCategory();
36
+ $file = $profile->getFilename();
37
+ $store_id = $profile->getStoreId();
38
+ $products_for_export = $profile->getProductsForExport();
39
+
40
+ if (!$products_for_export) {
41
+ $products = Mage::getModel('megabile/data')->getProductIds($store_id);
42
+ }
43
+
44
+ // START EXPORT
45
+ $io = new Varien_Io_File();
46
+ $io->setAllowCreateFolders(true);
47
+ $io->open(array('path' => Mage::getBaseDir() ));
48
+ if ($io->fileExists($file) && !$io->isWriteable($file)) {
49
+ Mage::throwException(Mage::helper('core')->__('File "%s" cannot be saved. Please, make sure the directory "%s" is writeable by web server.', $file, $this->getPath()));
50
+ }
51
+
52
+ $io->streamOpen($file);
53
+ $io->streamWrite('<?xml version="1.0" encoding="UTF-8"?>');
54
+ $io->streamWrite('<xml date="'.date('Y-m-d H:i').'">');
55
+
56
+ $io->streamWrite('<shop>' . "\n");
57
+
58
+ //CATEGORIES
59
+ $io->streamWrite('<categories>' . "\n");
60
+ $categories = Mage::getModel('catalog/category')
61
+ ->setStoreId($store_id)
62
+ ->getCollection()
63
+ ->addAttributeToSelect('*')
64
+ ;
65
+ foreach($categories as $category) {
66
+ $cat = Mage::getModel('catalog/category')->load($category->getId());
67
+
68
+ if ($cat['name']) {
69
+ if ($cat['entity_id'] == $root_category) {
70
+ $cat['parent_id'] = 0;
71
+ }
72
+ $io->streamWrite('<category id="'.$cat['entity_id'].'" parentId="'.$cat['parent_id'].'" >'.$this->prepareField($cat['name']).'</category>' . "\n");
73
+ }
74
+
75
+
76
+ }
77
+ $io->streamWrite('</categories>' . "\n");
78
+
79
+ //PRODUCTS
80
+ $io->streamWrite('<offers>'. "\n");
81
+ $i=0;
82
+ foreach ($products as $product_id) {
83
+
84
+ $cat_ids = 0;
85
+ $Product = Mage::getModel('catalog/product')->setStoreId($store_id)->load($product_id);
86
+ $parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild($Product->getId());
87
+ $groupedParentId = $parentIds[0] ;
88
+
89
+
90
+ $price = $Product->getData('price');
91
+
92
+ if($groupedParentId)
93
+ {
94
+ $Product_parent = Mage::getModel('catalog/product')->setStoreId($store_id)->load($groupedParentId);
95
+
96
+ // if($Product_parent->getImage() != 'no_selection') {
97
+ $image = $Product_parent->getImageUrl();
98
+ // }
99
+
100
+ $url = $Product_parent->getProductUrl();
101
+ $description = $Product_parent->getDescription();
102
+ $cat_ids = Mage::getResourceSingleton('catalog/product')->getCategoryIds($Product_parent);
103
+ } else {
104
+ // if($Product->getImage() != 'no_selection') {
105
+ $image = $Product->getImageUrl();
106
+ // }
107
+
108
+ $url = $Product->getProductUrl();
109
+ $description = $Product->getDescription();
110
+ $cat_ids = Mage::getResourceSingleton('catalog/product')->getCategoryIds($Product);
111
+ }
112
+
113
+ if (($cat_ids) && ($price > 0)) {
114
+ $i++;
115
+ $cat = implode(',',$cat_ids);
116
+
117
+ $io->streamWrite("\t".'<offer id="'.$Product->getData('entity_id').'" >'. "\n");
118
+ $io->streamWrite("\t\t".'<url>'.$url.'</url>'."\n");
119
+ $io->streamWrite("\t\t".'<price>'.$price.'</price>'."\n");
120
+ $io->streamWrite("\t\t".'<currencyId>RUR</currencyId>'."\n");
121
+ $io->streamWrite("\t\t<categoryId>\n");
122
+ foreach ($cat_ids as $cat_id) {
123
+ $io->streamWrite("\t\t".'<cid>'.$cat_id.'</cid>'."\n");
124
+ }
125
+ $io->streamWrite("\t\t</categoryId>\n");
126
+ $io->streamWrite("\t\t".'<picture>'.$image.'</picture>'."\n");
127
+ $io->streamWrite("\t\t".'<name><![CDATA['.$this->prepareField($Product->getName()).']]></name>'."\n");
128
+ $io->streamWrite("\t\t".'<sku>'.$Product->getSku().'</sku>'."\n");
129
+ $io->streamWrite("\t\t".'<description><![CDATA['.$this->prepareField($description).']]></description>'."\n");
130
+ $io->streamWrite('</offer>'. "\n");
131
+
132
+ //if ($i==10)break;
133
+
134
+ }
135
+ }
136
+ $io->streamWrite('</offers>'. "\n");
137
+
138
+ $io->streamWrite('</shop>'. "\n");
139
+ $io->streamWrite('</xml>'. "\n");
140
+ $io->streamClose();
141
+
142
+ return $i;
143
+
144
+
145
+ // var_dump($products);
146
+ // var_dump($attributes);
147
+ // var_dump($root_category);
148
+ // var_dump($filename);
149
+ // var_dump($store_id);
150
+ // var_dump($products_for_export);
151
+ }
152
+
153
+ }
app/code/community/Magazento/Megabile/Model/Mysql4/Item.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on April 4, 2012
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com - ecommerceoffice.com
5
+ * Copyright Proskuryakov Ivan. ecommerceoffice.com © 2011. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php
10
+
11
+ class Magazento_Megabile_Model_Mysql4_Item extends Mage_Core_Model_Mysql4_Abstract {
12
+
13
+ protected function _construct() {
14
+ $this->_init('megabile/item', 'item_id');
15
+ }
16
+
17
+ protected function _beforeSave(Mage_Core_Model_Abstract $object) {
18
+ $dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
19
+ $object->setFromTime(Mage::getSingleton('core/date')->gmtDate());
20
+ return $this;
21
+ }
22
+
23
+ protected function _afterLoad(Mage_Core_Model_Abstract $object) {
24
+
25
+ $attr = $object->getData('attributes');
26
+ $object->setData('product_attributes', $attr);
27
+ return parent::_afterLoad($object);
28
+ }
29
+
30
+ }
app/code/community/Magazento/Megabile/Model/Mysql4/Item/Collection.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on April 4, 2012
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com - ecommerceoffice.com
5
+ * Copyright Proskuryakov Ivan. ecommerceoffice.com © 2011. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php
10
+
11
+ class Magazento_Megabile_Model_Mysql4_Item_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
12
+
13
+ protected function _construct() {
14
+ $this->_init('megabile/item');
15
+ }
16
+
17
+ public function toOptionArray() {
18
+ return $this->_toOptionArray('item_id', 'name');
19
+ }
20
+
21
+ public function addStoreFilter($storeIds)
22
+ {
23
+ $this->getSelect()->where('main_table.store_id IN (?)', $storeIds);
24
+ return $this;
25
+ }
26
+
27
+ }
app/code/community/Magazento/Megabile/controllers/Admin/CatalogController.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Dec 6, 2012
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com - Magazento.com
5
+ * Copyright Proskuryakov Ivan. Magazento.com © 2012. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php
10
+
11
+ class Magazento_Megabile_Admin_CatalogController extends Mage_Adminhtml_Controller_Action {
12
+
13
+ protected function _initAction() {
14
+
15
+ if (Mage::helper('megabile')->versionUseAdminTitle()) {
16
+ $this->_title($this->__('MEGABILE'));
17
+ }
18
+
19
+
20
+ $this->loadLayout()
21
+ ->_setActiveMenu('megabile')
22
+ ->_addBreadcrumb(Mage::helper('megabile')->__('megabile'), Mage::helper('megabile')->__('megabile'))
23
+ ->_addBreadcrumb(Mage::helper('megabile')->__('megabile Items'), Mage::helper('megabile')->__('megabile Items'))
24
+ ;
25
+ return $this;
26
+ }
27
+
28
+
29
+
30
+ public function saveAction() {
31
+ $id = $this->getRequest()->getParam('id');
32
+ if ($id) {
33
+ // try {
34
+ $profile = Mage::getModel('megabile/item')->load($id);
35
+ $count = Mage::getModel('megabile/item')->buildXML($profile);
36
+ Mage::getSingleton('adminhtml/session')->addSuccess($count .' products has been exported');
37
+ // } catch (Exception $e) {
38
+ // Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
39
+ // }
40
+
41
+
42
+ }
43
+ $this->_redirect('*/admin_item/index', array('item_id' => $id));
44
+ return;
45
+ }
46
+ }
app/code/community/Magazento/Megabile/controllers/Admin/ItemController.php ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on Dec 6, 2012
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com - Magazento.com
5
+ * Copyright Proskuryakov Ivan. Magazento.com © 2012. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php
10
+
11
+ class Magazento_Megabile_Admin_ItemController extends Mage_Adminhtml_Controller_Action {
12
+
13
+ protected function _initAction() {
14
+
15
+ if (Mage::helper('megabile')->versionUseAdminTitle()) {
16
+ $this->_title($this->__('MEGABILE'));
17
+ }
18
+
19
+
20
+ $this->loadLayout()
21
+ ->_setActiveMenu('megabile')
22
+ ->_addBreadcrumb(Mage::helper('megabile')->__('megabile'), Mage::helper('megabile')->__('megabile'))
23
+ ->_addBreadcrumb(Mage::helper('megabile')->__('megabile Items'), Mage::helper('megabile')->__('megabile Items'))
24
+ ;
25
+ return $this;
26
+ }
27
+
28
+
29
+ /**
30
+ * Related part
31
+ */
32
+ public function relatedAction() {
33
+
34
+ $this->loadLayout();
35
+ $this->getLayout()->getBlock('megabile.related.grid');
36
+ $this->renderLayout();
37
+ }
38
+
39
+ public function relatedgridAction() {
40
+
41
+ $this->loadLayout();
42
+ $this->getLayout()->getBlock('megabile.related.grid');
43
+ $this->renderLayout();
44
+ }
45
+
46
+
47
+ public function indexAction() {
48
+
49
+ $this->_initAction()
50
+ ->_addContent($this->getLayout()->createBlock('megabile/admin_item'))
51
+ ->renderLayout();
52
+ }
53
+
54
+ public function newAction() {
55
+ $this->_forward('edit');
56
+ }
57
+
58
+ public function editAction() {
59
+ if (Mage::helper('megabile')->versionUseAdminTitle()) {
60
+ $this->_title($this->__('megabile'));
61
+ }
62
+ $id = $this->getRequest()->getParam('item_id');
63
+ $model = Mage::getModel('megabile/item');
64
+
65
+
66
+
67
+
68
+ if ($id) {
69
+ $model->load($id);
70
+ if (!$model->getId()) {
71
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('megabile')->__('This item no longer exists'));
72
+ $this->_redirect('*/*/');
73
+ return;
74
+ }
75
+ }
76
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
77
+ if (!empty($data)) {
78
+ $model->setData($data);
79
+ }
80
+
81
+ Mage::register('megabile_item', $model);
82
+ $this->_initAction()
83
+ ->_addBreadcrumb($id ? Mage::helper('megabile')->__('Edit rule') : Mage::helper('megabile')->__('New Event'), $id ? Mage::helper('megabile')->__('Edit rule') : Mage::helper('megabile')->__('New rule'))
84
+ ->_addContent($this->getLayout()->createBlock('megabile/admin_item_edit')->setData('action', $this->getUrl('*/admin_item/save')))
85
+ ->_addLeft($this->getLayout()->createBlock('megabile/admin_item_edit_tabs'))
86
+ ->renderLayout();
87
+
88
+
89
+ }
90
+
91
+ public function deleteAction() {
92
+ if ($id = $this->getRequest()->getParam('item_id')) {
93
+ try {
94
+ $model = Mage::getModel('megabile/item');
95
+ $model->load($id);
96
+ $model->delete();
97
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('megabile')->__('Item was successfully deleted'));
98
+ $this->_redirect('*/*/');
99
+ return;
100
+ } catch (Exception $e) {
101
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
102
+ $this->_redirect('*/*/edit', array('item_id' => $id));
103
+ return;
104
+ }
105
+ }
106
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('megabile')->__('Unable to find a item to delete'));
107
+ $this->_redirect('*/*/');
108
+ }
109
+
110
+ protected function _isAllowed() {
111
+ return Mage::getSingleton('admin/session')->isAllowed('megabile/item');
112
+ }
113
+
114
+ public function wysiwygAction() {
115
+ $elementId = $this->getRequest()->getParam('element_id', md5(microtime()));
116
+ $content = $this->getLayout()->createBlock('adminhtml/catalog_helper_form_wysiwyg_content', '', array(
117
+ 'editor_element_id' => $elementId
118
+ ));
119
+ $this->getResponse()->setBody($content->toHtml());
120
+ }
121
+
122
+ public function massDeleteAction() {
123
+ $itemIds = $this->getRequest()->getParam('massaction');
124
+ if(!is_array($itemIds)) {
125
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('megabile')->__('Please select item(s)'));
126
+ } else {
127
+ try {
128
+ foreach ($itemIds as $itemId) {
129
+ $mass = Mage::getModel('megabile/item')->load($itemId);
130
+ $mass->delete();
131
+ }
132
+ Mage::getSingleton('adminhtml/session')->addSuccess(
133
+ Mage::helper('megabile')->__(
134
+ 'Total of %d record(s) were successfully deleted', count($itemIds)
135
+ )
136
+ );
137
+ } catch (Exception $e) {
138
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
139
+ }
140
+ }
141
+ $this->_redirect('*/*/index');
142
+ }
143
+
144
+ public function saveAction() {
145
+ if ($data = $this->getRequest()->getPost()) {
146
+ $model = Mage::getModel('megabile/item');
147
+
148
+ if (isset($data['related_prodlist'])) {
149
+ $data['products'] = implode(",",$data['related_prodlist']);
150
+ }
151
+ $data['attributes'] = implode(",",$data['product_attributes']);
152
+
153
+ $model->setData($data);
154
+ try {
155
+ $model->save();
156
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('megabile')->__('Item was successfully saved'));
157
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
158
+ if ($this->getRequest()->getParam('back')) {
159
+ $this->_redirect('*/*/edit', array('item_id' => $model->getId()));
160
+ return;
161
+ }
162
+ $this->_redirect('*/*/');
163
+ return;
164
+ } catch (Exception $e) {
165
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
166
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
167
+ $this->_redirect('*/*/edit', array('item_id' => $this->getRequest()->getParam('item_id')));
168
+ return;
169
+ }
170
+ }
171
+ $this->_redirect('*/*/');
172
+ }
173
+ }
app/code/community/Magazento/Megabile/etc/config.xml ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <config>
3
+ <modules>
4
+ <Magazento_Megabile>
5
+ <version>0.0.1</version>
6
+ </Magazento_Megabile>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <megabile>
11
+ <class>Magazento_Megabile_Block</class>
12
+ </megabile>
13
+ </blocks>
14
+ <helpers>
15
+ <megabile>
16
+ <class>Magazento_Megabile_Helper</class>
17
+ </megabile>
18
+ </helpers>
19
+ <models>
20
+ <megabile>
21
+ <class>Magazento_Megabile_Model</class>
22
+ <resourceModel>megabile_mysql4</resourceModel>
23
+ </megabile>
24
+ <megabile_mysql4>
25
+ <class>Magazento_Megabile_Model_Mysql4</class>
26
+ <entities>
27
+ <item>
28
+ <table>magazento_megabile_item</table>
29
+ </item>
30
+ <category>
31
+ <table>magazento_megabile_category</table>
32
+ </category>
33
+ </entities>
34
+ </megabile_mysql4>
35
+ </models>
36
+ <resources>
37
+ <megabile_setup>
38
+ <setup>
39
+ <module>Magazento_Megabile</module>
40
+ </setup>
41
+ <connection>
42
+ <use>core_setup</use>
43
+ </connection>
44
+ </megabile_setup>
45
+ <megabile_write>
46
+ <connection>
47
+ <use>core_write</use>
48
+ </connection>
49
+ </megabile_write>
50
+ <megabile_read>
51
+ <connection>
52
+ <use>core_read</use>
53
+ </connection>
54
+ </megabile_read>
55
+ </resources>
56
+ </global>
57
+
58
+ <admin>
59
+ <routers>
60
+ <megabile>
61
+ <use>admin</use>
62
+ <args>
63
+ <module>Magazento_Megabile</module>
64
+ <frontName>megabile</frontName>
65
+ </args>
66
+ </megabile>
67
+ </routers>
68
+ </admin>
69
+
70
+ <adminhtml>
71
+ <layout>
72
+ <updates>
73
+ <megabile>
74
+ <file>magazento_megabile.xml</file>
75
+ </megabile>
76
+ </updates>
77
+ </layout>
78
+ <acl>
79
+ <resources>
80
+ <admin>
81
+ <children>
82
+ <system>
83
+ <children>
84
+ <config>
85
+ <children>
86
+ <megabile>
87
+ <title>megabile</title>
88
+ <sort_order>101</sort_order>
89
+ </megabile>
90
+ </children>
91
+ </config>
92
+ </children>
93
+ </system>
94
+ </children>
95
+ </admin>
96
+ </resources>
97
+ </acl>
98
+ <menu>
99
+ <megabile translate="title" module="megabile">
100
+ <title>Megabile</title>
101
+ <sort_order>99</sort_order>
102
+ <action>megabile/admin_item/index</action>
103
+ </megabile>
104
+ </menu>
105
+ </adminhtml>
106
+ <default>
107
+ <megabile>
108
+ <general>
109
+ <product_title_rewrite>1</product_title_rewrite>
110
+ <product_description_rewrite>1</product_description_rewrite>
111
+ <product_keyword_rewrite>1</product_keyword_rewrite>
112
+ <product_robots>1</product_robots>
113
+
114
+ <category_title_rewrite>1</category_title_rewrite>
115
+ <category_description_rewrite>1</category_description_rewrite>
116
+ <category_keyword_rewrite>1</category_keyword_rewrite>
117
+ <category_robots>1</category_robots>
118
+
119
+ <page_robots>1</page_robots>
120
+ <homepage_duplicates>1</homepage_duplicates>
121
+ </general>
122
+ </megabile>
123
+ </default>
124
+ </config>
app/code/community/Magazento/Megabile/etc/system.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <tabs>
3
+ <magazento translate="label">
4
+ <label>Magazento.com</label>
5
+ <sort_order>250</sort_order>
6
+ </magazento>
7
+ </tabs>
8
+ <sections>
9
+ <megabile translate="label" module="megabile">
10
+ <label>MEGABILE</label>
11
+ <tab>magazento</tab>
12
+ <frontend_type>text</frontend_type>
13
+ <sort_order>100</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
+ <groups>
18
+ <general translate="label">
19
+ <label>General settings &amp; rules</label>
20
+ <frontend_type>text</frontend_type>
21
+ <sort_order>10</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ <fields>
26
+ <product_robots translate="label">
27
+ <label>Product Meta Robots Enabled</label>
28
+ <frontend_type>select</frontend_type>
29
+ <source_model>adminhtml/system_config_source_yesno</source_model>
30
+ <comment><![CDATA[ Override default <meta name="robots" content="*" /> with tag from product]]></comment>
31
+ <sort_order>46</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </product_robots>
36
+ </fields>
37
+ </general>
38
+ </groups>
39
+ </megabile>
40
+
41
+
42
+
43
+ </sections>
44
+
45
+ </config>
app/code/community/Magazento/Megabile/sql/megabile_setup/mysql4-install-0.0.1.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+ $installer->installEntities();
7
+
8
+
9
+
10
+ $installer->run("
11
+
12
+
13
+
14
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('magazento_megabile_item')}` (
15
+ `item_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT ' Id',
16
+ `products` text NOT NULL,
17
+ `title` varchar(255) DEFAULT NULL,
18
+ `rule_title` varchar(255) DEFAULT NULL COMMENT 'Path',
19
+ `rule_url` varchar(255) DEFAULT NULL,
20
+ `rule_description` varchar(255) DEFAULT NULL,
21
+ `rule_keywords` varchar(255) DEFAULT NULL,
22
+ `store_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Store id',
23
+ PRIMARY KEY (`item_id`),
24
+ KEY `IDX_SITEMAP_STORE_ID` (`store_id`)
25
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
26
+
27
+ --
28
+ -- Dumping data for table `{$this->getTable('magazento_megabile_item')}`
29
+ --
30
+
31
+
32
+
33
+
34
+
35
+ ");
36
+
37
+
38
+
39
+ $installer->endSetup();
app/design/adminhtml/default/default/template/magazento_megabile/cattree.phtml ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="entry-edit">
2
+ <div class="entry-edit-head">
3
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('catalog')->__('Categories') ?></h4>
4
+ </div>
5
+ <fieldset id="grop_fields">
6
+ <input type="hidden" name="category_ids" id="item_categories" value="<?php echo $this->getIdsString() ?>">
7
+ <div id="item-categories" class="tree"></div>
8
+ </fieldset>
9
+ </div>
10
+
11
+ <?php if($this->getRootNode() && $this->getRootNode()->hasChildren()): ?>
12
+
13
+
14
+
15
+
16
+ <?php //var_dump($this->getCategoryIds()); ?>
17
+
18
+ <script type="text/javascript">
19
+ Ext.EventManager.onDocumentReady(function() {
20
+ var categoryLoader = new Ext.tree.TreeLoader({
21
+ dataUrl: '<?php echo $this->getLoadTreeUrl()?>'
22
+ });
23
+
24
+ categoryLoader.createNode = function(config) {
25
+ config.uiProvider = Ext.tree.CheckboxNodeUI;
26
+ var node;
27
+ if (config.children && !config.children.length) {
28
+ delete(config.children);
29
+ node = new Ext.tree.AsyncTreeNode(config);
30
+
31
+ } else {
32
+ node = new Ext.tree.TreeNode(config);
33
+ }
34
+ return node;
35
+ };
36
+
37
+ categoryLoader.on("beforeload", function(treeLoader, node) {
38
+ treeLoader.baseParams.category = node.attributes.id;
39
+ });
40
+
41
+ categoryLoader.on("load", function(treeLoader, node, config) {
42
+ varienWindowOnload();
43
+ });
44
+
45
+ var tree = new Ext.tree.TreePanel('item-categories', {
46
+ animate:true,
47
+ loader: categoryLoader,
48
+ enableDD:false,
49
+ containerScroll: true,
50
+ rootUIProvider: Ext.tree.CheckboxNodeUI,
51
+ selModel: new Ext.tree.CheckNodeMultiSelectionModel(),
52
+ rootVisible: '<?php echo $this->getRootNode()->getIsVisible() ?>'
53
+ });
54
+
55
+ tree.on('check', function(node) {
56
+ if(node.attributes.checked) {
57
+ categoryAdd(node.id);
58
+ } else {
59
+ categoryRemove(node.id);
60
+ }
61
+ varienElementMethods.setHasChanges(node.getUI().checkbox);
62
+ }, tree);
63
+
64
+ // set the root node
65
+ var root = new Ext.tree.TreeNode({
66
+ text: '<?php echo $this->jsQuoteEscape($this->getRootNode()->getName()) ?>',
67
+ draggable:false,
68
+ checked:'<?php echo $this->getRootNode()->getChecked() ?>',
69
+ id:'<?php echo $this->getRootNode()->getId() ?>',
70
+ disabled: <?php echo ($this->getRootNode()->getDisabled() ? 'true' : 'false') ?>,
71
+ uiProvider: Ext.tree.CheckboxNodeUI
72
+ });
73
+
74
+ tree.setRootNode(root);
75
+ bildCategoryTree(root, <?php echo $this->getTreeJson() ?>);
76
+ tree.addListener('click', categoryClick.createDelegate(this));
77
+
78
+ // render the tree
79
+ tree.render();
80
+ root.expand();
81
+ //tree.expandAll();
82
+ });
83
+
84
+ function bildCategoryTree(parent, config){
85
+ if (!config) return null;
86
+
87
+ if (parent && config && config.length){
88
+ for (var i = 0; i < config.length; i++){
89
+ config[i].uiProvider = Ext.tree.CheckboxNodeUI;
90
+ var node;
91
+ var _node = Object.clone(config[i]);
92
+ if (_node.children && !_node.children.length) {
93
+ delete(_node.children);
94
+ node = new Ext.tree.AsyncTreeNode(_node);
95
+
96
+ } else {
97
+ node = new Ext.tree.TreeNode(config[i]);
98
+ }
99
+ parent.appendChild(node);
100
+ node.loader = node.getOwnerTree().loader;
101
+ if(config[i].children){
102
+ bildCategoryTree(node, config[i].children);
103
+ }
104
+ }
105
+ }
106
+ }
107
+
108
+ function categoryClick(node, e){
109
+ if (node.disabled) {
110
+ return;
111
+ }
112
+ node.getUI().check(!node.getUI().checked());
113
+ varienElementMethods.setHasChanges(Event.element(e), e);
114
+ };
115
+ function categoryAdd(id) {
116
+ var ids = $('item_categories').value.split(',');
117
+ ids.push(id);
118
+ $('item_categories').value = ids.join(',');
119
+ }
120
+ function categoryRemove(id) {
121
+ var ids = $('item_categories').value.split(',');
122
+ while (-1 != ids.indexOf(id)) {
123
+ ids.splice(ids.indexOf(id), 1);
124
+ }
125
+ $('item_categories').value = ids.join(',');
126
+ }
127
+ </script>
128
+ <?php endif; ?>
app/etc/modules/Magazento_Megabile.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magazento_Megabile>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Magazento_Megabile>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>megabile</name>
4
+ <version>0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license>OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Export extension for Megabil.com </summary>
10
+ <description>Extension exports your magento products into one XML file. Which you can later upload Megabile.com.&#xD;
11
+ In Megabile we glad to provide you the simpliest way for pulishing your store on iPhone, already customized for your brand. Get native iPhone App for your store without any coding!</description>
12
+ <notes>initial release. Post all issues or bugs at magazento.com/ticket</notes>
13
+ <authors><author><name>volgodark</name><user>volgodark</user><email>volgodark@gmail.com</email></author></authors>
14
+ <date>2013-03-27</date>
15
+ <time>12:13:39</time>
16
+ <contents><target name="magecommunity"><dir name="Magazento"><dir name="Megabile"><dir name="Block"><dir name="Admin"><dir name="Item"><dir name="Edit"><file name="Form.php" hash="42185aaf964eb7548d63adcb78aee8cf"/><dir name="Tab"><file name="Form.php" hash="909e180f887f8b8bfc7245dd7ce67a3b"/><file name="Related.php" hash="3a88d4f98943150c3f026e1b0d157a1e"/></dir><file name="Tabs.php" hash="0bc2280975101e493d3d4f3fdcad4d1e"/></dir><file name="Edit.php" hash="7a379e684384dca6803d1f3cc9dcce0b"/><dir name="Grid"><dir name="Renderer"><file name="Action.php" hash="cd843831c9e76dba9f23e68f2f843bb7"/><file name="Category.php" hash="798701d014e649cd8a20ed9d2268bea5"/><file name="Link.php" hash="aa44b8da85cdb8de90e63d5281cacdee"/><file name="Products.php" hash="973c9ec718838f76478aee086bf32e36"/><file name="Time.php" hash="63dce7ad91c469ec930c9cec623cfdbd"/></dir></dir><file name="Grid.php" hash="54baf42c62dccf7e3ff5962a51db6040"/></dir><file name="Item.php" hash="05fa7f0a72a5fe2ba082ce65ca6e5430"/></dir></dir><dir name="Helper"><file name="Data.php" hash="ecfa3ef0ca79a598483ee8da44a35a27"/><file name="Product.php" hash="04296e9936820fd93615cfcd2e61be31"/></dir><dir name="Model"><file name="Data.php" hash="7367397972efbf028d0f22eb9614fc55"/><file name="Item.php" hash="f33871d166c8073776599f02f019d903"/><dir name="Mysql4"><dir name="Item"><file name="Collection.php" hash="703fbd93edd66314356dd2ce4403b940"/></dir><file name="Item.php" hash="be3c74e0805a95224a21ecfceff8f7c6"/></dir></dir><dir name="controllers"><dir name="Admin"><file name="CatalogController.php" hash="8fe30b7db6e97dbc75cca66c66493c62"/><file name="ItemController.php" hash="0152694a48dd86a931d9c64a7c7ece4f"/></dir></dir><dir name="etc"><file name="config.xml" hash="f1e3c6926572db52bb0642e94e459917"/><file name="system.xml" hash="bb37fe164606effab9977ff4203ad5d6"/></dir><dir name="sql"><dir name="megabile_setup"><file name="mysql4-install-0.0.1.php" hash="f5ee26dcbc6c950abcf58c8e50bc5dca"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="magazento_megabile"><file name="cattree.phtml" hash="996f95313df817494a4f50190d7e0ac9"/></dir><file name="magazento_megabile.xml" hash=""/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magazento_Megabile.xml" hash="822e0f1c604b5d762f33ee47b30cbff8"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="magazento_megabile"><file name="style.css" hash="f25650dc11cd81736bb880de1fa80e94"/></dir></dir></dir></dir></target></contents>
17
+ <compatible/>
18
+ <dependencies><required><php><min>5.1.1</min><max>6.0.0</max></php></required></dependencies>
19
+ </package>
skin/adminhtml/default/default/magazento_megabile/style.css ADDED
@@ -0,0 +1 @@
 
1
+ /* FOR FUTURE RELEASES */