Me_Shopdash - Version 1.1.7

Version Notes

Version number: 1.1.7. Stability: Stable Compatibility: 1.4.x, 1.5.x, 1.6.x, 1.7.x, 1.8.x.
The extension provides communication between Magento and ShopDash Application(http://shopdashapp.com).

Download this release

Release Info

Developer ShopDash
Extension Me_Shopdash
Version 1.1.7
Comparing to
See all releases


Version 1.1.7

Files changed (31) hide show
  1. app/code/community/Me/Shopdash/Block/Adminhtml/Shopdash.php +20 -0
  2. app/code/community/Me/Shopdash/Block/Adminhtml/Shopdash/Edit.php +47 -0
  3. app/code/community/Me/Shopdash/Block/Adminhtml/Shopdash/Edit/Form.php +34 -0
  4. app/code/community/Me/Shopdash/Block/Adminhtml/Shopdash/Edit/Tab/Grid.php +249 -0
  5. app/code/community/Me/Shopdash/Block/Adminhtml/Shopdash/Edit/Tabs.php +31 -0
  6. app/code/community/Me/Shopdash/Block/Adminhtml/Shopdash/Store/Switcher.php +26 -0
  7. app/code/community/Me/Shopdash/Block/Adminhtml/System/Config/Form/Button.php +54 -0
  8. app/code/community/Me/Shopdash/Helper/Data.php +280 -0
  9. app/code/community/Me/Shopdash/Model/Mysql4/Shopdash.php +15 -0
  10. app/code/community/Me/Shopdash/Model/Mysql4/Shopdash/Collection.php +16 -0
  11. app/code/community/Me/Shopdash/Model/Shopdash.php +446 -0
  12. app/code/community/Me/Shopdash/Model/Shopdash/Catalog/Product.php +137 -0
  13. app/code/community/Me/Shopdash/Model/System/Config/Backend/Shopdash/Cron.php +43 -0
  14. app/code/community/Me/Shopdash/Model/System/Config/Source/Attributes.php +25 -0
  15. app/code/community/Me/Shopdash/Model/System/Config/Source/Category.php +57 -0
  16. app/code/community/Me/Shopdash/Model/System/Config/Source/Priceattributes.php +25 -0
  17. app/code/community/Me/Shopdash/Model/System/Config/Source/Priority.php +28 -0
  18. app/code/community/Me/Shopdash/Model/System/Config/Source/Properties.php +24 -0
  19. app/code/community/Me/Shopdash/Model/System/Config/Source/Redirect.php +22 -0
  20. app/code/community/Me/Shopdash/Model/System/Config/Source/Textattributes.php +25 -0
  21. app/code/community/Me/Shopdash/controllers/AddController.php +300 -0
  22. app/code/community/Me/Shopdash/controllers/Adminhtml/ShopdashController.php +178 -0
  23. app/code/community/Me/Shopdash/etc/adminhtml.xml +78 -0
  24. app/code/community/Me/Shopdash/etc/config.xml +143 -0
  25. app/code/community/Me/Shopdash/etc/system.xml +293 -0
  26. app/code/community/Me/Shopdash/sql/me_shopdash_setup/mysql4-install-0.1.0.php +32 -0
  27. app/design/adminhtml/default/default/layout/me_shopdash.xml +53 -0
  28. app/design/adminhtml/default/default/template/me/shopdash/system/config/form/button.phtml +35 -0
  29. app/etc/modules/Me_Shopdash.xml +22 -0
  30. app/locale/en_US/Me_Shopdash.csv +64 -0
  31. package.xml +22 -0
app/code/community/Me/Shopdash/Block/Adminhtml/Shopdash.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Block_Adminhtml_Shopdash extends Mage_Adminhtml_Block_Widget_Grid_Container
10
+ {
11
+ public function __construct()
12
+ {
13
+ $this->_blockGroup = 'me_shopdash';
14
+ $this->_controller = 'adminhtml_shopdash';
15
+ $this->_headerText = Mage::helper('me_shopdash')->__('Shopdash Manager');
16
+ $this->_addButtonLabel = Mage::helper('me_shopdash')->__('Add Item');
17
+ parent::__construct();
18
+ $this->_removeButton('add');
19
+ }
20
+ }
app/code/community/Me/Shopdash/Block/Adminhtml/Shopdash/Edit.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Block_Adminhtml_Shopdash_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
10
+ {
11
+ public function __construct()
12
+ {
13
+ $this->_objectId = 'id';
14
+ $this->_blockGroup = 'me_shopdash';
15
+ $this->_controller = 'adminhtml_shopdash';
16
+
17
+ parent::__construct();
18
+
19
+ $this->_updateButton('save', 'label', Mage::helper('me_shopdash')->__('Save Products'));
20
+
21
+ $this->_removeButton('saveandcontinue');
22
+ $this->_removeButton('delete');
23
+ $this->_removeButton('back');
24
+ }
25
+
26
+ /**
27
+ * Add child HTML to layout
28
+ * @return Me_Shopdash_Block_Adminhtml_Shopdash_Edit
29
+ */
30
+ protected function _prepareLayout()
31
+ {
32
+ parent::_prepareLayout();
33
+
34
+ $this->setChild('store_switcher', $this->getLayout()->createBlock('adminhtml/tag_store_switcher'));
35
+
36
+ return $this;
37
+ }
38
+
39
+ /**
40
+ * Get header text
41
+ * @return string
42
+ */
43
+ public function getHeaderText()
44
+ {
45
+ return Mage::helper('me_shopdash')->__('Select Export Product(s)');
46
+ }
47
+ }
app/code/community/Me/Shopdash/Block/Adminhtml/Shopdash/Edit/Form.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Block_Adminhtml_Shopdash_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ protected function _prepareForm()
12
+ {
13
+ $form = new Varien_Data_Form(array(
14
+ 'id' => 'edit_form',
15
+ 'action' => $this->getSaveUrl(),
16
+ 'method' => 'post',
17
+ 'enctype' => 'multipart/form-data'
18
+ )
19
+ );
20
+
21
+ $form->setUseContainer(true);
22
+ $this->setForm($form);
23
+ return parent::_prepareForm();
24
+ }
25
+
26
+ /**
27
+ * Retrieve Save URL
28
+ * @return string
29
+ */
30
+ public function getSaveUrl()
31
+ {
32
+ return $this->getUrl('*/*/save', array('_current'=>true));
33
+ }
34
+ }
app/code/community/Me/Shopdash/Block/Adminhtml/Shopdash/Edit/Tab/Grid.php ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Block_Adminhtml_Shopdash_Edit_Tab_Grid extends Mage_Adminhtml_Block_Widget_Grid
10
+ {
11
+ /**
12
+ * Set grid params
13
+ */
14
+ public function __construct()
15
+ {
16
+ parent::__construct();
17
+ $this->setId('shopdashGrid');
18
+ $this->setUseAjax(true);
19
+ $this->setDefaultSort('entity_id');
20
+ $this->setDefaultFilter(array('in_products'=>1));
21
+ $this->setSaveParametersInSession(false);
22
+ }
23
+
24
+ /**
25
+ * Store getter
26
+ * @return Mage_Core_Model_Store
27
+ */
28
+ protected function _getStore()
29
+ {
30
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
31
+ return Mage::app()->getStore($storeId);
32
+ }
33
+
34
+ /**
35
+ * Add filter
36
+ * @param object $column
37
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Upsell
38
+ */
39
+ protected function _addColumnFilterToCollection($column)
40
+ {
41
+ // Set custom filter for in product flag
42
+ if ($column->getId() == 'in_products') {
43
+ $productIds = $this->_getSelectedProducts();
44
+ if (empty($productIds)) {
45
+ $productIds = 0;
46
+ }
47
+ if ($column->getFilter()->getValue()) {
48
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
49
+ } else {
50
+ if($productIds) {
51
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
52
+ }
53
+ }
54
+ } else {
55
+ parent::_addColumnFilterToCollection($column);
56
+ }
57
+ return $this;
58
+ }
59
+
60
+ /**
61
+ * Checks when this block is readonly
62
+ * @return boolean
63
+ */
64
+ public function isReadonly()
65
+ {
66
+ return false;
67
+ }
68
+
69
+ /**
70
+ * Prepare collection
71
+ * @return Mage_Adminhtml_Block_Widget_Grid
72
+ */
73
+ protected function _prepareCollection()
74
+ {
75
+ $store = $this->_getStore();
76
+
77
+ $collection = Mage::getModel('catalog/product')->getCollection()
78
+ ->addAttributeToSelect('sku')
79
+ ->addAttributeToSelect('name')
80
+ ->addAttributeToSelect('attribute_set_id')
81
+ ->addAttributeToSelect('type_id');
82
+
83
+ if ($store->getId()) {
84
+ $collection->addStoreFilter($store);
85
+ $collection->joinAttribute('custom_name', 'catalog_product/name', 'entity_id', null, 'inner', $store->getId());
86
+ $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner', $store->getId());
87
+ $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', $store->getId());
88
+ $collection->joinAttribute('price', 'catalog_product/price', 'entity_id', null, 'left', $store->getId());
89
+ } else {
90
+ $collection->addAttributeToSelect('price');
91
+ $collection->addAttributeToSelect('status');
92
+ $collection->addAttributeToSelect('visibility');
93
+ }
94
+
95
+ $collection->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
96
+ ->addAttributeToFilter('visibility', array('neq' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE))
97
+ ->addAttributeToFilter('type_id', array('in' => Mage::helper('me_shopdash')->getBaseProductTypes()));
98
+
99
+ if ($this->isReadonly()) {
100
+ $productIds = $this->_getSelectedProducts();
101
+ if (empty($productIds)) {
102
+ $productIds = array(0);
103
+ }
104
+ $collection->addFieldToFilter('entity_id', array('in'=>$productIds));
105
+ }
106
+
107
+ $this->setCollection($collection);
108
+ return parent::_prepareCollection();
109
+ }
110
+
111
+ /**
112
+ * Add columns to grid
113
+ * @return Mage_Adminhtml_Block_Widget_Grid
114
+ */
115
+ protected function _prepareColumns()
116
+ {
117
+ if (!$this->isReadonly()) {
118
+ $this->addColumn('in_products', array(
119
+ 'header_css_class' => 'a-center',
120
+ 'type' => 'checkbox',
121
+ 'name' => 'in_products',
122
+ 'values' => $this->_getSelectedProducts(),
123
+ 'align' => 'center',
124
+ 'index' => 'entity_id'
125
+ ));
126
+ }
127
+
128
+ $this->addColumn('entity_id', array(
129
+ 'header' => Mage::helper('catalog')->__('ID'),
130
+ 'sortable' => true,
131
+ 'width' => 60,
132
+ 'index' => 'entity_id'
133
+ ));
134
+ $this->addColumn('name', array(
135
+ 'header' => Mage::helper('catalog')->__('Name'),
136
+ 'index' => 'name'
137
+ ));
138
+
139
+ $store = $this->_getStore();
140
+ if ($store->getId()) {
141
+ $this->addColumn('custom_name',
142
+ array(
143
+ 'header'=> Mage::helper('me_shopdash')->__('Name in %s', $store->getName()),
144
+ 'index' => 'custom_name',
145
+ ));
146
+ }
147
+
148
+ $types = Mage::getSingleton('catalog/product_type')->getOptionArray();
149
+ unset($types['grouped']);
150
+ unset($types['bundle']);
151
+ $this->addColumn('type', array(
152
+ 'header' => Mage::helper('catalog')->__('Type'),
153
+ 'width' => 100,
154
+ 'index' => 'type_id',
155
+ 'type' => 'options',
156
+ 'options' => $types,
157
+ ));
158
+
159
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
160
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
161
+ ->load()
162
+ ->toOptionHash();
163
+
164
+ $this->addColumn('set_name', array(
165
+ 'header' => Mage::helper('catalog')->__('Attrib. Set Name'),
166
+ 'width' => 130,
167
+ 'index' => 'attribute_set_id',
168
+ 'type' => 'options',
169
+ 'options' => $sets,
170
+ ));
171
+
172
+ $visibility = Mage::getSingleton('catalog/product_visibility')->getOptionArray();
173
+ unset($visibility[1]);
174
+ $this->addColumn('visibility', array(
175
+ 'header' => Mage::helper('catalog')->__('Visibility'),
176
+ 'width' => 90,
177
+ 'index' => 'visibility',
178
+ 'type' => 'options',
179
+ 'options' => $visibility,
180
+ ));
181
+
182
+ $this->addColumn('sku', array(
183
+ 'header' => Mage::helper('catalog')->__('SKU'),
184
+ 'width' => 80,
185
+ 'index' => 'sku'
186
+ ));
187
+
188
+ $this->addColumn('price', array(
189
+ 'header' => Mage::helper('catalog')->__('Price'),
190
+ 'type' => 'currency',
191
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
192
+ 'index' => 'price'
193
+ ));
194
+
195
+ $this->addColumn('position', array(
196
+ 'header' => Mage::helper('catalog')->__('Position'),
197
+ 'name' => 'position',
198
+ 'type' => 'number',
199
+ 'width' => 60,
200
+ 'validate_class' => 'validate-number',
201
+ 'index' => 'position',
202
+ 'editable' => true,
203
+ 'edit_only' => true
204
+ ));
205
+
206
+ return parent::_prepareColumns();
207
+ }
208
+
209
+ /**
210
+ * Rerieve grid URL
211
+ * @return string
212
+ */
213
+ public function getGridUrl()
214
+ {
215
+ return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/productgrid', array('_current'=>true));
216
+ }
217
+
218
+ /**
219
+ * Retrieve selected shopdash products
220
+ * @return array
221
+ */
222
+ protected function _getSelectedProducts()
223
+ {
224
+ $products = $this->getProducts();
225
+ if (!is_array($products)) {
226
+ $products = array_keys($this->getSelectedProducts());
227
+ }
228
+ return $products;
229
+ }
230
+
231
+ /**
232
+ * Retrieve selected products
233
+ * @return array
234
+ */
235
+ public function getSelectedProducts()
236
+ {
237
+ $products = array();
238
+
239
+ $shopDashCollection = Mage::getModel('me_shopdash/shopdash')->getCollection()
240
+ ->addFieldToFilter('store_id', $this->_getStore()->getId());
241
+
242
+ foreach($shopDashCollection as $shopdash) {
243
+ $products[$shopdash->getProductId()] = array('position' => 0);
244
+ }
245
+
246
+ return $products;
247
+ }
248
+
249
+ }
app/code/community/Me/Shopdash/Block/Adminhtml/Shopdash/Edit/Tabs.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Block_Adminhtml_Shopdash_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
10
+ {
11
+
12
+ public function __construct()
13
+ {
14
+ parent::__construct();
15
+ $this->setId('shopdash_tabs');
16
+ $this->setDestElementId('edit_form');
17
+ $this->setTitle(Mage::helper('me_shopdash')->__('ShopDash Export Information'));
18
+ }
19
+
20
+ protected function _beforeToHtml()
21
+ {
22
+ $this->addTab('form_section1', array(
23
+ 'label' => Mage::helper('me_shopdash')->__('Select Export Products'),
24
+ 'title' => Mage::helper('me_shopdash')->__('Select Export Products'),
25
+ 'url' => $this->getUrl('*/*/product', array('_current' => true)),
26
+ 'class' => 'ajax',
27
+ ));
28
+
29
+ return parent::_beforeToHtml();
30
+ }
31
+ }
app/code/community/Me/Shopdash/Block/Adminhtml/Shopdash/Store/Switcher.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Block_Adminhtml_Shopdash_Store_Switcher extends Mage_Adminhtml_Block_Store_Switcher
10
+ {
11
+ /**
12
+ * @var bool
13
+ */
14
+ protected $_hasDefaultOption = false;
15
+
16
+ /**
17
+ * Set overriden params
18
+ */
19
+ public function __construct()
20
+ {
21
+ parent::__construct();
22
+ $this->setUseConfirm(false)->setSwitchUrl(
23
+ $this->getUrl('*/*/*/', array('store' => null, '_current' => true))
24
+ );
25
+ }
26
+ }
app/code/community/Me/Shopdash/Block/Adminhtml/System/Config/Form/Button.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Block_Adminhtml_System_Config_Form_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
10
+ {
11
+ /**
12
+ * Set template
13
+ */
14
+ protected function _construct()
15
+ {
16
+ parent::_construct();
17
+ $this->setTemplate('me/shopdash/system/config/form/button.phtml');
18
+ }
19
+
20
+ /**
21
+ * Return element html
22
+ * @param Varien_Data_Form_Element_Abstract $element
23
+ * @return string
24
+ */
25
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
26
+ {
27
+ return $this->_toHtml();
28
+ }
29
+
30
+ /**
31
+ * Return ajax url for button
32
+ * @return string
33
+ */
34
+ public function getAjaxRunUrl()
35
+ {
36
+ return Mage::helper('adminhtml')->getUrl('adminhtml/adminhtml_shopdash/run');
37
+ }
38
+
39
+ /**
40
+ * Generate button html
41
+ * @return string
42
+ */
43
+ public function getButtonHtml()
44
+ {
45
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
46
+ ->setData(array(
47
+ 'id' => 'me_shopdash_button',
48
+ 'label' => $this->helper('me_shopdash')->__('Run Export'),
49
+ 'onclick' => 'javascript:run(); return false;'
50
+ ));
51
+
52
+ return $button->toHtml();
53
+ }
54
+ }
app/code/community/Me/Shopdash/Helper/Data.php ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Helper_Data extends Mage_Core_Helper_Abstract
10
+ {
11
+ /**
12
+ * Extension log file name
13
+ * @var string
14
+ */
15
+ protected $_log = 'shopdash.log';
16
+
17
+ /**
18
+ * Base attributes for export
19
+ * @var array
20
+ */
21
+ protected $_baseAttributes = array('name', 'description', 'url_path', 'image');
22
+
23
+ /**
24
+ * Not used attributes for export
25
+ * @var array
26
+ */
27
+ protected $_removedAttributes = array(
28
+ 'visibility',
29
+ 'status',
30
+ 'url_key',
31
+ 'gift_message_available',
32
+ 'is_recurring'
33
+ );
34
+
35
+ /**
36
+ * Base product types for export
37
+ * @var array
38
+ */
39
+ protected $_baseProductTypes = array('simple', 'configurable', 'virtual', 'downloadable');
40
+
41
+ /**
42
+ * Deals variable
43
+ * @var array
44
+ */
45
+ protected $_deal = array();
46
+
47
+ /**
48
+ * Product config array
49
+ * @var array
50
+ */
51
+ protected $_productConfig = array();
52
+
53
+ /**
54
+ * Product unit attribute is custom
55
+ * @var bool
56
+ */
57
+ protected $_productUnitIsCustom = false;
58
+
59
+ /**
60
+ * Category config array
61
+ * @var array
62
+ */
63
+ protected $_categoryConfig = array();
64
+
65
+ /**
66
+ * Get extension config
67
+ * @param $var
68
+ * @return mixed
69
+ */
70
+ public function getBaseConfigByVar( $var )
71
+ {
72
+ return Mage::getStoreConfig('shopdash/config/' . $var);
73
+ }
74
+
75
+ /**
76
+ * Get extension basic attributes to select
77
+ * @return array
78
+ */
79
+ public function getBaseAttributes()
80
+ {
81
+ return $this->_baseAttributes;
82
+ }
83
+
84
+ /**
85
+ * Get attributes to remove form select
86
+ * @return array
87
+ */
88
+ public function getRemovedAttributes()
89
+ {
90
+ return $this->_removedAttributes;
91
+ }
92
+
93
+ /**
94
+ * Get extension basic product types to select
95
+ * @return array
96
+ */
97
+ public function getBaseProductTypes()
98
+ {
99
+ return $this->_baseProductTypes;
100
+ }
101
+
102
+ /**
103
+ * Get extension deal configuration
104
+ * @return mixed
105
+ */
106
+ public function getDealsConfig()
107
+ {
108
+ return Mage::getStoreConfig('shopdash/deals');
109
+ }
110
+
111
+ /**
112
+ * Get extension products configuration
113
+ * @return mixed
114
+ */
115
+ public function getProductConfig()
116
+ {
117
+ $this->_productConfig = Mage::getStoreConfig('shopdash/products');
118
+ if( !is_null($this->_productConfig) ) return $this->_productConfig;
119
+ else return null;
120
+ }
121
+
122
+ /**
123
+ * Get product properties
124
+ * @return array
125
+ */
126
+ public function getProperties()
127
+ {
128
+ $this->getProductConfig();
129
+ if( isset($this->_productConfig['properties']) && !empty($this->_productConfig['properties']) ) {
130
+ $properties = explode(',', $this->_productConfig['properties']);
131
+
132
+ return $properties;
133
+ }
134
+ else return array();
135
+ }
136
+
137
+ /**
138
+ * Get extension product unit configuration
139
+ * @return mixed
140
+ */
141
+ public function getProductUnit()
142
+ {
143
+ $this->getProductConfig();
144
+ if( isset($this->_productConfig['unit']) && !empty($this->_productConfig['unit']) ) return $this->_productConfig['unit'];
145
+ else {
146
+ $this->_productUnitIsCustom = true;
147
+ return $this->_productConfig['unit_custom'];
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Get if extension unit configuration is custom
153
+ * @return bool
154
+ */
155
+ public function getProductUnitIsCustom()
156
+ {
157
+ $this->getProductUnit();
158
+ return $this->_productUnitIsCustom;
159
+ }
160
+
161
+ /**
162
+ * Get is export includes product image gallery
163
+ * @return bool
164
+ */
165
+ public function getInclProductGallery()
166
+ {
167
+ $this->getProductConfig();
168
+ if( !is_null($this->_productConfig['gallery']) ) return $this->_productConfig['gallery'];
169
+ else return false;
170
+ }
171
+
172
+ /**
173
+ * Get extension categories configuration
174
+ * @return mixed
175
+ */
176
+ public function getCategoryConfig()
177
+ {
178
+ $this->_categoryConfig = Mage::getStoreConfig('shopdash/category');
179
+ return $this->_categoryConfig;
180
+ }
181
+
182
+ /**
183
+ * Get extension category ids configuration
184
+ * @return array|null
185
+ */
186
+ public function getCategoryIdsConfig()
187
+ {
188
+ $this->getCategoryConfig();
189
+ if( !is_null($this->_categoryConfig) && !$this->_categoryConfig['category_all'] ) {
190
+ $category_ids = explode(',', $this->_categoryConfig['category_ids']);
191
+
192
+ return $category_ids;
193
+ }
194
+ else return null;
195
+ }
196
+
197
+ /**
198
+ * Get if item category ids are in extension config category ids
199
+ * @param $itemCategoryIds
200
+ * @return bool
201
+ */
202
+ public function getInSelectedCategory($itemCategoryIds)
203
+ {
204
+ if( is_null($itemCategoryIds) || empty($itemCategoryIds) ) return false;
205
+
206
+ $configCategoryIds = $this->getCategoryIdsConfig();
207
+ if( !is_null($configCategoryIds) ) {
208
+
209
+ $result = false;
210
+
211
+ foreach($itemCategoryIds as $categoryId) {
212
+ if( in_array($categoryId, $configCategoryIds) ) {
213
+ $result = true;
214
+ break;
215
+ }
216
+ }
217
+
218
+ return $result;
219
+ }
220
+ else return true;
221
+ }
222
+
223
+ /**
224
+ * Get base deal configuration
225
+ * @return mixed|null
226
+ */
227
+ public function getBaseDeal()
228
+ {
229
+ $this->_deal = $this->getDealsConfig();
230
+
231
+ if( $this->_deal['deal_enable'] ) {
232
+ unset($this->_deal['deal_enable']);
233
+
234
+ return $this->_deal;
235
+ }
236
+ else {
237
+ $this->_deal = null;
238
+ }
239
+ }
240
+
241
+ /**
242
+ * Get deal attributes for select
243
+ * @return array|null
244
+ */
245
+ public function prepareDealAttributes()
246
+ {
247
+ $this->getBaseDeal();
248
+ if( !is_null( $this->_deal ) ) {
249
+
250
+ if( array_key_exists('name_custom', $this->_deal) && empty($this->_deal['name']) ) {
251
+ $this->_deal['name'] = $this->_deal['name_custom'];
252
+ }
253
+
254
+ $dealAttributes = $this->_deal;
255
+ unset($dealAttributes['priority']);
256
+
257
+ return $dealAttributes;
258
+ }
259
+ else return null;
260
+ }
261
+
262
+ /**
263
+ * Extension logging
264
+ * @param $msg
265
+ */
266
+ public function setLog($msg)
267
+ {
268
+ if( is_array($msg) ) {
269
+ foreach($msg as $message) {
270
+ Mage::log($this->__($message), null, $this->_log);
271
+ }
272
+ }
273
+ elseif(is_string($msg) ) {
274
+ Mage::log($this->__($msg), null, $this->_log);
275
+ }
276
+ else {
277
+ Mage::log($msg, null, $this->_log);
278
+ }
279
+ }
280
+ }
app/code/community/Me/Shopdash/Model/Mysql4/Shopdash.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Model_Mysql4_Shopdash extends Mage_Core_Model_Mysql4_Abstract
10
+ {
11
+ public function _construct()
12
+ {
13
+ $this->_init('me_shopdash/shopdash', 'shopdash_id');
14
+ }
15
+ }
app/code/community/Me/Shopdash/Model/Mysql4/Shopdash/Collection.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Model_Mysql4_Shopdash_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
10
+ {
11
+ public function _construct()
12
+ {
13
+ parent::_construct();
14
+ $this->_init('me_shopdash/shopdash');
15
+ }
16
+ }
app/code/community/Me/Shopdash/Model/Shopdash.php ADDED
@@ -0,0 +1,446 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Model_Shopdash extends Mage_Core_Model_Abstract
10
+ {
11
+ /**
12
+ *
13
+ */
14
+ public function _construct()
15
+ {
16
+ parent::_construct();
17
+ $this->_init('me_shopdash/shopdash');
18
+ }
19
+
20
+ /**
21
+ * Feed file path
22
+ * @var
23
+ */
24
+ protected $_filePath;
25
+
26
+ /**
27
+ * Feed file name
28
+ * @var
29
+ */
30
+ protected $_fileName;
31
+
32
+ /**
33
+ * Start export for each store
34
+ */
35
+ public function startExport()
36
+ {
37
+ $_helper = $this->_getHelper();
38
+
39
+ if( !$_helper->getBaseConfigByVar('enable') ) {
40
+ $_helper->setLog('ShopDash extension is disbaled.');
41
+ return;
42
+ }
43
+
44
+ $allStores = Mage::app()->getStores();
45
+ foreach($allStores as $store) {
46
+ $this->_generateXml($store->getId());
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Get extension helper
52
+ * @return Mage_Core_Helper_Abstract
53
+ */
54
+ protected function _getHelper()
55
+ {
56
+ return Mage::helper('me_shopdash');
57
+ }
58
+
59
+ /**
60
+ * Get path for export file
61
+ * @return mixed
62
+ */
63
+ protected function _getPath()
64
+ {
65
+ if (is_null($this->_filePath)) {
66
+ $this->_filePath = str_replace('//', '/', Mage::getBaseDir() . $this->_getHelper()->getBaseConfigByVar('path'));
67
+ }
68
+ return $this->_filePath;
69
+ }
70
+
71
+ /**
72
+ * Get export file name
73
+ * @return mixed
74
+ */
75
+ protected function _getFilename()
76
+ {
77
+ if (is_null($this->_fileName)) {
78
+ $this->_fileName = $this->_getHelper()->getBaseConfigByVar('filename');
79
+ }
80
+ return $this->_fileName;
81
+ }
82
+
83
+ /**
84
+ * Generate XML for defined store
85
+ * @param $store_id
86
+ * @return $this
87
+ */
88
+ protected function _generateXml($store_id)
89
+ {
90
+ $store = Mage::app()->getStore($store_id);
91
+
92
+ $_helper = $this->_getHelper();
93
+ $_taxHelper = Mage::helper('tax');
94
+ $_coreHelper = Mage::helper('core');
95
+
96
+ // website price inculdes tax
97
+ $_inclTax = $_taxHelper->priceIncludesTax($store);
98
+
99
+ //config values
100
+ $baseUrl = Mage::app()->getStore($store_id)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
101
+
102
+ $collection = Mage::getModel('me_shopdash/shopdash_catalog_product')->getStoreCollection($store_id);
103
+
104
+ if( !$collection->count() ) {
105
+ $_helper->setLog('Store Id: ' . $store_id . ' Product collection empty.');
106
+ return;
107
+ }
108
+
109
+ //category array
110
+ $categoryPathes = $this->_getCategoryPathes($store_id);
111
+
112
+ if( !count($categoryPathes) ) {
113
+ $_helper->setLog('Category pathes empty.');
114
+ return;
115
+ }
116
+
117
+ $io = new Varien_Io_File();
118
+ $io->setAllowCreateFolders(true);
119
+ $io->open(array('path' => $this->_getPath()));
120
+
121
+ if ( $io->fileExists('store' . $store_id . '_' . $this->_getFilename()) && !$io->isWriteable('store' . $store_id . '_' . $this->_getFilename()) ) {
122
+ $this->_getHelper()->setLog('Permission error, unable to write export file');
123
+ }
124
+
125
+ $io->streamOpen('store' . $store_id . '_' . $this->_getFilename());
126
+
127
+ $io->streamWrite('<?xml version="1.0" encoding="UTF-8"?>' . "\n");
128
+ $io->streamWrite('<catalog>');
129
+
130
+ foreach ($collection as $item) {
131
+
132
+ // check selected category ids
133
+ if( !$_helper->getInSelectedCategory( $item->getCategoryIds() ) ) continue;
134
+
135
+ //get prices
136
+ $_finalPriceInclTax = $this->_getFinalPrice($item, $item->getPrice(), $_taxHelper, $store, $_inclTax);
137
+
138
+ $xml = sprintf('<product><id>%s</id><name><![CDATA[%s]]></name><price>%s</price><category>%s</category><url><![CDATA[%s]]></url><description><![CDATA[%s]]></description>%s%s%s%s</product>',
139
+ $item->getEntityId(), // id
140
+ $_coreHelper->stripTags($item->getName(), null, true), // name
141
+ round($_finalPriceInclTax, 2), // price
142
+ $this->_getCategoryPathById($categoryPathes, $item->getCategoryIds()), // category
143
+ $baseUrl . $item->getUrlPath(), // url
144
+ $_coreHelper->stripTags($item->getDescription(), null, true), // description
145
+ $this->getImages($item, $baseUrl), // images
146
+ $this->_getDeal($item, $_taxHelper, $store, $_inclTax), // deal
147
+ $this->_getUnit($item), // unit
148
+ $this->_getProperties($item, $_coreHelper) // properties
149
+ );
150
+
151
+ $io->streamWrite($xml);
152
+ }
153
+ unset($collection);
154
+
155
+ $io->streamWrite('</catalog>');
156
+ $io->streamClose();
157
+
158
+ return $this;
159
+ }
160
+
161
+ /**
162
+ * Get item properties
163
+ * @param Mage_Catalog_Model_Product $item
164
+ * @param $_coreHelper
165
+ * @return string
166
+ */
167
+ protected function _getProperties($item, $_coreHelper)
168
+ {
169
+ $_properties = '';
170
+ $propertyRow = '';
171
+
172
+ $properties = $this->_getHelper()->getProperties();
173
+ foreach($properties as $attribute) {
174
+
175
+ $itemProperty = $item->getData($attribute);
176
+
177
+ if( !is_null( $itemProperty ) ) {
178
+
179
+ if( $item->getAttributeText($attribute) ) $value = $item->getAttributeText($attribute);
180
+ else $value = $item->getData($attribute);
181
+
182
+ if( is_array( $value ) ) { // if multiselect attaribute
183
+
184
+ $_multiValues = implode(',', $value);
185
+
186
+ $propertyRow .= sprintf('<property name="%s"><![CDATA[%s]]></property>',
187
+ $_coreHelper->stripTags($attribute, null, true),
188
+ $_coreHelper->stripTags(trim($_multiValues), null, true)
189
+ );
190
+ }
191
+ else {
192
+ $propertyRow .= sprintf('<property name="%s"><![CDATA[%s]]></property>',
193
+ $_coreHelper->stripTags($attribute, null, true),
194
+ $_coreHelper->stripTags(trim($value), null, true)
195
+ );
196
+ }
197
+ }
198
+
199
+ }
200
+
201
+ if( $item->getTypeId() == 'configurable' ) {
202
+
203
+ $confAttributes = $item->getTypeInstance(true)->getConfigurableAttributesAsArray($item);
204
+ if( !empty($confAttributes) ) {
205
+ foreach($confAttributes as $confAttribute) {
206
+
207
+ $_values = '';
208
+ $i = 1;
209
+ $cnt = count($confAttribute['values']);
210
+
211
+ foreach($confAttribute['values'] as $confValue) {
212
+ if( $i != $cnt ) $_values .= trim($confValue['store_label']) . '|';
213
+ else $_values .= trim($confValue['store_label']);
214
+ $i++;
215
+ }
216
+
217
+ $propertyRow .= sprintf('<property name="%s" required="required"><![CDATA[%s]]></property>',
218
+ $_coreHelper->stripTags($confAttribute['frontend_label'], null, true),
219
+ $_coreHelper->stripTags(trim($_values), null, true)
220
+ );
221
+
222
+ }
223
+ }
224
+
225
+ }
226
+
227
+ if( $item->getHasOptions() && $item->getRequiredOptions() ) {
228
+
229
+ $productCustomOptions = $item->getProductOptionsCollection();
230
+
231
+ if( !empty($productCustomOptions) ) {
232
+
233
+ foreach ($productCustomOptions as $options) {
234
+
235
+ if( $options->getIsRequire() ) {
236
+
237
+ $values = array();
238
+
239
+ foreach($options->getValues() as $value) {
240
+ $values[$value->getId()] = $value->getStoreTitle() ? $value->getStoreTitle() : $value->getTitle();
241
+ }
242
+
243
+ $result[] = array(
244
+ 'option_id' => $options->getId(),
245
+ 'title' => $options->getTitle(),
246
+ 'values' => $values
247
+ );
248
+
249
+ $propertyRow .= sprintf('<property name="%s" required="required"><![CDATA[%s]]></property>',
250
+ $_coreHelper->stripTags($options->getTitle(), null, true),
251
+ $_coreHelper->stripTags(implode('|', $values), null, true)
252
+ );
253
+
254
+ }
255
+
256
+ }
257
+
258
+ }
259
+
260
+ }
261
+
262
+ if( $propertyRow ) $_properties = sprintf('<properties>%s</properties>', $propertyRow);
263
+
264
+ return $_properties;
265
+ }
266
+
267
+ /**
268
+ * Get item's images
269
+ * @param Mage_Catalog_Model_Product $item
270
+ * @param string $baseUrl
271
+ * @return string
272
+ */
273
+ protected function getImages($item, $baseUrl)
274
+ {
275
+ $_images = '';
276
+
277
+ if( !Mage::helper('me_shopdash')->getInclProductGallery() ) {
278
+ $_images = sprintf('<images><image><![CDATA[%s]]></image></images>',
279
+ $baseUrl . 'media/catalog/product' . $item->getImage()
280
+ );
281
+ }
282
+ else {
283
+ $images = $item->getData('media_gallery');
284
+ if( isset($images['images']) && count($images['images']) > 0 ) {
285
+
286
+ if( count($images['images']) > 1 ) {
287
+ $imageRow = '';
288
+
289
+ foreach($images['images'] as $image) {
290
+ $imageRow .= sprintf('<image><![CDATA[%s]]></image>',
291
+ $baseUrl . 'media/catalog/product' . $image['file']
292
+ );
293
+ }
294
+
295
+ $_images = sprintf('<images>%s</images>', $imageRow);
296
+
297
+ }
298
+ else {
299
+ $_images = sprintf('<images><image><![CDATA[%s]]></image></images>',
300
+ $baseUrl . 'media/catalog/product' . $item->getImage()
301
+ );
302
+ }
303
+
304
+ }
305
+ }
306
+
307
+ return $_images;
308
+ }
309
+
310
+ /**
311
+ * Get item's unit
312
+ * @param Mage_Catalog_Model_Product $item
313
+ * @return string
314
+ */
315
+ protected function _getUnit($item)
316
+ {
317
+ $_helper = $this->_getHelper();
318
+ $_unit = '';
319
+
320
+ if( !$_helper->getProductUnitIsCustom() ) $unit = $item->getData( $_helper->getProductUnit() );
321
+ else $unit = $_helper->getProductUnit();
322
+
323
+ $_unit = sprintf('<unit_of_quantity><![CDATA[%s]]></unit_of_quantity>',
324
+ Mage::helper('core')->stripTags($unit, null, true)
325
+ );
326
+
327
+ return $_unit;
328
+ }
329
+
330
+ /**
331
+ * Get item's deal
332
+ * @param Mage_Catalog_Model_Product $item
333
+ * @param Mage_Tax_Helper_Data $_taxHelper
334
+ * @param Mage_Core_Model_Store $store
335
+ * @param boolean $_inclTax
336
+ * @return string
337
+ */
338
+ protected function _getDeal($item, $_taxHelper, $store, $_inclTax)
339
+ {
340
+ $dealConfig = $this->_getHelper()->getBaseDeal();
341
+ $price = $item->getData( $dealConfig['price'] );
342
+ if( isset($dealConfig['name']) && !empty($dealConfig['name']) ) $name = $item->getData( $dealConfig['name'] );
343
+ else $name = $dealConfig['name_custom'];
344
+
345
+ if( !is_null($dealConfig) && !is_null($price) && !is_null($name)) {
346
+ $_dealItem = sprintf('<deal><name><![CDATA[%s]]></name><priority><![CDATA[%s]]></priority><price>%s</price></deal>',
347
+ Mage::helper('core')->stripTags($name, null, true),
348
+ $dealConfig['priority'],
349
+ $this->_getFinalPrice($item, $price, $_taxHelper, $store, $_inclTax)
350
+ );
351
+
352
+ return $_dealItem;
353
+ }
354
+ else return '';
355
+ }
356
+
357
+ /**
358
+ * Get item final price with tax
359
+ * @param Mage_Catalog_Model_Product $item
360
+ * @param float price
361
+ * @param Mage_Tax_Helper_Data $_taxHelper
362
+ * @param Mage_Core_Model_Store $store
363
+ * @param boolean $_inclTax
364
+ * @return float
365
+ */
366
+ protected function _getFinalPrice($item, $price, $_taxHelper, $store, $_inclTax)
367
+ {
368
+ if( !$_inclTax ) {
369
+ $_finalPrice = $store->convertPrice($price, null);
370
+ return $_taxHelper->getPrice($item, $_finalPrice, true, null, null, null, $store, null);
371
+ }
372
+ else {
373
+ return $store->convertPrice($price, null);
374
+ }
375
+ }
376
+
377
+ /**
378
+ * Get category pathes by category id
379
+ * @param $categoryPathes
380
+ * @param $category_ids
381
+ * @return string
382
+ */
383
+ protected function _getCategoryPathById($categoryPathes, $category_ids)
384
+ {
385
+ $categoryPath = '';
386
+ foreach($category_ids as $id) {
387
+ if( isset($categoryPathes[$id]) ) $categoryPath = $categoryPathes[$id];
388
+ }
389
+
390
+ return $categoryPath;
391
+ }
392
+
393
+ /**
394
+ * Get all category pathes
395
+ * @param $store_id
396
+ * @return array
397
+ */
398
+ protected function _getCategoryPathes($store_id)
399
+ {
400
+ $categoryPathes = array();
401
+ $categoriesArray = $this->_getCategoriesArray($store_id);
402
+
403
+ foreach($categoriesArray as $key => $category) {
404
+
405
+ $categoryPath = '';
406
+
407
+ $pathArray = explode('/', $category['path']);
408
+ $lastId = end($pathArray);
409
+ foreach($pathArray as $id) {
410
+ if( $id != $lastId ) $categoryPath .= $categoriesArray[$id]['name'] . ' / ';
411
+ else $categoryPath .= $categoriesArray[$id]['name'];
412
+ }
413
+
414
+ $categoryPathes[$key] = $categoryPath;
415
+ }
416
+
417
+ return $categoryPathes;
418
+ }
419
+
420
+ /**
421
+ * Get categories by store
422
+ * @param $store_id
423
+ * @return array
424
+ */
425
+ protected function _getCategoriesArray($store_id)
426
+ {
427
+ $categoriesArray = array();
428
+
429
+ $storecategoryid = Mage::app()->getStore($store_id)->getRootCategoryId();
430
+ $storeRootCategoryPath = Mage::getModel('catalog/category')->load( $storecategoryid )->getPath();
431
+
432
+ $categoriesCollection = Mage::getModel('catalog/category')->getCollection()
433
+ ->addAttributeToSelect('name')
434
+ ->addPathsFilter($storeRootCategoryPath . '/');
435
+
436
+ $selectedCategoryIds = Mage::helper('me_shopdash')->getCategoryIdsConfig();
437
+ if( $selectedCategoryIds ) $categoriesCollection->addAttributeToFilter('entity_id', array('in', $selectedCategoryIds));
438
+
439
+ foreach($categoriesCollection as $category) {
440
+ $categoriesArray[$category->getId()]['name'] = htmlspecialchars($category->getName());
441
+ $categoriesArray[$category->getId()]['path'] = str_replace($storeRootCategoryPath . '/', '', $category->getPath());
442
+ }
443
+
444
+ return $categoriesArray;
445
+ }
446
+ }
app/code/community/Me/Shopdash/Model/Shopdash/Catalog/Product.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Model_Shopdash_Catalog_Product extends Mage_Core_Model_Abstract
10
+ {
11
+ protected $_productCollection;
12
+
13
+ /**
14
+ * @param int $store_id
15
+ * @param null $attributes
16
+ * @return Mage_Catalog_Model_Resource_Product_Collection | null
17
+ */
18
+ public function getStoreCollection($store_id, $attributes = null)
19
+ {
20
+ $productCollection = $this->_getProductCollection($store_id);
21
+
22
+ $productCollection->load();
23
+
24
+ return $productCollection;
25
+ }
26
+
27
+ /**
28
+ * Get base products collection
29
+ * @param int $store_id
30
+ * @return Mage_Catalog_Model_Resource_Product_Collection | null
31
+ */
32
+ protected function _getProductCollection($store_id)
33
+ {
34
+ $_helper = Mage::helper('me_shopdash');
35
+ $store = Mage::app()->getStore($store_id);
36
+
37
+ if (!$store) {
38
+ return false;
39
+ }
40
+
41
+ if ( is_null($this->_productCollection) ) {
42
+
43
+ $this->_productCollection = Mage::getModel('catalog/product')->getCollection()
44
+ ->setStoreId($store_id)
45
+ ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
46
+ ->addAttributeToFilter('visibility', array('neq' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE))
47
+ ->addAttributeToFilter('type_id', array('in' => Mage::helper('me_shopdash')->getBaseProductTypes()));
48
+
49
+ $product_ids = $this->_getShopdashProductIds($store_id);
50
+ if( !is_null($product_ids) && count($product_ids) > 0 ) $this->_productCollection->addAttributeToFilter('entity_id', array('in' => $product_ids));
51
+
52
+ // add deal attributes to select
53
+ if( $dealAttributes = $_helper->prepareDealAttributes() ) {
54
+
55
+ if( isset($dealAttributes['name_custom']) && $dealAttributes['name_custom'] != $dealAttributes['name'] ) {
56
+ $this->_productCollection->addAttributeToSelect( $dealAttributes );
57
+ }
58
+ else {
59
+ $this->_productCollection->addAttributeToSelect( $dealAttributes['price'] );
60
+ }
61
+ }
62
+
63
+ // add properties attributes to select
64
+ if( count( $_helper->getProperties() ) > 0 ) $this->_productCollection->addAttributeToSelect( $_helper->getProperties() );
65
+
66
+ // add unit attributes to select
67
+ if( !$_helper->getProductUnitIsCustom() ) $this->_productCollection->addAttributeToSelect( $_helper->getProductUnit() );
68
+
69
+ // add base attributes to select
70
+ $this->_addProductAttributesAndPrices($this->_productCollection);
71
+
72
+ // add media gallery images to select
73
+ if( $_helper->getInclProductGallery() ) $this->_addMediaGallery($this->_productCollection);
74
+
75
+ }
76
+
77
+ return $this->_productCollection;
78
+ }
79
+
80
+ /**
81
+ * Add attributes to collection
82
+ * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
83
+ * @return Mage_Catalog_Model_Resource_Product_Collection
84
+ */
85
+ protected function _addProductAttributesAndPrices(Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection)
86
+ {
87
+ return $collection
88
+ ->addMinimalPrice()
89
+ ->addFinalPrice()
90
+ ->addAttributeToSelect( Mage::helper('me_shopdash')->getBaseAttributes() ) //TODO: check url_path
91
+ ->addUrlRewrite();
92
+ }
93
+
94
+ /**
95
+ * Add media gallery images to collection
96
+ * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
97
+ * @return Mage_Catalog_Model_Resource_Product_Collection
98
+ */
99
+ protected function _addMediaGallery(Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection)
100
+ {
101
+ if( !is_null($collection) ) {
102
+ $backendModel = $collection->getResource()->getAttribute('media_gallery')->getBackend();
103
+ foreach($collection as $product){
104
+ $backendModel->afterLoad($product);
105
+ }
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Get export product ids by store
111
+ * @param $store_id
112
+ * @return array|null
113
+ */
114
+ protected function _getShopdashProductIds($store_id)
115
+ {
116
+ if( $store_id ) {
117
+
118
+ $shopDashCollection = Mage::getModel('me_shopdash/shopdash')->getCollection()
119
+ ->addFieldToFilter('store_id', $store_id);
120
+
121
+ if( $shopDashCollection->count() ) {
122
+
123
+ $productIds = array();
124
+
125
+ foreach($shopDashCollection as $shopdash) {
126
+ $productIds[] = $shopdash->getProductId();
127
+ }
128
+
129
+ return $productIds;
130
+
131
+ }
132
+ else return null;
133
+
134
+ }
135
+ else return null;
136
+ }
137
+ }
app/code/community/Me/Shopdash/Model/System/Config/Backend/Shopdash/Cron.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Model_System_Config_Backend_Shopdash_Cron extends Mage_Core_Model_Config_Data
10
+ {
11
+ const CRON_STRING_PATH = 'crontab/jobs/me_shopdash_export/schedule/cron_expr';
12
+ const CRON_MODEL_PATH = 'crontab/jobs/me_shopdash_export/run/model';
13
+
14
+ protected function _beforeSave()
15
+ {
16
+ $time = $this->getValue();;
17
+
18
+ $cronExprArray = array(
19
+ intval($time[1]), // Minute
20
+ intval($time[0]), // Hour
21
+ '*', // Day of the Month
22
+ '*', // Month of the Year
23
+ '*', // Day of the Week
24
+ );
25
+
26
+ $cronExprString = join(' ', $cronExprArray);
27
+
28
+ try {
29
+ Mage::getModel('core/config_data')
30
+ ->load(self::CRON_STRING_PATH, 'path')
31
+ ->setValue($cronExprString)
32
+ ->setPath(self::CRON_STRING_PATH)
33
+ ->save();
34
+ Mage::getModel('core/config_data')
35
+ ->load(self::CRON_MODEL_PATH, 'path')
36
+ ->setValue((string) Mage::getConfig()->getNode(self::CRON_MODEL_PATH))
37
+ ->setPath(self::CRON_MODEL_PATH)
38
+ ->save();
39
+ } catch (Exception $e) {
40
+ throw new Exception(Mage::helper('me_shopdash')->__('Unable to save the cron expression.'));
41
+ }
42
+ }
43
+ }
app/code/community/Me/Shopdash/Model/System/Config/Source/Attributes.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Model_System_Config_Source_Attributes
10
+ {
11
+ public function toOptionArray()
12
+ {
13
+ $options = array();
14
+
15
+ $collection = Mage::getResourceModel('catalog/product_attribute_collection')
16
+ ->addVisibleFilter();
17
+
18
+ $options[] = array('value' => '', 'label' => Mage::helper('me_shopdash')->__('Please select...'));
19
+ foreach($collection as $attribute) {
20
+ $options[] = array('value' => $attribute->getAttributeCode(), 'label' => $attribute->getFrontendLabel());
21
+ }
22
+
23
+ return $options;
24
+ }
25
+ }
app/code/community/Me/Shopdash/Model/System/Config/Source/Category.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Model_System_Config_Source_Category
10
+ {
11
+ public function toOptionArray($addEmpty = false)
12
+ {
13
+ $options = $this->getTree();
14
+
15
+ return $options;
16
+ }
17
+
18
+ protected function _prepareMultiselect(Varien_Data_Tree_Node $node, $values, $level = 0)
19
+ {
20
+ $level++;
21
+ $nonEscapableNbspChar = html_entity_decode('&#160;', ENT_NOQUOTES, 'UTF-8');
22
+
23
+ $values[$node->getId()]['value'] = $node->getId();
24
+ $values[$node->getId()]['label'] = str_repeat($nonEscapableNbspChar, ($level - 1) * 4) . $node->getName();
25
+
26
+ foreach ($node->getChildren() as $child)
27
+ {
28
+ $values = $this->_prepareMultiselect($child, $values, $level);
29
+ }
30
+
31
+ return $values;
32
+ }
33
+
34
+ protected function getTree()
35
+ {
36
+ $store = Mage::app()->getRequest()->getParam('store');
37
+ if( $store ) $rootId = Mage::app()->getStore($store)->getRootCategoryId();
38
+ else $rootId = 1;
39
+
40
+ $tree = Mage::getResourceSingleton('catalog/category_tree')->load();
41
+
42
+ $root = $tree->getNodeById($rootId);
43
+
44
+ if($root && $root->getId() == 1)
45
+ {
46
+ $root->setName(Mage::helper('catalog')->__('Root'));
47
+ }
48
+
49
+ $collection = $tree->getCollection()
50
+ ->addAttributeToSelect('name')
51
+ ->addAttributeToFilter('is_active', 1);
52
+
53
+ $tree->addCollectionData($collection, true);
54
+
55
+ return $this->_prepareMultiselect($root, array());
56
+ }
57
+ }
app/code/community/Me/Shopdash/Model/System/Config/Source/Priceattributes.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Model_System_Config_Source_Priceattributes
10
+ {
11
+ public function toOptionArray()
12
+ {
13
+ $options = array();
14
+
15
+ $collection = Mage::getResourceModel('catalog/product_attribute_collection')
16
+ ->addVisibleFilter();
17
+
18
+ $options[] = array('value' => '', 'label' => Mage::helper('me_shopdash')->__('Please select...'));
19
+ foreach($collection as $attribute) {
20
+ if( $attribute->getFrontendInput() == 'price' ) $options[] = array('value' => $attribute->getAttributeCode(), 'label' => $attribute->getFrontendLabel());
21
+ }
22
+
23
+ return $options;
24
+ }
25
+ }
app/code/community/Me/Shopdash/Model/System/Config/Source/Priority.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Model_System_Config_Source_Priority
10
+ {
11
+ const SMALL = 'small';
12
+ const MEDIUM = 'medium';
13
+ const HUGE = 'huge';
14
+
15
+ /**
16
+ * Get priority values
17
+ * @return array
18
+ */
19
+ public function toOptionArray()
20
+ {
21
+ return array(
22
+ '' => Mage::helper('me_shopdash')->__('Please select...'),
23
+ self::SMALL => Mage::helper('me_shopdash')->__('Small'),
24
+ self::MEDIUM => Mage::helper('me_shopdash')->__('Medium'),
25
+ self::HUGE => Mage::helper('me_shopdash')->__('Huge')
26
+ );
27
+ }
28
+ }
app/code/community/Me/Shopdash/Model/System/Config/Source/Properties.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Model_System_Config_Source_Properties
10
+ {
11
+ public function toOptionArray()
12
+ {
13
+ $options = array();
14
+
15
+ $collection = Mage::getResourceModel('catalog/product_attribute_collection')
16
+ ->addVisibleFilter();
17
+
18
+ foreach($collection as $attribute) {
19
+ if( !in_array($attribute->getAttributeCode(), Mage::helper('me_shopdash')->getBaseAttributes()) && !in_array($attribute->getAttributeCode(), Mage::helper('me_shopdash')->getRemovedAttributes()) ) $options[] = array('value' => $attribute->getAttributeCode(), 'label' => $attribute->getFrontendLabel());
20
+ }
21
+
22
+ return $options;
23
+ }
24
+ }
app/code/community/Me/Shopdash/Model/System/Config/Source/Redirect.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Model_System_Config_Source_Redirect
10
+ {
11
+ /**
12
+ * Get priority values
13
+ * @return array
14
+ */
15
+ public function toOptionArray()
16
+ {
17
+ return array(
18
+ 0 => Mage::helper('me_shopdash')->__('Shopping Cart'),
19
+ 1 => Mage::helper('me_shopdash')->__('Checkout')
20
+ );
21
+ }
22
+ }
app/code/community/Me/Shopdash/Model/System/Config/Source/Textattributes.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Model_System_Config_Source_Textattributes
10
+ {
11
+ public function toOptionArray()
12
+ {
13
+ $options = array();
14
+
15
+ $collection = Mage::getResourceModel('catalog/product_attribute_collection')
16
+ ->addVisibleFilter();
17
+
18
+ $options[] = array('value' => '', 'label' => Mage::helper('me_shopdash')->__('Please select...'));
19
+ foreach($collection as $attribute) {
20
+ if( $attribute->getFrontendInput() == 'textarea' || $attribute->getFrontendInput() == 'text' ) $options[] = array('value' => $attribute->getAttributeCode(), 'label' => $attribute->getFrontendLabel());
21
+ }
22
+
23
+ return $options;
24
+ }
25
+ }
app/code/community/Me/Shopdash/controllers/AddController.php ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_AddController extends Mage_Core_Controller_Front_Action
10
+ {
11
+ /**
12
+ * Dummy post data for testing with Magento Sample Data
13
+ * @var array
14
+ */
15
+ protected $_dummyPost = array(
16
+ 'products' => array(
17
+ array( // simple product
18
+ 'product_id' => 16,
19
+ 'amount' => 1,
20
+ 'attributes' => array()
21
+ ),
22
+ array( // simple product
23
+ 'product_id' => 17,
24
+ 'amount' => 3,
25
+ 'attributes' => array()
26
+ ),
27
+ array( // configurable product
28
+ 'product_id' => 83,
29
+ 'amount' => 1,
30
+ 'attributes' => array(
31
+ 'Gender' => 'Mens',
32
+ 'Shoe Size' => '12'
33
+ )
34
+ ),
35
+ array( // simple product custom options
36
+ 'product_id' => 171,
37
+ 'amount' => 1,
38
+ 'attributes' => array(
39
+ 'Brand' => 'LG',
40
+ 'Color' => 'Blue'
41
+ ),
42
+ ),
43
+ )
44
+ );
45
+
46
+ /**
47
+ * Retrieve shopping cart model object
48
+ * @return Mage_Checkout_Model_Cart
49
+ */
50
+ protected function _getCart()
51
+ {
52
+ return Mage::getModel('checkout/cart');
53
+ }
54
+
55
+ /**
56
+ * Get checkout session model instance
57
+ * @return Mage_Checkout_Model_Session
58
+ */
59
+ protected function _getSession()
60
+ {
61
+ return Mage::getSingleton('checkout/session');
62
+ }
63
+
64
+ /**
65
+ * Initialize product instance from request data
66
+ * @param productId
67
+ * @return Mage_Catalog_Model_Product || false
68
+ */
69
+ protected function _initProduct($productId)
70
+ {
71
+ if ($productId) {
72
+ $product = Mage::getModel('catalog/product')
73
+ ->setStoreId(Mage::app()->getStore()->getId())
74
+ ->load($productId);
75
+ if ($product->getId()) {
76
+ return $product;
77
+ }
78
+ }
79
+ return false;
80
+ }
81
+
82
+ /**
83
+ * Get url action
84
+ */
85
+ public function indexAction()
86
+ {
87
+ $_helper = Mage::helper('me_shopdash');
88
+ $post = $this->getRequest()->getPost();
89
+
90
+ // dummy post for testing
91
+ //$post = $this->_dummyPost;
92
+
93
+ if( $post ) {
94
+
95
+ if( isset($post['products']) ) {
96
+ $answer = $this->_getAnswer($post['products']);
97
+ if( !is_null($answer) ) $answerUrl = Mage::getUrl('shopdash/add/addtocart', array('code' => $answer));
98
+ else {
99
+ $_helper->setLog('Invalid request.');
100
+ $_helper->setLog($post);
101
+ }
102
+ }
103
+ else {
104
+ $_helper->setLog('Invalid request.');
105
+ $_helper->setLog($post);
106
+ }
107
+ }
108
+
109
+ Mage::app()->getResponse()->setBody($answerUrl);
110
+ }
111
+
112
+ /**
113
+ * Add to cart action
114
+ */
115
+ public function addtocartAction()
116
+ {
117
+ $_helper = Mage::helper('me_shopdash');
118
+
119
+ $params = $this->getRequest()->getParams();
120
+
121
+ if( $params ) {
122
+
123
+ parse_str( $params['code'], $data);
124
+
125
+ if( !is_null($data) && is_array($data) ) {
126
+
127
+ try {
128
+
129
+ foreach($data as $item) {
130
+
131
+ $cart = $this->_getCart();
132
+
133
+ if( !isset($item['amount']) || !isset($item['product_id']) ) {
134
+ throw new Exception($_helper->__('ShopDash: Cannot add the item to shopping cart.'));
135
+ }
136
+
137
+ $addParams['qty'] = (int)$item['amount'];
138
+ $addParams['product'] = (int)$item['product_id'];
139
+ if( isset($item['attributes']) ) $addParams['attributes'] = $item['attributes'];
140
+
141
+ if (isset($addParams['qty'])) {
142
+ $filter = new Zend_Filter_LocalizedToNormalized(
143
+ array('locale' => Mage::app()->getLocale()->getLocaleCode())
144
+ );
145
+ $addParams['qty'] = $filter->filter($addParams['qty']);
146
+ }
147
+
148
+ $product = $this->_initProduct($addParams['product']);
149
+
150
+ /**
151
+ * Check product availability
152
+ */
153
+ if (!$product) {
154
+ $this->_getSession()->addError($_helper->__('Cannot add the item to shopping cart.'));
155
+ $this->_redirect('checkout/cart');
156
+ return;
157
+ }
158
+
159
+ if( $product->getTypeId() == 'configurable' ) {
160
+ $addParams = $this->_getConfigurableAttributes($product, $item);
161
+ if( is_null($params) ) {
162
+ $this->_getSession()->addError($_helper->__('Cannot add configurable item to shopping cart.'));
163
+ $this->_redirect('checkout/cart');
164
+ return;
165
+ }
166
+ }
167
+
168
+ if( $product->getHasOptions() && $product->getRequiredOptions() && !empty($addParams['attributes']) ) {
169
+
170
+ $productCustomOptions = $product->getProductOptionsCollection();
171
+
172
+ if( !empty($productCustomOptions) ) {
173
+
174
+ foreach($productCustomOptions as $options) {
175
+ if( $options->getIsRequire() ) {
176
+
177
+ $values = array();
178
+
179
+ foreach($options->getValues() as $value) {
180
+ $values[$value->getId()] = $value->getStoreTitle() ? $value->getStoreTitle() : $value->getTitle();
181
+ }
182
+
183
+ $result[] = array(
184
+ 'option_id' => $options->getId(),
185
+ 'title' => $options->getTitle(),
186
+ 'values' => $values
187
+ );
188
+
189
+ }
190
+ }
191
+
192
+ foreach($result as $_result) {
193
+ if( array_key_exists($_result['title'], $addParams['attributes']) ) {
194
+ $option[$_result['option_id']] = array_search($addParams['attributes'][$_result['title']], $_result['values']);
195
+ }
196
+ }
197
+
198
+ if( !empty($option) ) {
199
+ $addParams['options'] = $option;
200
+ }
201
+
202
+ if( count($addParams['options']) != count($addParams['attributes']) || in_array(false, $addParams['options']) ) {
203
+ Mage::throwException($_helper->__('Invalid custom option(s): <a href="%s">%s</a>', $product->getProducturl(), $product->getName()));
204
+ }
205
+
206
+ }
207
+ }
208
+
209
+ $cart->addProduct($product, $addParams);
210
+
211
+ $cart->save();
212
+
213
+ $this->_getSession()->setCartWasUpdated(true);
214
+
215
+ }
216
+
217
+ if (!$cart->getQuote()->getHasError()) {
218
+ if( count($data) > 1 ) $message = $_helper->__('Products were added to your shopping cart.');
219
+ else $message = $_helper->__('%s was added to your shopping cart.', Mage::helper('core')->escapeHtml($product->getName()));
220
+ $this->_getSession()->addSuccess($message);
221
+ }
222
+
223
+ } catch (Mage_Core_Exception $e) {
224
+
225
+ if ($this->_getSession()->getUseNotice(true)) {
226
+ $this->_getSession()->addNotice(Mage::helper('core')->escapeHtml($e->getMessage()));
227
+ } else {
228
+ $messages = array_unique(explode("\n", $e->getMessage()));
229
+ foreach ($messages as $message) {
230
+ $this->_getSession()->addError(Mage::helper('core')->__($message));
231
+ }
232
+ }
233
+
234
+ $this->_redirect('checkout/cart');
235
+
236
+ } catch (Exception $e) {
237
+ $this->_getSession()->addException($e, $this->__('Cannot add the item to shopping cart.'));
238
+ Mage::logException($e);
239
+ $this->_redirect('checkout/cart');
240
+ }
241
+
242
+ }
243
+
244
+ }
245
+
246
+ if( $_helper->getBaseConfigByVar('redirect') ) $this->_redirect('checkout/onepage');
247
+ else $this->_redirect('checkout/cart');
248
+ }
249
+
250
+ /**
251
+ * Create URL for answer
252
+ * @param $post
253
+ * @return null|string
254
+ */
255
+ protected function _getAnswer($post)
256
+ {
257
+ $_answerUrl = '';
258
+
259
+ if( is_array($post) && !is_null($post) && !empty($post) ) {
260
+
261
+ $_answerUrl = http_build_query( $post );
262
+
263
+ return $_answerUrl;
264
+ }
265
+ else return null;
266
+ }
267
+
268
+ /**
269
+ * @param Mage_Catalog_Model_Product $product
270
+ * @param array $item
271
+ * @return array|null
272
+ */
273
+ protected function _getConfigurableAttributes($product, $item = array())
274
+ {
275
+ $params = array(
276
+ 'product' => (int)$product->getId(),
277
+ 'qty' => (int)$item['amount'],
278
+ );
279
+
280
+ if( !empty($item['attributes']) ) {
281
+
282
+ $confAttributes = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
283
+
284
+ foreach($confAttributes as $attribute) {
285
+ if( array_key_exists($attribute['frontend_label'], $item['attributes']) ) {
286
+
287
+ foreach($attribute['values'] as $value) {
288
+ if( $value['store_label'] == $item['attributes'][$attribute['frontend_label']] ) $superAttribute[$attribute['attribute_id']] = $value['value_index'];
289
+ }
290
+
291
+ }
292
+ }
293
+
294
+ $params['super_attribute'] = $superAttribute;
295
+
296
+ return $params;
297
+ }
298
+ else return null;
299
+ }
300
+ }
app/code/community/Me/Shopdash/controllers/Adminhtml/ShopdashController.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Me_Shopdash_Adminhtml_ShopdashController extends Mage_Adminhtml_Controller_Action
10
+ {
11
+ /**
12
+ * Init action
13
+ * @return $this
14
+ */
15
+ protected function _initAction()
16
+ {
17
+ // load layout, set active menu and breadcrumbs
18
+ $this->loadLayout()
19
+ ->_setActiveMenu('catalog/shopdash')
20
+ ->_addBreadcrumb(
21
+ Mage::helper('me_shopdash')->__('Catalog'),
22
+ Mage::helper('me_shopdash')->__('Catalog')
23
+ )
24
+ ->_addBreadcrumb(
25
+ Mage::helper('me_shopdash')->__('Manage ShopDash'),
26
+ Mage::helper('me_shopdash')->__('Manage ShopDash')
27
+ )
28
+ ;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Edit action
34
+ */
35
+ public function editAction()
36
+ {
37
+ if (! (int) $this->getRequest()->getParam('store')) {
38
+ Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('me_shopdash')->__('Please click on Reset filter to see the whole list'));
39
+ return $this->_redirect('*/*/*/', array('store' => Mage::app()->getAnyStoreView()->getId(), '_current' => true));
40
+ }
41
+
42
+ $this->_initAction();
43
+
44
+ $this->_title($this->__('Catalog'))
45
+ ->_title($this->__('Manage ShopDash'))
46
+ ->_title($this->__('Manage Export'));
47
+
48
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
49
+
50
+ $this->_addContent($this->getLayout()->createBlock('me_shopdash/adminhtml_shopdash_store_switcher'))
51
+ ->_addContent($this->getLayout()->createBlock('me_shopdash/adminhtml_shopdash_edit'))
52
+ ->_addLeft($this->getLayout()->createBlock('me_shopdash/adminhtml_shopdash_edit_tabs'));
53
+
54
+ $this->renderLayout();
55
+ }
56
+
57
+ /**
58
+ * Save action
59
+ */
60
+ public function saveAction()
61
+ {
62
+ $links = $this->getRequest()->getPost('links');
63
+ $store_id = $this->getRequest()->getParam('store');;
64
+
65
+ if ( isset($links['products']) && !is_null($store_id) && $store_id ) {
66
+
67
+ $productsGrid = Mage::helper('adminhtml/js')->decodeGridSerializedInput($links['products']);
68
+
69
+ try {
70
+
71
+ $shopDashCollection = Mage::getModel('me_shopdash/shopdash')->getCollection()
72
+ ->addFieldToFilter('store_id', $store_id);
73
+ foreach($shopDashCollection as $shopdash) {
74
+ $shopdash->delete();
75
+ }
76
+
77
+ $shopDashCollection->clear();
78
+
79
+ if( !empty($productsGrid) ) {
80
+
81
+ foreach(array_keys($productsGrid) as $productId) {
82
+
83
+ $shopDashModel = Mage::getModel('me_shopdash/shopdash');
84
+
85
+ $shopDashModel->setProductId( $productId );
86
+ $shopDashModel->setStoreId( $store_id );
87
+
88
+ $shopDashCollection->addItem($shopDashModel);
89
+ }
90
+
91
+ $shopDashCollection->save();
92
+
93
+ }
94
+
95
+ $this->_getSession()->addSuccess(Mage::helper('me_shopdash')->__('Export products has been saved.'));
96
+
97
+ } catch (Mage_Core_Exception $e) {
98
+
99
+ $this->_getSession()->addError($e->getMessage());
100
+
101
+ } catch (Exception $e) {
102
+
103
+ $this->_getSession()->addException($e, Mage::helper('me_shopdash')->__('An error occurred while saving the news item.'));
104
+
105
+ }
106
+
107
+ }
108
+ else {
109
+ $this->_getSession()->addError(Mage::helper('me_shopdash')->__('Please select products.'));
110
+ }
111
+
112
+ $this->_redirect('*/*/edit', array('store' => $store_id));
113
+
114
+ }
115
+
116
+ /**
117
+ * Product default grid action
118
+ */
119
+ public function productAction()
120
+ {
121
+ $this->loadLayout();
122
+ $this->getLayout()->getBlock('product.grid')->setProducts($this->getRequest()->getPost('products', null));
123
+ $this->renderLayout();
124
+ }
125
+
126
+ /**
127
+ * Product grid action
128
+ */
129
+ public function productgridAction()
130
+ {
131
+ $this->loadLayout();
132
+ $this->getLayout()->getBlock('product.grid')->setProducts($this->getRequest()->getPost('products', null));
133
+ $this->renderLayout();
134
+ }
135
+
136
+ /**
137
+ * Index action
138
+ */
139
+ public function indexAction()
140
+ {
141
+ $this->_title($this->__('ShopDash'))
142
+ ->_title($this->__('Manage Export'));
143
+
144
+ $this->_initAction();
145
+ $this->renderLayout();
146
+ }
147
+
148
+ /**
149
+ * Run action
150
+ */
151
+ public function runAction()
152
+ {
153
+ try {
154
+ $_helper = Mage::helper(('me_shopdash'));
155
+
156
+ $result = array(
157
+ 'result' => 0,
158
+ 'msg' => ''
159
+ );
160
+
161
+ if( !$_helper->getBaseConfigByVar('enable') ) {
162
+ $_helper->setLog('ShopDash extension is disbaled.');
163
+ $result['result'] = 1;
164
+ }
165
+
166
+ Mage::getModel('me_shopdash/shopdash')->startExport();
167
+ $result['result'] = 1;
168
+ } catch (Mage_Core_Exception $e) {
169
+ $result['result'] = 0;
170
+ $result['msg'] = $e->getMessage();
171
+ } catch (Exception $e) {
172
+ $result['result'] = 0;
173
+ $result['msg'] = $e . Mage::helper('me_shopdash')->__('An error occurred while running export.');
174
+ }
175
+
176
+ Mage::app()->getResponse()->setBody( json_encode($result) );
177
+ }
178
+ }
app/code/community/Me/Shopdash/etc/adminhtml.xml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * @category Me
5
+ * @package Me_Shopdash
6
+ * @author Magevolve Ltd.
7
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ -->
11
+ <config>
12
+ <menu>
13
+ <catalog>
14
+ <children>
15
+ <shopdash translate="title" module="me_shopdash">
16
+ <title>Manage ShopDash</title>
17
+ <children>
18
+ <manage translate="title" module="me_shopdash">
19
+ <title>Manage Export</title>
20
+ <action>me_shopdash/adminhtml_shopdash/edit</action>
21
+ </manage>
22
+ <settings translate="title" module="me_shopdash">
23
+ <title>Settings</title>
24
+ <action>adminhtml/system_config/edit/section/shopdash</action>
25
+ </settings>
26
+ </children>
27
+ <sort_order>60</sort_order>
28
+ </shopdash>
29
+ </children>
30
+ </catalog>
31
+ </menu>
32
+ <acl>
33
+ <resources>
34
+ <all>
35
+ <title>Allow Everything</title>
36
+ </all>
37
+ <admin>
38
+ <children>
39
+ <catalog>
40
+ <children>
41
+ <shopdash translate="title" module="me_shopdash">
42
+ <title>Manage ShopDash</title>
43
+ <children>
44
+ <manage translate="title">
45
+ <title>Manage Export</title>
46
+ </manage>
47
+ <settings translate="title">
48
+ <title>Settings</title>
49
+ </settings>
50
+ </children>
51
+ </shopdash>
52
+ </children>
53
+ </catalog>
54
+ <system>
55
+ <children>
56
+ <config>
57
+ <children>
58
+ <shopdash translate="title" module="me_shopdash">
59
+ <title>ShopDash Magento Extension</title>
60
+ <sort_order>500</sort_order>
61
+ </shopdash>
62
+ <info translate="title" module="me_shopdash">
63
+ <title>ShopDash Magento Extension Informations</title>
64
+ <sort_order>501</sort_order>
65
+ </info>
66
+ <help translate="title" module="me_shopdash">
67
+ <title>ShopDash Magento Extension Help</title>
68
+ <sort_order>502</sort_order>
69
+ </help>
70
+ </children>
71
+ </config>
72
+ </children>
73
+ </system>
74
+ </children>
75
+ </admin>
76
+ </resources>
77
+ </acl>
78
+ </config>
app/code/community/Me/Shopdash/etc/config.xml ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Me
5
+ * @package Me_Shopdash
6
+ * @author Magevolve Ltd.
7
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ -->
11
+ <config>
12
+ <modules>
13
+ <Me_Shopdash>
14
+ <version>1.1.7</version>
15
+ </Me_Shopdash>
16
+ </modules>
17
+ <frontend>
18
+ <routers>
19
+ <me_shopdash>
20
+ <use>standard</use>
21
+ <args>
22
+ <module>Me_Shopdash</module>
23
+ <frontName>shopdash</frontName>
24
+ </args>
25
+ </me_shopdash>
26
+ </routers>
27
+ <translate>
28
+ <modules>
29
+ <Me_Shopdash>
30
+ <files>
31
+ <default>Me_Shopdash.csv</default>
32
+ </files>
33
+ </Me_Shopdash>
34
+ </modules>
35
+ </translate>
36
+ </frontend>
37
+ <admin>
38
+ <routers>
39
+ <adminhtml>
40
+ <args>
41
+ <modules>
42
+ <shopdash after="Mage_Adminhtml">Me_Shopdash</shopdash>
43
+ </modules>
44
+ </args>
45
+ </adminhtml>
46
+ </routers>
47
+ </admin>
48
+ <adminhtml>
49
+ <layout>
50
+ <updates>
51
+ <me_shopdash>
52
+ <file>me_shopdash.xml</file>
53
+ </me_shopdash>
54
+ </updates>
55
+ </layout>
56
+ <translate>
57
+ <modules>
58
+ <Me_Shopdash>
59
+ <files>
60
+ <default>Me_Shopdash.csv</default>
61
+ </files>
62
+ </Me_Shopdash>
63
+ </modules>
64
+ </translate>
65
+ </adminhtml>
66
+ <global>
67
+ <models>
68
+ <me_shopdash>
69
+ <class>Me_Shopdash_Model</class>
70
+ <resourceModel>shopdash_mysql4</resourceModel>
71
+ </me_shopdash>
72
+ <shopdash_mysql4>
73
+ <class>Me_Shopdash_Model_Mysql4</class>
74
+ <entities>
75
+ <shopdash>
76
+ <table>me_shopdash</table>
77
+ </shopdash>
78
+ </entities>
79
+ </shopdash_mysql4>
80
+ </models>
81
+ <resources>
82
+ <me_shopdash_setup>
83
+ <setup>
84
+ <module>Me_Shopdash</module>
85
+ </setup>
86
+ <connection>
87
+ <use>core_setup</use>
88
+ </connection>
89
+ </me_shopdash_setup>
90
+ <shopdash_write>
91
+ <connection>
92
+ <use>core_write</use>
93
+ </connection>
94
+ </shopdash_write>
95
+ <shopdash_read>
96
+ <connection>
97
+ <use>core_read</use>
98
+ </connection>
99
+ </shopdash_read>
100
+ </resources>
101
+ <blocks>
102
+ <me_shopdash>
103
+ <class>Me_Shopdash_Block</class>
104
+ </me_shopdash>
105
+ </blocks>
106
+ <helpers>
107
+ <me_shopdash>
108
+ <class>Me_Shopdash_Helper</class>
109
+ </me_shopdash>
110
+ </helpers>
111
+ </global>
112
+ <crontab>
113
+ <jobs>
114
+ <me_shopdash_export>
115
+ <run>
116
+ <model>me_shopdash/shopdash::startExport</model>
117
+ </run>
118
+ </me_shopdash_export>
119
+ </jobs>
120
+ </crontab>
121
+ <default>
122
+ <shopdash>
123
+ <config>
124
+ <enable>0</enable>
125
+ <filename>shopdash.xml</filename>
126
+ <path>/shopdash_feed</path>
127
+ <empty_cart>0</empty_cart>
128
+ <redirect>0</redirect>
129
+ </config>
130
+ <products>
131
+ <unit_custom>qty</unit_custom>
132
+ <gallery>0</gallery>
133
+ </products>
134
+ <category>
135
+ <category_all>1</category_all>
136
+ </category>
137
+ <deals>
138
+ <deal_enable>0</deal_enable>
139
+ <name_custom>Custom deal name</name_custom>
140
+ </deals>
141
+ </shopdash>
142
+ </default>
143
+ </config>
app/code/community/Me/Shopdash/etc/system.xml ADDED
@@ -0,0 +1,293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Me
5
+ * @package Me_Shopdash
6
+ * @author Magevolve Ltd.
7
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ -->
11
+ <config>
12
+ <tabs>
13
+ <shopdash_tab translate="label" module="me_shopdash">
14
+ <label>ShopDash Extension</label>
15
+ <sort_order>99999</sort_order>
16
+ </shopdash_tab>
17
+ </tabs>
18
+ <sections>
19
+ <shopdash translate="label" module="me_shopdash">
20
+ <label>ShopDash Settings</label>
21
+ <tab>shopdash_tab</tab>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>1000</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <groups>
28
+ <config translate="label">
29
+ <label>ShopDash Export Configuration</label>
30
+ <sort_order>1</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <fields>
35
+ <enable translate="label">
36
+ <label>Enable</label>
37
+ <frontend_type>select</frontend_type>
38
+ <source_model>adminhtml/system_config_source_yesno</source_model>
39
+ <sort_order>1</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>0</show_in_store>
43
+ <comment>Enable module.</comment>
44
+ </enable>
45
+ <filename translate="label">
46
+ <label>Filename</label>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>3</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ <comment>Name of the export file. I.e.: shopdash.xml. The export file name will be storeX_shopdash.xml, where X is the store id.</comment>
53
+ </filename>
54
+ <path translate="label">
55
+ <label>Path</label>
56
+ <frontend_type>text</frontend_type>
57
+ <sort_order>4</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>1</show_in_store>
61
+ <comment>Path to the export file. I.e.: /shopdash_feed.</comment>
62
+ </path>
63
+ <time translate="label">
64
+ <label>Start Time</label>
65
+ <frontend_type>time</frontend_type>
66
+ <sort_order>5</sort_order>
67
+ <backend_model>me_shopdash/system_config_backend_shopdash_cron</backend_model>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ <comment>Daily export schedule. Format: HH:MM:SS.</comment>
72
+ </time>
73
+ <redirect translate="label">
74
+ <label>Redirect</label>
75
+ <frontend_type>select</frontend_type>
76
+ <source_model>me_shopdash/system_config_source_redirect</source_model>
77
+ <sort_order>6</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>1</show_in_store>
81
+ <comment>Redirect to shopping cart or to checkout page.</comment>
82
+ </redirect>
83
+ <run translate="label">
84
+ <label>Run Export Now</label>
85
+ <frontend_type>button</frontend_type>
86
+ <frontend_model>me_shopdash/adminhtml_system_config_form_button</frontend_model>
87
+ <sort_order>7</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>1</show_in_store>
91
+ </run>
92
+ </fields>
93
+ </config>
94
+ <products translate="label">
95
+ <label>Products Configuration</label>
96
+ <sort_order>2</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>1</show_in_store>
100
+ <fields>
101
+ <properties translate="label">
102
+ <label>Product Properties</label>
103
+ <frontend_type>multiselect</frontend_type>
104
+ <source_model>me_shopdash/system_config_source_properties</source_model>
105
+ <sort_order>1</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>1</show_in_store>
109
+ <comment>Please select product's attributes.</comment>
110
+ </properties>
111
+ <unit translate="label">
112
+ <label>Unit of Quantity</label>
113
+ <frontend_type>select</frontend_type>
114
+ <source_model>me_shopdash/system_config_source_textattributes</source_model>
115
+ <sort_order>2</sort_order>
116
+ <show_in_default>1</show_in_default>
117
+ <show_in_website>1</show_in_website>
118
+ <show_in_store>1</show_in_store>
119
+ <comment>Please select unit of quantity attribute.</comment>
120
+ </unit>
121
+ <unit_custom translate="label">
122
+ <label>Custom Unit of Quantity</label>
123
+ <frontend_type>text</frontend_type>
124
+ <sort_order>3</sort_order>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <show_in_store>1</show_in_store>
128
+ <depends>
129
+ <unit></unit>
130
+ </depends>
131
+ <comment>Custom discount name for every products. I.e.: qty, kg, etc.</comment>
132
+ </unit_custom>
133
+ <gallery>
134
+ <label>Include Image Gallery</label>
135
+ <frontend_type>select</frontend_type>
136
+ <source_model>adminhtml/system_config_source_yesno</source_model>
137
+ <sort_order>4</sort_order>
138
+ <show_in_default>1</show_in_default>
139
+ <show_in_website>1</show_in_website>
140
+ <show_in_store>1</show_in_store>
141
+ <comment>The export will include all product images.</comment>
142
+ </gallery>
143
+ </fields>
144
+ </products>
145
+ <category translate="label">
146
+ <label>Category Configuration</label>
147
+ <sort_order>3</sort_order>
148
+ <show_in_default>1</show_in_default>
149
+ <show_in_website>1</show_in_website>
150
+ <show_in_store>1</show_in_store>
151
+ <fields>
152
+ <category_all translate="label">
153
+ <label>Select All Categories</label>
154
+ <frontend_type>select</frontend_type>
155
+ <source_model>adminhtml/system_config_source_yesno</source_model>
156
+ <sort_order>1</sort_order>
157
+ <show_in_default>1</show_in_default>
158
+ <show_in_website>1</show_in_website>
159
+ <show_in_store>1</show_in_store>
160
+ <comment>If set to yes, all categories will be selected.</comment>
161
+ </category_all>
162
+ <category_ids translate="label">
163
+ <label>Selected Categories</label>
164
+ <frontend_type>multiselect</frontend_type>
165
+ <source_model>me_shopdash/system_config_source_category</source_model>
166
+ <sort_order>2</sort_order>
167
+ <show_in_default>1</show_in_default>
168
+ <show_in_website>1</show_in_website>
169
+ <show_in_store>1</show_in_store>
170
+ <comment>Please select categories.</comment>
171
+ <depends>
172
+ <category_all>0</category_all>
173
+ </depends>
174
+ </category_ids>
175
+ </fields>
176
+ </category>
177
+ <deals translate="label">
178
+ <label>Deal Configuration</label>
179
+ <sort_order>4</sort_order>
180
+ <show_in_default>1</show_in_default>
181
+ <show_in_website>1</show_in_website>
182
+ <show_in_store>1</show_in_store>
183
+ <fields>
184
+ <deal_enable translate="label">
185
+ <label>Enable Deal</label>
186
+ <frontend_type>select</frontend_type>
187
+ <source_model>adminhtml/system_config_source_yesno</source_model>
188
+ <sort_order>1</sort_order>
189
+ <show_in_default>1</show_in_default>
190
+ <show_in_website>1</show_in_website>
191
+ <show_in_store>1</show_in_store>
192
+ <comment>Enable deal in export.</comment>
193
+ </deal_enable>
194
+ <name translate="label">
195
+ <label>Deal Name Attribute</label>
196
+ <frontend_type>select</frontend_type>
197
+ <source_model>me_shopdash/system_config_source_textattributes</source_model>
198
+ <sort_order>2</sort_order>
199
+ <show_in_default>1</show_in_default>
200
+ <show_in_website>1</show_in_website>
201
+ <show_in_store>1</show_in_store>
202
+ <comment>Please select deal name attribute.</comment>
203
+ <depends>
204
+ <deal_enable>1</deal_enable>
205
+ </depends>
206
+ </name>
207
+ <name_custom translate="label">
208
+ <label>Custom Deal Name</label>
209
+ <frontend_type>text</frontend_type>
210
+ <sort_order>3</sort_order>
211
+ <show_in_default>1</show_in_default>
212
+ <show_in_website>1</show_in_website>
213
+ <show_in_store>1</show_in_store>
214
+ <comment>Custom discount name for every products. I.e.: Special discount. This will be used if deal name attribute is not set.</comment>
215
+ <depends>
216
+ <deal_enable>1</deal_enable>
217
+ <name></name>
218
+ </depends>
219
+ <validate>required-entry</validate>
220
+ </name_custom>
221
+ <priority translate="label">
222
+ <label>Deal Priority</label>
223
+ <frontend_type>select</frontend_type>
224
+ <source_model>me_shopdash/system_config_source_priority</source_model>
225
+ <sort_order>4</sort_order>
226
+ <show_in_default>1</show_in_default>
227
+ <show_in_website>1</show_in_website>
228
+ <show_in_store>1</show_in_store>
229
+ <comment>Item size in the list. Available values: small, medium, huge.</comment>
230
+ <depends>
231
+ <deal_enable>1</deal_enable>
232
+ </depends>
233
+ <validate>required-entry</validate>
234
+ </priority>
235
+ <price translate="label">
236
+ <label>Deal Price Attribute</label>
237
+ <frontend_type>select</frontend_type>
238
+ <source_model>me_shopdash/system_config_source_priceattributes</source_model>
239
+ <sort_order>5</sort_order>
240
+ <show_in_default>1</show_in_default>
241
+ <show_in_website>1</show_in_website>
242
+ <show_in_store>1</show_in_store>
243
+ <comment>Please select deal price attribute.</comment>
244
+ <depends>
245
+ <deal_enable>1</deal_enable>
246
+ </depends>
247
+ <validate>required-entry</validate>
248
+ </price>
249
+ </fields>
250
+ </deals>
251
+
252
+ </groups>
253
+ </shopdash>
254
+ <info>
255
+ <label>About ShopDash</label>
256
+ <tab>shopdash_tab</tab>
257
+ <frontend_type>text</frontend_type>
258
+ <sort_order>1001</sort_order>
259
+ <show_in_default>1</show_in_default>
260
+ <show_in_website>1</show_in_website>
261
+ <show_in_store>1</show_in_store>
262
+ <groups>
263
+ <shopdash_info translate="label">
264
+ <label>About ShopDash</label>
265
+ <sort_order>1</sort_order>
266
+ <show_in_default>1</show_in_default>
267
+ <show_in_website>1</show_in_website>
268
+ <show_in_store>1</show_in_store>
269
+ <comment><![CDATA[<div style="background: #ff4f03;"><img src="http://magevolve.hu/other/shopdash_header.png" alt="ShopDash" /></div><div style="display: inline-block; padding: 10px;"><p> <br/>ShopDash brings online shopping to tablets and lets users shop across many online retailers in one convenient and easy-to-use app. Products are organized into categories and by retailers of various brands to give shoppers the desired “mall on your tablet” feel.</p><br/><div class="f-left"><p>Contact: <a href="mailto:info@shopdashapp.com" title="info@shopdashapp.com">info@shopdashapp.com</a></p><p>Support: <a href="mailto:support@shopdashapp.com" title="support@shopdashapp.com">support@shopdashapp.com</a></p><p>Web: <a href="http://shopdashapp.com" title="ShopDash" target="_blank">http://shopdashapp.com</a></div><div class="f-right"><a href="https://itunes.apple.com/hu/app/shopdash/id609564715?mt=8" title="ShopDash App Store" target="_blank"> <img src="http://magevolve.hu/other/shopdash_appstore.png" alt="ShopDash App Store" /></a></div><div class="clearer"></div></div><br/><br/><div style="display: block; width: 100%; height: 61px; background: #ff4f03 url(http://magevolve.hu/other/shopdash_footer.png) center right no-repeat;"><p style="color: #FFF; text-align: center; position: relative; top: 21px; font-size: 14px;">Copyright &copy; 2013 <a style="color: #FFF;" href="http://shopdashapp.com" title="ShopDash Inc." target="_blank">ShopDash Inc.</a> All rights reserved.</p></div><script type="text/javascript">Fieldset.toggleCollapse('info_shopdash_info');</script>]]></comment>
270
+ </shopdash_info>
271
+ </groups>
272
+ </info>
273
+ <help>
274
+ <label>Help</label>
275
+ <tab>shopdash_tab</tab>
276
+ <frontend_type>text</frontend_type>
277
+ <sort_order>1002</sort_order>
278
+ <show_in_default>1</show_in_default>
279
+ <show_in_website>1</show_in_website>
280
+ <show_in_store>1</show_in_store>
281
+ <groups>
282
+ <shopdash_info translate="label">
283
+ <label>Help</label>
284
+ <sort_order>1</sort_order>
285
+ <show_in_default>1</show_in_default>
286
+ <show_in_website>1</show_in_website>
287
+ <show_in_store>1</show_in_store>
288
+ <comment><![CDATA[<div style="background: #ff4f03;"> <img src="http://magevolve.hu/other/shopdash_header.png" alt="ShopDash" /></div><div style="padding: 10px 10px 5px 10px;"><p style="text-transform: uppercase; text-decoration: underline;"><strong>Basic configuration</strong></p><p><strong>Enable:</strong> Basic set up to enable or disable the module.<br /> <strong>Filename:</strong> Here you can set up the export files default name. I.e.: shopdash.xml. The export file name will be storeX_shopdash.xml, where X is the store id.<br /> <strong>Path</strong>: Here you can set up the custom directory path where the export files will be saved after the export.<br /> <strong>Start Time:</strong> Here you can set up the automatic daily export time which will run in the background executed by cron job. This requires that the cron configuration of the Magento system configured correctly both in the backend and on the server side.<br /> <strong>Redirect:</strong> Here you can choose where to redirect to user after checkout was processed in the ShopDash Application. If Shopping Cart is selected, the user will be directed to Shopping Cart page. If Checkout is selected, the user will directly reach the webshop checkout page instead of shopping cart.<br /> <strong>Run Export Now:</strong> Here you can run the export process manually.</p><p style="text-transform: uppercase; text-decoration: underline;"><strong>Products configuration</strong></p><p><strong>Product Properties:</strong> Here you can select all the product attributes which will be included in the export file. Configurable required attributes will be included automatically in the export file.<br /> <strong>Unit of Quantity:</strong> Here you can select the products unit quantity attribute if the webshop has more than one unit quantity values.<br /> <strong>Custom Unit of Quantity:</strong> Here you can set up the basic unit of quantity which will be used for each product in the export file.<br /> <strong>Include Image Gallery:</strong> Here you can set up if the products media gallery should be included in the export file. For example if you have products with multiply images. If this setting set to NO, only the main images of the products will be exported.</p><p style="text-transform: uppercase; text-decoration: underline;"><strong>Category configuration</strong></p><p><strong>Select All Categories:</strong> Here you can set up to use all categories of the Magento store or not.<br /><strong>Selected Categories:</strong> Here you can select one or more categories. In this case only those products will be exported which are assigned to the selected categories.<br />Note: If you set up individual products for export in the Catalog / Manage ShopDash / Manage Export menu item, category configuration will not be used.</p><p style="text-transform: uppercase; text-decoration: underline;"><strong>Deal configuration</strong></p><p><strong>Enable Deal:</strong> Here you can set up to enable deals for products or not.<br /> <strong>Deal Name Attribute:</strong> Here you can select the product’s deal(discount) attribute to be used for the export.<br /> <strong>Custom Deal Name:</strong> If you don’t have deal(discount) attribute in the Magento store, you can set up a default deal name which will be used for each products in the export.<br /> <strong>Deal Priority:</strong> Here you can choose three different types of size which how deals will be showed in the ShopDash Application.<br /> <strong>Deal Price Attribute:</strong> Here you can select the product’s deal price attribute to be used for the export, for example Special Price attribute.</p></div><div style="display: block; width: 100%; height: 61px; background: #ff4f03 url(http://magevolve.hu/other/shopdash_footer.png) center right no-repeat;"><p style="color: #FFF; text-align: center; position: relative; top: 21px; font-size: 14px;">Copyright &copy; 2013 <a style="color: #FFF;" href="http://shopdashapp.com" title="ShopDash Inc." target="_blank">ShopDash Inc.</a> All rights reserved.</p></div><script type="text/javascript">Fieldset.toggleCollapse('help_shopdash_info');</script>]]></comment>
289
+ </shopdash_info>
290
+ </groups>
291
+ </help>
292
+ </sections>
293
+ </config>
app/code/community/Me/Shopdash/sql/me_shopdash_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ $installer = $this;
10
+
11
+ $installer->startSetup();
12
+
13
+ $installer->run("
14
+
15
+ -- DROP TABLE IF EXISTS {$this->getTable('me_shopdash/shopdash')};
16
+ CREATE TABLE IF NOT EXISTS {$this->getTable('me_shopdash/shopdash')} (
17
+ `shopdash_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
18
+ `product_id` int(10) unsigned NOT NULL,
19
+ `store_id` smallint(5) unsigned NOT NULL,
20
+ PRIMARY KEY (`shopdash_id`),
21
+ KEY `product_id` (`product_id`),
22
+ KEY `store_id` (`store_id`),
23
+ KEY `store_id_2` (`store_id`)
24
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
25
+
26
+ ALTER TABLE `{$this->getTable('me_shopdash/shopdash')}`
27
+ ADD CONSTRAINT FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core/store')}` (`store_id`) ON DELETE CASCADE,
28
+ ADD CONSTRAINT FOREIGN KEY (`product_id`) REFERENCES `{$this->getTable('catalog/product')}` (`entity_id`) ON DELETE CASCADE;
29
+
30
+ ");
31
+
32
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/me_shopdash.xml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Me
5
+ * @package Me_Shopdash
6
+ * @author Magevolve Ltd.
7
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ -->
11
+ <layout version="0.1.0">
12
+
13
+ <me_shopdash_adminhtml_shopdash_index>
14
+ <update handle="editor"/>
15
+ <reference name="content">
16
+ <block type="me_shopdash/adminhtml_shopdash" name="shopdash" />
17
+ </reference>
18
+ </me_shopdash_adminhtml_shopdash_index>
19
+
20
+ <!--
21
+ <me_shopdash_adminhtml_shopdash_edit>
22
+ <reference name="content">
23
+ <block type="adminhtml/tag_edit" name="tag_edit" template="tag/edit/container.phtml"></block>
24
+ </reference>
25
+ </me_shopdash_adminhtml_shopdash_edit>
26
+ -->
27
+
28
+ <me_shopdash_adminhtml_shopdash_product>
29
+ <block type="core/text_list" name="root" output="toHtml">
30
+ <block type="me_shopdash/adminhtml_shopdash_edit_tab_grid" name="product.grid"/>
31
+ <block type="adminhtml/widget_grid_serializer" name="grid_serializer">
32
+ <reference name="grid_serializer">
33
+ <action method="initSerializerBlock">
34
+ <grid_block_name>product.grid</grid_block_name>
35
+ <data_callback>getSelectedProducts</data_callback>
36
+ <hidden_input_name>links[products]</hidden_input_name>
37
+ <reload_param_name>products</reload_param_name>
38
+ </action>
39
+ <action method="addColumnInputName">
40
+ <input_name>position</input_name>
41
+ </action>
42
+ </reference>
43
+ </block>
44
+ </block>
45
+ </me_shopdash_adminhtml_shopdash_product>
46
+
47
+ <me_shopdash_adminhtml_shopdash_productgrid>
48
+ <block type="core/text_list" name="root" output="toHtml">
49
+ <block type="me_shopdash/adminhtml_shopdash_edit_tab_grid" name="product.grid"/>
50
+ </block>
51
+ </me_shopdash_adminhtml_shopdash_productgrid>
52
+
53
+ </layout>
app/design/adminhtml/default/default/template/me/shopdash/system/config/form/button.phtml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Me
4
+ * @package Me_Shopdash
5
+ * @author Magevolve Ltd.
6
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ ?>
10
+ <?php $dataHelper = Mage::helper('me_shopdash'); ?>
11
+ <script type="text/javascript">
12
+ //<![CDATA[
13
+ function run() {
14
+ if( confirm("<?php echo $dataHelper->__("Are you sure you want to run export? There can be performance impact during this operation.") ?>") ) {
15
+ new Ajax.Request('<?php echo $this->getAjaxRunUrl() ?>', {
16
+ method: 'post',
17
+ onSuccess: function(transport){
18
+ var result = transport.responseText.evalJSON();
19
+ if (result.result == 0){
20
+ alert(result.msg);
21
+ }
22
+ },
23
+ on404: function(transport){
24
+ alert('<?php echo $dataHelper->__("URL error! 404 Not found.") ?>');
25
+ },
26
+ on500: function(transport){
27
+ alert('<?php echo $dataHelper->__("Server error! Please try again later.") ?>');
28
+ }
29
+ });
30
+ }
31
+ }
32
+ //]]>
33
+ </script>
34
+
35
+ <?php echo $this->getButtonHtml() ?>
app/etc/modules/Me_Shopdash.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Me
5
+ * @package Me_Shopdash
6
+ * @author Magevolve Ltd.
7
+ * @copyright Copyright (c) 2013 ShopDash Inc. (http://shopdashapp.com/)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ -->
11
+ <config>
12
+ <modules>
13
+ <Me_Shopdash>
14
+ <active>true</active>
15
+ <codePool>community</codePool>
16
+ <depends>
17
+ <Mage_Catalog />
18
+ <Mage_Checkout />
19
+ </depends>
20
+ </Me_Shopdash>
21
+ </modules>
22
+ </config>
app/locale/en_US/Me_Shopdash.csv ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "ShopDash Extension","ShopDash Extension"
2
+ "ShopDash Settings","ShopDash Settings"
3
+ "ShopDash Export Configuration","ShopDash Export Configuration"
4
+ "Enable","Enable"
5
+ "Enable module.","Enable module."
6
+ "Filename","Filename"
7
+ "Name of the export file. I.e.: shopdash.xml. The export file name will be storeX_shopdash.xml, where X is the store id.","Name of the export file. I.e.: shopdash.xml. The export file name will be storeX_shopdash.xml, where X is the store id."
8
+ "Path","Path"
9
+ "Path to the export file. I.e.: /shopdash_feed.","Path to the export file. I.e.: /shopdash_feed."
10
+ "Start Time","Start Time"
11
+ "Daily export schedule. Format: HH:MM:SS.","Daily export schedule. Format: HH:MM:SS."
12
+ "Empty Cart","Empty Cart"
13
+ "Empty cart before adding products.","Empty cart before adding products."
14
+ "Redirect","Redirect"
15
+ "Redirect to shopping cart or to checkout page.","Redirect to shopping cart or to checkout page."
16
+ "Run Export Now","Run Export Now"
17
+ "Products Configuration","Products Configuration"
18
+ "Product Properties","Product Properties"
19
+ "Please select product's attributes.","Please select product's attributes."
20
+ "Unit of Quantity","Unit of Quantity"
21
+ "Please select unit of quantity attribute.","Please select unit of quantity attribute."
22
+ "Custom Unit of Quantity","Custom Unit of Quantity"
23
+ "Custom discount name for every products. I.e.: qty, kg, etc.","Custom discount name for every products. I.e.: qty, kg, etc."
24
+ "Include Image Gallery","Include Image Gallery"
25
+ "The export will include all product images.","The export will include all product images."
26
+ "Category Configuration","Category Configuration"
27
+ "Select All Categories","Select All Categories"
28
+ "If set to yes, all categories will be selected.","If set to yes, all categories will be selected."
29
+ "Selected Categories","Selected Categories"
30
+ "Please select categories.","Please select categories."
31
+ "Deal Configuration","Deal Configuration"
32
+ "Enable Deal","Enable Deal"
33
+ "Enable deal in export.","Enable deal in export."
34
+ "Deal Name Attribute","Deal Name Attribute"
35
+ "Please select deal name attribute.","Please select deal name attribute."
36
+ "Custom Deal Name","Custom Deal Name"
37
+ "Custom discount name for every products. I.e.: Special discount. This will be used if deal name attribute is not set.","Custom discount name for every products. I.e.: Special discount. This will be used if deal name attribute is not set."
38
+ "Deal Priority","Deal Priority"
39
+ "Item size in the list. Available values: small, medium, huge.","Item size in the list. Available values: small, medium, huge."
40
+ "Deal Price Attribute","Deal Price Attribute"
41
+ "Please select deal price attribute.","Please select deal price attribute."
42
+ "ShopDash Informations","ShopDash Informations"
43
+ "Run Export","Run Export"
44
+ "ShopDash: Cannot add the item to shopping cart.","ShopDash: Cannot add the item to shopping cart."
45
+ "Cannot add the item to shopping cart.","Cannot add the item to shopping cart."
46
+ "Cannot add configurable item to shopping cart.","Cannot add configurable item to shopping cart."
47
+ "Products were added to your shopping cart.","Products were added to your shopping cart."
48
+ "%s was added to your shopping cart.","%s was added to your shopping cart."
49
+ "Cannot add the item to shopping cart.","Cannot add the item to shopping cart."
50
+ "An error occurred while running export.","An error occurred while running export."
51
+ "Unable to save the cron expression.","Unable to save the cron expression."
52
+ "Please select...","Please select..."
53
+ "Root","Root"
54
+ "Small","Small"
55
+ "Medium","Medium"
56
+ "Huge","Huge"
57
+ "Shopping Cart","Shopping Cart"
58
+ "Checkout","Checkout"
59
+ "Are you sure you want to run export? There can be performance impact during this operation.","Are you sure you want to run export? There can be performance impact during this operation."
60
+ "URL error! 404 Not found.","URL error! 404 Not found."
61
+ "Server error! Please try again later.","Server error! Please try again later."
62
+ "Yes","Yes"
63
+ "No","No"
64
+ "Please click on Reset filter to see the whole list","Please click on Reset filter to see the whole list"
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Me_Shopdash</name>
4
+ <version>1.1.7</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://shopdashapp.com/">Open Software License (OSL 3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The module provides communication between Magento and ShopDash Application(http://shopdashapp.com).&#xD;
10
+ ShopDash Inc., ShopDash Magento Extension</summary>
11
+ <description>The module provides communication between Magento and ShopDash Application(http://shopdashapp.com). The extension creates separate export files in XML format for every store in the Magento E-commerce system in a customizable directory on the server. The export file contains all the product information which is required for the ShopDash Application.&#xD;
12
+ &#xD;
13
+ ShopDash Inc., ShopDash Magento Extension</description>
14
+ <notes>Version number: 1.1.7. Stability: Stable Compatibility: 1.4.x, 1.5.x, 1.6.x, 1.7.x, 1.8.x.&#xD;
15
+ The extension provides communication between Magento and ShopDash Application(http://shopdashapp.com).</notes>
16
+ <authors><author><name>ShopDash</name><user>ShopDash</user><email>info@shopdashapp.com</email></author><author><name>Attila S&#xE1;gi</name><user>magevolve</user><email>sagi.attila@magevolve.com</email></author></authors>
17
+ <date>2013-12-11</date>
18
+ <time>21:19:41</time>
19
+ <contents><target name="mageetc"><dir name="modules"><file name="Me_Shopdash.xml" hash="3fa6806f92dbcd2e4bc575aad9fa555b"/></dir></target><target name="magecommunity"><dir name="Me"><dir name="Shopdash"><dir name="Block"><dir name="Adminhtml"><dir name="Shopdash"><dir name="Edit"><file name="Form.php" hash="c561fc202ab0fd901134ce1c6d5e94ac"/><dir name="Tab"><file name="Grid.php" hash="a889a0a23675f04aea124594872aa087"/></dir><file name="Tabs.php" hash="1c30b8d57cafe1a09e6b1364d821d87b"/></dir><file name="Edit.php" hash="58dd953562cfba958af718c6214f0756"/><dir name="Store"><file name="Switcher.php" hash="910f7f21136e4bff68f93150c745bf6b"/></dir></dir><file name="Shopdash.php" hash="e47d283865be9c801526bb299f568269"/><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="108055f1e0feeecc970fd4c3553aa268"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="5f856c8a3419cf8e49e02eee62af9303"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Shopdash"><file name="Collection.php" hash="5b5cd8016ea509de43c6e5dd37205f10"/></dir><file name="Shopdash.php" hash="47b967a491ff478b1aca8ff2c75ec43e"/></dir><dir name="Shopdash"><dir name="Catalog"><file name="Product.php" hash="5682b3aae88b84411d8d398eadf6c048"/></dir></dir><file name="Shopdash.php" hash="1faa4ed50661e6c26f747ecd21936f9d"/><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Shopdash"><file name="Cron.php" hash="480b795576987fcf8987445b087fbd97"/></dir></dir><dir name="Source"><file name="Attributes.php" hash="c1107f6a98c642782849ae4a12014f81"/><file name="Category.php" hash="15ded7bbad672cae036c3174a6eaf792"/><file name="Priceattributes.php" hash="2caa3a7441a635fcac014cf4a8ec0397"/><file name="Priority.php" hash="02a00dd8a88634f4e6ecad0833ae68f3"/><file name="Properties.php" hash="94334174f4d10f98ecb1f1a8edfc5cf4"/><file name="Redirect.php" hash="154d28f8f318334d389b97747af09dc4"/><file name="Textattributes.php" hash="e57c51c759717a3e870004f03b7e2af9"/></dir></dir></dir></dir><dir name="controllers"><file name="AddController.php" hash="ed357433a3f78a2bba11dcb1e30b3952"/><dir name="Adminhtml"><file name="ShopdashController.php" hash="9c47f1d962d3868120de83655ba51a73"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="724e9e933ccd73ce66ce9e9de28bd3dc"/><file name="config.xml" hash="e5848f8c4629ced27d02e9ddf210d31b"/><file name="system.xml" hash="14d343aaad1a11ab8a751b9b470e413d"/></dir><dir name="sql"><dir name="me_shopdash_setup"><file name="mysql4-install-0.1.0.php" hash="d9b0e3bb2ce58139a0c4b50fc7fdac55"/></dir></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="locale"><dir name="en_US"><file name="Me_Shopdash.csv" hash="7b6bc94aa1c64ef8dd32754f5d40bafe"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="me"><dir name="shopdash"><dir name="system"><dir name="config"><dir name="form"><file name="button.phtml" hash="51f7886ee6fa9e75cb286b58246200af"/></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="me_shopdash.xml" hash="d295d88ff956713c673b21defb6bc4cc"/></dir></dir></dir></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
22
+ </package>