CP_Feed - Version 0.0.1

Version Notes

CP Google Feed

Download this release

Release Info

Developer Commerce Pundit
Extension CP_Feed
Version 0.0.1
Comparing to
See all releases


Version 0.0.1

Files changed (49) hide show
  1. app/code/community/CP/Feed/Block/Adminhtml/Config/Form/Renderer/Website.php +32 -0
  2. app/code/community/CP/Feed/Block/Adminhtml/Items.php +33 -0
  3. app/code/community/CP/Feed/Block/Adminhtml/Items/Edit.php +163 -0
  4. app/code/community/CP/Feed/Block/Adminhtml/Items/Edit/Form.php +56 -0
  5. app/code/community/CP/Feed/Block/Adminhtml/Items/Edit/Tab/Advanced.php +322 -0
  6. app/code/community/CP/Feed/Block/Adminhtml/Items/Edit/Tab/Content/Csv.php +340 -0
  7. app/code/community/CP/Feed/Block/Adminhtml/Items/Edit/Tab/Content/Productcategory.php +28 -0
  8. app/code/community/CP/Feed/Block/Adminhtml/Items/Edit/Tab/Main.php +147 -0
  9. app/code/community/CP/Feed/Block/Adminhtml/Items/Edit/Tab/Type.php +142 -0
  10. app/code/community/CP/Feed/Block/Adminhtml/Items/Edit/Tabs.php +131 -0
  11. app/code/community/CP/Feed/Block/Adminhtml/Items/Grid.php +253 -0
  12. app/code/community/CP/Feed/Block/Adminhtml/Items/Grid/Renderer/AccessUrl.php +40 -0
  13. app/code/community/CP/Feed/Block/Adminhtml/Items/Grid/Renderer/Datetime.php +45 -0
  14. app/code/community/CP/Feed/Helper/Data.php +74 -0
  15. app/code/community/CP/Feed/Model/Adminhtml/System/Config/Source/Store.php +25 -0
  16. app/code/community/CP/Feed/Model/Custom/Attribute.php +40 -0
  17. app/code/community/CP/Feed/Model/Item.php +755 -0
  18. app/code/community/CP/Feed/Model/Item/Block.php +369 -0
  19. app/code/community/CP/Feed/Model/Item/Block/Category.php +64 -0
  20. app/code/community/CP/Feed/Model/Item/Block/Product.php +483 -0
  21. app/code/community/CP/Feed/Model/Mysql4/Custom/Attribute.php +36 -0
  22. app/code/community/CP/Feed/Model/Mysql4/Custom/Attribute/Collection.php +38 -0
  23. app/code/community/CP/Feed/Model/Mysql4/Item.php +36 -0
  24. app/code/community/CP/Feed/Model/Mysql4/Item/Collection.php +38 -0
  25. app/code/community/CP/Feed/Model/Observer.php +94 -0
  26. app/code/community/CP/Feed/Model/Option/Productcategories.php +69 -0
  27. app/code/community/CP/Feed/Model/Product/Collection.php +197 -0
  28. app/code/community/CP/Feed/controllers/Adminhtml/ItemsController.php +791 -0
  29. app/code/community/CP/Feed/controllers/IndexController.php +63 -0
  30. app/code/community/CP/Feed/etc/adminhtml.xml +85 -0
  31. app/code/community/CP/Feed/etc/config.xml +154 -0
  32. app/code/community/CP/Feed/sql/cp_feed_setup/mysql4-install-1.0.php +41 -0
  33. app/code/community/CP/Feed/sql/cp_feed_setup/mysql4-install-1.3.php +45 -0
  34. app/code/community/CP/Feed/sql/cp_feed_setup/mysql4-install-1.4.php +48 -0
  35. app/code/community/CP/Feed/sql/cp_feed_setup/mysql4-install-2.0.php +54 -0
  36. app/code/community/CP/Feed/sql/cp_feed_setup/mysql4-upgrade-1.3-1.4.php +36 -0
  37. app/code/community/CP/Feed/sql/cp_feed_setup/mysql4-upgrade-1.4-2.0.php +32 -0
  38. app/code/community/CP/Feed/sql/cp_feed_setup/mysql4-upgrade-2.0-2.1.php +32 -0
  39. app/design/adminhtml/default/default/layout/cp-feed.xml +65 -0
  40. app/design/adminhtml/default/default/template/cp/feed/item/edit/category_product.phtml +79 -0
  41. app/design/adminhtml/default/default/template/cp/feed/item/edit/content.phtml +187 -0
  42. app/design/adminhtml/default/default/template/cp/feed/item/edit/content/mapping.phtml +44 -0
  43. app/design/adminhtml/default/default/template/cp/feed/item/import/form.phtml +27 -0
  44. app/etc/modules/Cp_Feed.xml +30 -0
  45. js/cpfeed/jquery-1.8.2.min.js +139 -0
  46. package.xml +18 -0
  47. skin/adminhtml/default/default/cp/cpfeed.css +20 -0
  48. skin/adminhtml/default/default/cp/feed.css +105 -0
  49. skin/adminhtml/default/default/cp/images/plus.png +0 -0
app/code/community/CP/Feed/Block/Adminhtml/Config/Form/Renderer/Website.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Block_Adminhtml_Config_Form_Renderer_Website extends Mage_Adminhtml_Block_System_Config_Form_Field
23
+ {
24
+
25
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
26
+ {
27
+
28
+ $html = '';
29
+ return $html;
30
+
31
+ }
32
+ }
app/code/community/CP/Feed/Block/Adminhtml/Items.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Block_Adminhtml_Items extends Mage_Adminhtml_Block_Widget_Grid_Container
23
+ {
24
+ public function __construct()
25
+ {
26
+ $this->_controller = 'adminhtml_items';
27
+ $this->_blockGroup = 'cp_feed';
28
+ $this->_headerText = $this->__('Manage Feeds');
29
+ $this->_addButtonLabel = $this->__('Add Feed');
30
+
31
+ parent::__construct();
32
+ }
33
+ }
app/code/community/CP/Feed/Block/Adminhtml/Items/Edit.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Block_Adminhtml_Items_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
23
+ {
24
+
25
+ public function __construct()
26
+ {
27
+
28
+
29
+
30
+ parent::__construct();
31
+
32
+
33
+
34
+ $this->_objectId = 'id';
35
+
36
+ $this->_blockGroup = 'cp_feed';
37
+
38
+ $this->_controller = 'adminhtml_items';
39
+
40
+
41
+
42
+ $this->_updateButton('save', 'label', $this->__('Save'));
43
+
44
+ $this->_updateButton('delete', 'label', $this->__('Delete'));
45
+
46
+
47
+
48
+ $feed = Mage::registry('cp_feed');
49
+
50
+
51
+
52
+ if ($feed && $feed->getId() > 0) {
53
+
54
+
55
+
56
+ $this->_addButton('generate', array(
57
+
58
+ 'label' => $this->__('Generate File'),
59
+
60
+ 'onclick' => 'if($(\'loading-mask\')){$(\'loading-mask\').show();}setLocation(\'' . $this->getUrl('*/*/generate', array(
61
+ 'id' => $feed->getId()
62
+ )) . '\')'
63
+
64
+ ), -100);
65
+
66
+
67
+
68
+ if ($feed->getFtpActive()) {
69
+
70
+
71
+
72
+ $this->_addButton('upload', array(
73
+
74
+ 'label' => $this->__('Upload File'),
75
+
76
+ 'onclick' => 'setLocation(\'' . $this->getUrl('*/*/upload', array(
77
+ 'id' => $feed->getId()
78
+ )) . '\')'
79
+
80
+ ), -100);
81
+
82
+
83
+
84
+ }
85
+
86
+
87
+
88
+ }
89
+
90
+
91
+
92
+ $this->_addButton('saveandcontinue', array(
93
+
94
+ 'label' => $this->__('Save And Continue Edit'),
95
+
96
+ 'onclick' => 'saveAndContinueEdit()',
97
+
98
+ 'class' => 'save'
99
+
100
+ ), -100);
101
+
102
+
103
+
104
+ $_data = array();
105
+
106
+ $_data['data'] = Cp_Feed_Block_Adminhtml_Items_Edit_Tab_Content_Csv::getSystemSections();
107
+
108
+ $_data['url'] = $this->getUrl('*/*/mappingimportsection', array(
109
+ 'id' => ($feed && $feed->getId() ? $feed->getId() : 0)
110
+ ));
111
+
112
+
113
+
114
+ $this->_formScripts[] = "
115
+
116
+ function saveAndContinueEdit(){
117
+
118
+ editForm.submit($('edit_form').action+'back/edit/');
119
+
120
+ }
121
+
122
+
123
+
124
+ var CpFeedAdmin = new CpFeedAdminSettings(" . Zend_Json::encode($_data) . ");
125
+
126
+
127
+
128
+ ";
129
+
130
+
131
+
132
+ if ($this->getRequest()->getActionName() == 'new' && !$this->getRequest()->getParam('type')) {
133
+
134
+ $this->removeButton('save');
135
+
136
+ $this->removeButton('saveandcontinue');
137
+
138
+ }
139
+
140
+
141
+
142
+ }
143
+
144
+
145
+
146
+ public function getHeaderText()
147
+ {
148
+
149
+
150
+
151
+ if (Mage::registry('cp_feed') && Mage::registry('cp_feed')->getId()) {
152
+
153
+ return $this->__("Edit %s", $this->htmlEscape(Mage::registry('cp_feed')->getName()));
154
+
155
+ } else {
156
+
157
+ return $this->__('Add Item');
158
+
159
+ }
160
+
161
+ }
162
+
163
+ }
app/code/community/CP/Feed/Block/Adminhtml/Items/Edit/Form.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Block_Adminhtml_Items_Edit_Form extends Mage_Adminhtml_Block_Widget_Form{
23
+
24
+
25
+
26
+ protected function _prepareForm(){
27
+
28
+
29
+
30
+ $form = new Varien_Data_Form(array(
31
+
32
+ 'id' => 'edit_form',
33
+
34
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
35
+
36
+ 'method' => 'post',
37
+
38
+ 'enctype' => 'multipart/form-data'
39
+
40
+ ));
41
+
42
+
43
+
44
+ $form->setUseContainer(true);
45
+
46
+ $this->setForm($form);
47
+
48
+ return parent::_prepareForm();
49
+
50
+
51
+
52
+ }
53
+
54
+
55
+
56
+ }
app/code/community/CP/Feed/Block/Adminhtml/Items/Edit/Tab/Advanced.php ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Block_Adminhtml_Items_Edit_Tab_Advanced extends Mage_Adminhtml_Block_Widget_Form
23
+ {
24
+
25
+ protected function _prepareForm()
26
+ {
27
+
28
+
29
+
30
+ $form = new Varien_Data_Form();
31
+
32
+
33
+
34
+ if (Mage::registry('cp_feed')) {
35
+
36
+ $item = Mage::registry('cp_feed');
37
+
38
+ } else {
39
+
40
+ $item = Mage::getModel('cp_feed/item');
41
+
42
+ }
43
+
44
+
45
+
46
+ $this->setForm($form);
47
+
48
+ $fieldset = $form->addFieldset('advanced', array(
49
+ 'legend' => $this->__('File Creation Settings')
50
+ ));
51
+
52
+
53
+ $field = $fieldset->addField('use_layer', 'select', array(
54
+
55
+ 'name' => 'use_layer',
56
+
57
+ 'label' => $this->__('Export Out of Stock Products'),
58
+
59
+ 'title' => $this->__('Export Out of Stock Products'),
60
+
61
+ 'required' => false,
62
+
63
+ 'values' => array(
64
+ 1 => $this->__('No'),
65
+ 0 => $this->__('Yes')
66
+ )
67
+
68
+ ));
69
+
70
+ if (!$item->getId()) {
71
+
72
+ $field->setValue('1');
73
+
74
+ }
75
+
76
+
77
+
78
+ $field = $fieldset->addField('use_disabled', 'select', array(
79
+
80
+ 'name' => 'use_disabled',
81
+
82
+ 'label' => $this->__('Export Disabled Products'),
83
+
84
+ 'title' => $this->__('Export Disabled Products'),
85
+
86
+ 'required' => false,
87
+
88
+ 'values' => array(
89
+ 1 => $this->__('No'),
90
+ 0 => $this->__('Yes')
91
+ )
92
+
93
+ ));
94
+
95
+ $fieldset->addField('product_visibility', 'select', array(
96
+ 'label' => Mage::helper('cms')->__('Product Visibility'),
97
+ 'name' => 'product_visibility',
98
+ 'onclick' => "",
99
+ 'onchange' => "",
100
+ 'value' => '4',
101
+ 'values' => array(
102
+ 0 => $this->__('-- Please Select --'),
103
+ 1 => $this->__('Not Visible Individually'),
104
+ 2 => $this->__('Catalog'),
105
+ 3 => $this->__('Search'),
106
+ 4 => $this->__('Catalog, Search')
107
+
108
+ ),
109
+ 'disabled' => false,
110
+ 'readonly' => false,
111
+ 'tabindex' => 1
112
+ ));
113
+
114
+
115
+
116
+
117
+
118
+ if (!$item->getId()) {
119
+
120
+ $field->setValue('1');
121
+
122
+ }
123
+
124
+ $fieldset = $form->addFieldset('upload_settings', array(
125
+ 'legend' => $this->__('CRON Settings')
126
+ ));
127
+
128
+ $field = $fieldset->addField('upload_day', 'multiselect', array(
129
+
130
+ 'name' => 'upload_day',
131
+
132
+ 'label' => $this->__('Available Days'),
133
+
134
+ 'title' => $this->__('Available Days'),
135
+
136
+ 'required' => false,
137
+
138
+ 'values' => array(
139
+
140
+ array(
141
+ 'label' => $this->__('Sunday'),
142
+ 'value' => 'sun'
143
+ ),
144
+
145
+ array(
146
+ 'label' => $this->__('Monday'),
147
+ 'value' => 'mon'
148
+ ),
149
+
150
+ array(
151
+ 'label' => $this->__('Tuesday'),
152
+ 'value' => 'tue'
153
+ ),
154
+
155
+ array(
156
+ 'label' => $this->__('Wednesday'),
157
+ 'value' => 'wed'
158
+ ),
159
+
160
+ array(
161
+ 'label' => $this->__('Thursday'),
162
+ 'value' => 'thu'
163
+ ),
164
+
165
+ array(
166
+ 'label' => $this->__('Friday'),
167
+ 'value' => 'fri'
168
+ ),
169
+
170
+ array(
171
+ 'label' => $this->__('Saturday'),
172
+ 'value' => 'sat'
173
+ )
174
+
175
+ )
176
+
177
+ ));
178
+
179
+
180
+
181
+ if (!$item->getId()) {
182
+
183
+ $field->setValue('sun,mon,tue,wed,thu,fri,sat');
184
+
185
+ }
186
+
187
+
188
+
189
+ $hours = array();
190
+
191
+ $locale = Mage::getSingleton('core/locale');
192
+
193
+ for ($i = 0; $i < 24; $i++) {
194
+
195
+ $hours[] = array(
196
+ 'label' => sprintf('%02d:00', $i),
197
+ 'value' => date('H', mktime($i, 0, 0, 1, 1, 1970) + $locale->date()->getGmtOffset())
198
+ );
199
+
200
+ }
201
+
202
+
203
+ $field = $fieldset->addField('upload_interval', 'select', array(
204
+
205
+ 'name' => 'upload_interval',
206
+
207
+ 'label' => $this->__('Interval, hours'),
208
+
209
+ 'title' => $this->__('Interval, hours'),
210
+
211
+ 'required' => false,
212
+
213
+ 'values' => array(
214
+
215
+ array(
216
+ 'label' => $this->__('every 5 mins'),
217
+ 'value' => 50
218
+ ),
219
+
220
+ array(
221
+ 'label' => $this->__('every 10 mins'),
222
+ 'value' => 100
223
+ ),
224
+
225
+ array(
226
+ 'label' => $this->__('every 15 mins'),
227
+ 'value' => 150
228
+ ),
229
+
230
+ array(
231
+ 'label' => $this->__('every 20 mins'),
232
+ 'value' => 200
233
+ ),
234
+
235
+ array(
236
+ 'label' => $this->__('every 30 mins'),
237
+ 'value' => 300
238
+ ),
239
+
240
+ array(
241
+ 'label' => $this->__('every 1 hour'),
242
+ 'value' => 1
243
+ ),
244
+
245
+ array(
246
+ 'label' => $this->__('every 3 hours'),
247
+ 'value' => 3
248
+ ),
249
+
250
+ array(
251
+ 'label' => $this->__('every 6 hours'),
252
+ 'value' => 6
253
+ ),
254
+
255
+ array(
256
+ 'label' => $this->__('every 12 hours'),
257
+ 'value' => 12
258
+ ),
259
+
260
+ array(
261
+ 'label' => $this->__('every 24 hours'),
262
+ 'value' => 24
263
+ )
264
+
265
+ ),
266
+
267
+ 'class' => 'cp-feed-validate-interval'
268
+
269
+ ));
270
+
271
+ if (!$item->getId()) {
272
+
273
+ $field->setValue('24');
274
+
275
+ }
276
+
277
+
278
+ /* $field->setOnchange('cpfeed_setinterval(this, \'upload_hour_to\')');
279
+
280
+ $field = $field = $fieldset->addField('restart_cron', 'select', array(
281
+
282
+ 'name' => 'restart_cron',
283
+
284
+ 'label' => $this->__('Restart Cron, times'),
285
+
286
+ 'title' => $this->__('Restart Cron, times'),
287
+
288
+ 'required' => false,
289
+
290
+ 'values' => array(
291
+
292
+ array('label'=>$this->__('1'), 'value'=>1),
293
+
294
+ array('label'=>$this->__('2'), 'value'=>2),
295
+
296
+ array('label'=>$this->__('3'), 'value'=>3),
297
+
298
+ array('label'=>$this->__('4'), 'value'=>4),
299
+
300
+ array('label'=>$this->__('5'), 'value'=>5),
301
+
302
+ )
303
+
304
+ ));
305
+
306
+ if(!$item->getId()){
307
+
308
+ $field ->setValue('3');
309
+
310
+ }*/
311
+
312
+ if ($item->getId()) {
313
+
314
+ $form->setValues($item->getData());
315
+
316
+ }
317
+
318
+ return parent::_prepareForm();
319
+
320
+ }
321
+
322
+ }
app/code/community/CP/Feed/Block/Adminhtml/Items/Edit/Tab/Content/Csv.php ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Block_Adminhtml_Items_Edit_Tab_Content_Csv extends Mage_Adminhtml_Block_Template
23
+ {
24
+
25
+ protected $attribute_collection;
26
+ protected $options;
27
+ protected $_config;
28
+
29
+ public function __construct()
30
+ {
31
+ parent::__construct();
32
+ $this->getConfig()->setUrl(Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/*/ajaxupload'));
33
+ $this->getConfig()->setParams(array(
34
+ 'form_key' => $this->getFormKey()
35
+ ));
36
+ $this->getConfig()->setFileField('file');
37
+ $this->getConfig()->setFilters(array(
38
+ 'all' => array(
39
+ 'label' => Mage::helper('adminhtml')->__('All Files'),
40
+ 'files' => array(
41
+ '*.*'
42
+ )
43
+ )
44
+ ));
45
+ }
46
+
47
+ public function getHtmlId()
48
+ {
49
+ if ($this->getData('upload_id') === null) {
50
+ $this->setData('upload_id', 'id_cp_feed_upload');
51
+ }
52
+ return $this->getData('upload_id');
53
+ }
54
+
55
+ public function getConfigJson()
56
+ {
57
+ return Zend_Json::encode($this->getConfig()->getData());
58
+ }
59
+
60
+ public function getConfig()
61
+ {
62
+ if (is_null($this->_config)) {
63
+ $this->_config = new Varien_Object();
64
+ }
65
+
66
+ return $this->_config;
67
+ }
68
+
69
+ public function getJsObjectName()
70
+ {
71
+ return $this->getHtmlId() . 'JsObject';
72
+ }
73
+
74
+ public function getPostMaxSize()
75
+ {
76
+ return ini_get('post_max_size');
77
+ }
78
+
79
+ public function getUploadMaxSize()
80
+ {
81
+ return ini_get('upload_max_filesize');
82
+ }
83
+
84
+ public function getDataMaxSize()
85
+ {
86
+ return min($this->getPostMaxSize(), $this->getUploadMaxSize());
87
+ }
88
+
89
+ public function getDataMaxSizeInBytes()
90
+ {
91
+ $iniSize = $this->getDataMaxSize();
92
+ $size = substr($iniSize, 0, strlen($iniSize) - 1);
93
+ $parsedSize = 0;
94
+ switch (strtolower(substr($iniSize, strlen($iniSize) - 1))) {
95
+ case 't':
96
+ $parsedSize = $size * (1024 * 1024 * 1024 * 1024);
97
+ break;
98
+ case 'g':
99
+ $parsedSize = $size * (1024 * 1024 * 1024);
100
+ break;
101
+ case 'm':
102
+ $parsedSize = $size * (1024 * 1024);
103
+ break;
104
+ case 'k':
105
+ $parsedSize = $size * 1024;
106
+ break;
107
+ case 'b':
108
+ default:
109
+ $parsedSize = $size;
110
+ break;
111
+ }
112
+ return $parsedSize;
113
+ }
114
+
115
+ public function getUploaderUrl($url)
116
+ {
117
+ if (!is_string($url)) {
118
+ $url = '';
119
+ }
120
+ $design = Mage::getDesign();
121
+ $theme = $design->getTheme('skin');
122
+ if (empty($url) || !$design->validateFile($url, array(
123
+ '_type' => 'skin',
124
+ '_theme' => $theme
125
+ ))) {
126
+ $theme = $design->getDefaultTheme();
127
+ }
128
+ return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . $design->getArea() . '/' . $design->getPackageName() . '/' . $theme . '/' . $url;
129
+ }
130
+
131
+ public function getDeleteButtonHtml()
132
+ {
133
+ return $this->getChildHtml('delete_button');
134
+ }
135
+
136
+ protected function _prepareLayout()
137
+ {
138
+ $this->setChild('delete_button', $this->getLayout()->createBlock('adminhtml/widget_button')->addData(array(
139
+ 'id' => '{{id}}-delete',
140
+ 'class' => 'delete',
141
+ 'type' => 'button',
142
+ 'label' => Mage::helper('adminhtml')->__('Remove'),
143
+ 'onclick' => $this->getJsObjectName() . '.removeFile(\'{{fileId}}\')'
144
+ )));
145
+
146
+ return parent::_prepareLayout();
147
+ }
148
+
149
+ public function getFeed()
150
+ {
151
+
152
+ if (Mage::registry('cp_feed')) {
153
+ return Mage::registry('cp_feed');
154
+ } else {
155
+ return new Varien_Object();
156
+ }
157
+
158
+ }
159
+
160
+ public static function getAttributeCollection()
161
+ {
162
+
163
+ $attribute_collection = Mage::getResourceModel('eav/entity_attribute_collection')->setItemObjectClass('catalog/resource_eav_attribute')->setEntityTypeFilter(Mage::getResourceModel('catalog/product')->getTypeId());
164
+
165
+ return $attribute_collection;
166
+ }
167
+
168
+ public static function getAttributeOptionsArray()
169
+ {
170
+
171
+ $options = array();
172
+
173
+ $options['Product Id'] = array(
174
+ 'code' => "entity_id",
175
+ 'label' => "Product Id"
176
+ );
177
+ $options['Product Type'] = array(
178
+ 'code' => "product_type",
179
+ 'label' => "Product Type"
180
+ );
181
+ $options['Is In Stock'] = array(
182
+ 'code' => "is_in_stock",
183
+ 'label' => "Is In Stock"
184
+ );
185
+ $options['Qty'] = array(
186
+ 'code' => "qty",
187
+ 'label' => "Qty"
188
+ );
189
+ $options['Image'] = array(
190
+ 'code' => "image",
191
+ 'label' => "Image"
192
+ );
193
+ $options['URL'] = array(
194
+ 'code' => "url",
195
+ 'label' => "URL"
196
+ );
197
+ /*$options['URL (Parent product)'] = array('code'=>"parent_url" , 'label' => "URL (Parent product)");*/
198
+ $options['Category'] = array(
199
+ 'code' => "category",
200
+ 'label' => "Category"
201
+ );
202
+ $options['Final Price'] = array(
203
+ 'code' => "final_price",
204
+ 'label' => "Final Price"
205
+ );
206
+ $options['Store Price'] = array(
207
+ 'code' => "store_price",
208
+ 'label' => "Store Price"
209
+ );
210
+ $options['Image 2'] = array(
211
+ 'code' => "image_2",
212
+ 'label' => "Image 2"
213
+ );
214
+ $options['Image 3'] = array(
215
+ 'code' => "image_3",
216
+ 'label' => "Image 3"
217
+ );
218
+ $options['Image 4'] = array(
219
+ 'code' => "image_4",
220
+ 'label' => "Image 4"
221
+ );
222
+ $options['Image 5'] = array(
223
+ 'code' => "image_5",
224
+ 'label' => "Image 5"
225
+ );
226
+ $options['Parent Product Base Image'] = array(
227
+ 'code' => "parent_base_image",
228
+ 'label' => "Parent Base Image"
229
+ );
230
+ $options['Category > SubCategory'] = array(
231
+ 'code' => "category_subcategory",
232
+ 'label' => "Category > SubCategory"
233
+ );
234
+ $options['Parent Product Name'] = array(
235
+ 'code' => "parent_name",
236
+ 'label' => "Parent Product Name"
237
+ );
238
+ $options['Parent Product SKU'] = array(
239
+ 'code' => "parent_sku",
240
+ 'label' => "Parent Product SKU"
241
+ );
242
+ $options['Parent Product URL'] = array(
243
+ 'code' => "parent_url",
244
+ 'label' => "Parent Product URL"
245
+ );
246
+ $options['Parent Product Description'] = array(
247
+ 'code' => "parent_description",
248
+ 'label' => "Parent Product Description"
249
+ );
250
+ $options['Parent Product Price'] = array(
251
+ 'code' => "parent_product_price",
252
+ 'label' => "Parent Product Price"
253
+ );
254
+ $options['Parent Product Special Price'] = array(
255
+ 'code' => "parent_product_special_price",
256
+ 'label' => "Parent Product Special Price"
257
+ );
258
+ $options['Parent Product Brand'] = array(
259
+ 'code' => "parent_brand",
260
+ 'label' => "Parent Product Brand"
261
+ );
262
+ $options['Product Product Image Url'] = array(
263
+ 'code' => "image_link",
264
+ 'label' => "Product Product Image Url"
265
+ );
266
+ $options['Parent Product Name with Simple Color Size'] = array(
267
+ 'code' => "parent_name_color_size",
268
+ 'label' => "Parent Product Name with Simple Color Size"
269
+ );
270
+
271
+
272
+ foreach (self::getAttributeCollection() as $attribute) {
273
+ if ($attribute->getFrontendLabel()) {
274
+ $options[$attribute->getFrontendLabel()] = array(
275
+ 'code' => $attribute->getAttributeCode(),
276
+ 'label' => ($attribute->getFrontendLabel() ? $attribute->getFrontendLabel() : $attribute->getAttributeCode())
277
+ );
278
+ /*$options['Parent '.$attribute->getFrontendLabel()] = array('code'=>'parent_'.$attribute->getAttributeCode(), 'label'=>($attribute->getFrontendLabel() ? 'Parent '.$attribute->getFrontendLabel() : 'Parent '.$attribute->getAttributeCode()));*/
279
+ }
280
+
281
+ }
282
+
283
+ ksort($options);
284
+
285
+ return $options;
286
+
287
+ }
288
+
289
+ public static function getAttributeSelect($i, $current = null, $active = true)
290
+ {
291
+
292
+ $options = array();
293
+
294
+ $options[] = "<option value=''>Not Set</option>";
295
+
296
+ foreach (self::getAttributeOptionsArray() as $attribute) {
297
+
298
+ extract($attribute);
299
+
300
+ $selected = '';
301
+
302
+ if ($code == $current) {
303
+ $selected = 'selected="selected"';
304
+ }
305
+
306
+ $options[] = "<option value=\"{$code}\" {$selected}>{$label}</option>";
307
+
308
+ }
309
+
310
+ return '<select style="width:260px;display:' . ($active ? 'block' : 'none') . '" id="mapping-' . $i . '-attribute-value" name="field[' . $i . '][attribute_value]">' . implode('', $options) . '</select>';
311
+
312
+ }
313
+
314
+ public static function getSystemSections()
315
+ {
316
+ $data = array();
317
+
318
+ $fileDir = Mage::getBaseDir('media') . DS . 'productsfeed' . DS . 'examples';
319
+ if (file_exists($fileDir) && $handle = opendir($fileDir)) {
320
+ while (false !== ($dir = readdir($handle))) {
321
+ if ($dir != '.' && $dir != '..') {
322
+ if (is_dir($fileDir . DS . $dir) && ($sub_handle = opendir($fileDir . DS . $dir))) {
323
+ $data[$dir] = array();
324
+ while (false !== ($file = readdir($sub_handle))) {
325
+ if ($file != '.' && $file != '..') {
326
+ $data[$dir][] = $file;
327
+ }
328
+ }
329
+ closedir($sub_handle);
330
+ }
331
+ }
332
+ }
333
+ closedir($handle);
334
+ }
335
+
336
+ return $data;
337
+
338
+ }
339
+
340
+ }
app/code/community/CP/Feed/Block/Adminhtml/Items/Edit/Tab/Content/Productcategory.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Block_Adminhtml_Items_Edit_Tab_Content_Productcategory extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Categories
23
+ {
24
+ public function __construct() {
25
+ parent::__construct();
26
+ $this->setTemplate('cp/feed/item/edit/category_product.phtml');
27
+ }
28
+ }
app/code/community/CP/Feed/Block/Adminhtml/Items/Edit/Tab/Main.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Block_Adminhtml_Items_Edit_Tab_Main extends Mage_Adminhtml_Block_Widget_Form
23
+ {
24
+
25
+
26
+
27
+
28
+
29
+ protected function _prepareForm()
30
+ {
31
+
32
+
33
+
34
+ $form = new Varien_Data_Form();
35
+
36
+
37
+
38
+ if (Mage::registry('cp_feed')) {
39
+
40
+ $item = Mage::registry('cp_feed');
41
+
42
+ } else {
43
+
44
+ $item = new Varien_Object();
45
+
46
+ }
47
+
48
+
49
+
50
+ $this->setForm($form);
51
+
52
+ $fieldset = $form->addFieldset('main_fieldset', array(
53
+ 'legend' => $this->__('Item information')
54
+ ));
55
+
56
+
57
+ $fieldset->addField('type', 'hidden', array(
58
+
59
+ 'name' => 'type'
60
+
61
+ ));
62
+
63
+
64
+
65
+ $fieldset->addField('name', 'text', array(
66
+
67
+ 'name' => 'name',
68
+
69
+ 'label' => $this->__('Name'),
70
+
71
+ 'title' => $this->__('Name'),
72
+
73
+ 'required' => true
74
+
75
+ ));
76
+
77
+ if ($item->getId() && ($url = $item->getUrl())) {
78
+
79
+
80
+
81
+ $fieldset->addField('comments', 'note', array(
82
+
83
+ 'label' => $this->__('Access Url'),
84
+
85
+ 'title' => $this->__('Access Url'),
86
+
87
+ 'text' => '<a href="' . $url . '" target="_blank">' . $url . '</a>'
88
+
89
+ ));
90
+
91
+ }
92
+
93
+
94
+
95
+ $fieldset->addField('filename', 'text', array(
96
+
97
+ 'name' => 'filename',
98
+
99
+ 'label' => $this->__('Filename'),
100
+
101
+ 'title' => $this->__('Filename'),
102
+
103
+ 'required' => false
104
+
105
+ ));
106
+
107
+
108
+
109
+ $fieldset->addField('store_id', 'select', array(
110
+
111
+ 'label' => $this->__('Store View'),
112
+
113
+ 'required' => true,
114
+
115
+ 'name' => 'store_id',
116
+
117
+ 'values' => Mage::getModel('cp_feed/adminhtml_system_config_source_store')->getStoreValuesForForm()
118
+
119
+ ));
120
+
121
+
122
+
123
+ if (!$item->getType() && $this->getRequest()->getParam('type')) {
124
+
125
+ $item->setType($this->getRequest()->getParam('type'));
126
+
127
+ }
128
+
129
+
130
+
131
+ $form->setValues($item->getData());
132
+
133
+
134
+
135
+
136
+
137
+ return parent::_prepareForm();
138
+
139
+
140
+
141
+ }
142
+
143
+
144
+
145
+
146
+
147
+ }
app/code/community/CP/Feed/Block/Adminhtml/Items/Edit/Tab/Type.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Block_Adminhtml_Items_Edit_Tab_Type extends Mage_Adminhtml_Block_Widget_Form
23
+ {
24
+
25
+
26
+
27
+ protected function _toHtml()
28
+ {
29
+
30
+
31
+
32
+ return parent::_toHtml() . '
33
+
34
+ <script type="text/javascript">
35
+
36
+ var templateSyntax = /(^|.|\r|\n)({{(\w+)}})/;
37
+
38
+ function setSettings(urlTemplate, typeElement) {
39
+
40
+ var template = new Template(urlTemplate, templateSyntax);
41
+
42
+
43
+
44
+ setLocation(template.evaluate({type:$F(typeElement)}));
45
+
46
+ }
47
+
48
+ </script>';
49
+
50
+
51
+
52
+ }
53
+
54
+
55
+
56
+ protected function _prepareLayout()
57
+ {
58
+
59
+ $this->setChild('continue_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
60
+
61
+ 'label' => $this->__('Continue'),
62
+
63
+ 'onclick' => "setSettings('" . $this->getContinueUrl() . "','type')",
64
+
65
+ 'class' => 'save'
66
+
67
+ )));
68
+
69
+ return parent::_prepareLayout();
70
+
71
+ }
72
+
73
+
74
+
75
+ public function getContinueUrl()
76
+ {
77
+
78
+ return $this->getUrl('*/*/new', array(
79
+
80
+ '_current' => true,
81
+
82
+ 'type' => '{{type}}'
83
+
84
+ ));
85
+
86
+ }
87
+
88
+
89
+
90
+ protected function _prepareForm()
91
+ {
92
+
93
+
94
+
95
+ $form = new Varien_Data_Form();
96
+
97
+
98
+
99
+ $this->setForm($form);
100
+
101
+ $fieldset = $form->addFieldset('main_fieldset', array(
102
+ 'legend' => $this->__('Settings')
103
+ ));
104
+
105
+
106
+
107
+ $fieldset->addField('type', 'select', array(
108
+
109
+ 'name' => 'type',
110
+
111
+ 'label' => $this->__('Feed Type'),
112
+
113
+ 'title' => $this->__('Feed Type'),
114
+
115
+ 'required' => true,
116
+
117
+ 'values' => array(
118
+ 'google' => 'Google Shopping',
119
+ /*'amazon' => 'Amazon Marketplace',
120
+ 'other' => 'CPC Strategy'*/
121
+ )
122
+
123
+ ));
124
+
125
+
126
+ $fieldset->addField('continue_button', 'note', array(
127
+
128
+ 'text' => $this->getChildHtml('continue_button')
129
+
130
+ ));
131
+
132
+ return parent::_prepareForm();
133
+
134
+
135
+
136
+ }
137
+
138
+
139
+
140
+
141
+
142
+ }
app/code/community/CP/Feed/Block/Adminhtml/Items/Edit/Tabs.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Block_Adminhtml_Items_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
23
+ {
24
+
25
+ public function __construct()
26
+ {
27
+
28
+
29
+
30
+ parent::__construct();
31
+
32
+ $this->setId('cp_feed_tabs');
33
+
34
+ $this->setDestElementId('edit_form');
35
+
36
+ $this->setTitle($this->__('Feed Information'));
37
+
38
+
39
+
40
+ }
41
+
42
+
43
+
44
+ protected function _prepareLayout()
45
+ {
46
+
47
+ if (($type = $this->getRequest()->getParam('type', null)) || (Mage::registry('cp_feed') && ($type = Mage::registry('cp_feed')->getType()))) {
48
+
49
+
50
+ $this->addTab('main_section', array(
51
+
52
+ 'label' => $this->__('Item information'),
53
+
54
+ 'title' => $this->__('Item information'),
55
+
56
+ 'content' => $this->getLayout()->createBlock('cp_feed/adminhtml_items_edit_tab_main')->toHtml()
57
+
58
+ ));
59
+
60
+ $this->addTab('content_section', array(
61
+
62
+ 'label' => $this->__('Content Settings'),
63
+
64
+ 'title' => $this->__('Content Settings'),
65
+
66
+ 'content' => $this->getLayout()->createBlock('cp_feed/adminhtml_items_edit_tab_content_csv')->setTemplate('cp/feed/item/edit/content.phtml')->toHtml()
67
+
68
+ ));
69
+
70
+
71
+ $this->addTab('advanced', array(
72
+
73
+ 'label' => $this->__('Advanced Settings'),
74
+
75
+ 'title' => $this->__('Advanced Settings'),
76
+
77
+ 'content' => $this->getLayout()->createBlock('cp_feed/adminhtml_items_edit_tab_advanced')->toHtml()
78
+
79
+ ));
80
+
81
+ $this->addTab('product_category', array(
82
+
83
+ 'label' => $this->__('Product categories'),
84
+
85
+ 'title' => $this->__('Product categories'),
86
+
87
+ 'content' => $this->getLayout()->createBlock('cp_feed/adminhtml_items_edit_tab_content_productcategory')->toHtml()
88
+
89
+ //->setTemplate('cp/feed/item/edit/category_product.phtml')->toHtml(),
90
+
91
+ ));
92
+
93
+ } else {
94
+
95
+
96
+
97
+ $this->addTab('main_section', array(
98
+
99
+ 'label' => $this->__('Content Settings'),
100
+
101
+ 'title' => $this->__('Content Settings'),
102
+
103
+ 'content' => $this->getLayout()->createBlock('cp_feed/adminhtml_items_edit_tab_type')->toHtml()
104
+
105
+ ));
106
+
107
+
108
+
109
+ }
110
+
111
+ if ($tabId = addslashes(htmlspecialchars($this->getRequest()->getParam('tab')))) {
112
+
113
+
114
+
115
+ $this->setActiveTab($tabId);
116
+
117
+ }
118
+
119
+
120
+
121
+
122
+
123
+ return parent::_beforeToHtml();
124
+
125
+
126
+
127
+ }
128
+
129
+
130
+
131
+ }
app/code/community/CP/Feed/Block/Adminhtml/Items/Grid.php ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Block_Adminhtml_Items_Grid extends Mage_Adminhtml_Block_Widget_Grid
23
+ {
24
+
25
+ public function __construct()
26
+ {
27
+
28
+ parent::__construct();
29
+
30
+ $this->setId('cpfeedsGrid');
31
+
32
+ $this->setDefaultSort('date');
33
+
34
+ $this->setDefaultDir('DESC');
35
+
36
+ $this->setSaveParametersInSession(true);
37
+
38
+ }
39
+
40
+
41
+
42
+ protected function _prepareCollection()
43
+ {
44
+
45
+ $collection = Mage::getModel('cp_feed/item')->getCollection();
46
+
47
+ $this->setCollection($collection);
48
+
49
+ return parent::_prepareCollection();
50
+
51
+ }
52
+
53
+
54
+
55
+ protected function _prepareColumns()
56
+ {
57
+
58
+ $this->addColumn('id', array(
59
+
60
+ 'header' => $this->__('ID'),
61
+
62
+ 'align' => 'left',
63
+
64
+ 'index' => 'id',
65
+
66
+ 'type' => 'number',
67
+
68
+ 'width' => '50px'
69
+
70
+ ));
71
+
72
+ $this->addColumn('name', array(
73
+
74
+ 'header' => $this->__('Name'),
75
+
76
+ 'align' => 'left',
77
+
78
+ 'index' => 'name'
79
+
80
+ ));
81
+
82
+ $this->addColumn('filename', array(
83
+
84
+ 'header' => $this->__('Access Url'),
85
+
86
+ 'align' => 'left',
87
+
88
+ 'index' => 'filename',
89
+
90
+ 'renderer' => 'Cp_Feed_Block_Adminhtml_Items_Grid_Renderer_AccessUrl'
91
+
92
+ ));
93
+
94
+ $this->addColumn('last_generated', array(
95
+
96
+ 'header' => $this->__('Last Generated'),
97
+
98
+ 'align' => 'left',
99
+
100
+ 'index' => 'generated_at',
101
+
102
+ 'type' => 'datetime',
103
+
104
+ 'renderer' => 'Cp_Feed_Block_Adminhtml_Items_Grid_Renderer_Datetime'
105
+
106
+ ));
107
+
108
+ $this->addColumn('store_id', array(
109
+
110
+ 'header' => $this->__('Store View'),
111
+
112
+ 'align' => 'left',
113
+
114
+ 'index' => 'store_id',
115
+
116
+ 'type' => 'store'
117
+
118
+ ));
119
+
120
+
121
+ $this->addColumn('action', array(
122
+
123
+ 'header' => $this->__('Action'),
124
+
125
+ 'width' => '100',
126
+
127
+ 'type' => 'action',
128
+
129
+ 'getter' => 'getId',
130
+
131
+ 'actions' => array(
132
+
133
+ array(
134
+
135
+ 'caption' => $this->__('Edit'),
136
+
137
+ 'url' => array(
138
+ 'base' => '*/*/edit'
139
+ ),
140
+
141
+ 'field' => 'id'
142
+
143
+ )
144
+
145
+ ),
146
+
147
+ 'filter' => false,
148
+
149
+ 'sortable' => false,
150
+
151
+ 'index' => 'stores',
152
+
153
+ 'is_system' => true
154
+
155
+ ));
156
+
157
+
158
+
159
+ return parent::_prepareColumns();
160
+
161
+
162
+
163
+ }
164
+
165
+
166
+
167
+ protected function _prepareMassaction()
168
+ {
169
+
170
+
171
+
172
+ $this->setMassactionIdField('id');
173
+
174
+ $this->getMassactionBlock()->setFormFieldName('id');
175
+
176
+
177
+
178
+ $this->getMassactionBlock()->addItem('delete', array(
179
+
180
+ 'label' => $this->__('Delete Feed(s)'),
181
+
182
+ 'url' => $this->getUrl('*/*/massDelete'),
183
+
184
+ 'confirm' => $this->__('Are you sure?')
185
+
186
+ ));
187
+
188
+
189
+
190
+
191
+
192
+ return $this;
193
+
194
+
195
+
196
+ }
197
+
198
+
199
+
200
+
201
+
202
+ protected function _afterLoadCollection()
203
+ {
204
+
205
+
206
+
207
+ $this->getCollection()->walk('afterLoad');
208
+
209
+ parent::_afterLoadCollection();
210
+
211
+
212
+
213
+ }
214
+
215
+
216
+
217
+ protected function _filterStoreCondition($collection, $column)
218
+ {
219
+
220
+
221
+
222
+ if (!$value = $column->getFilter()->getValue()) {
223
+
224
+ return;
225
+
226
+ }
227
+
228
+
229
+
230
+ $this->getCollection()->addStoreFilter($value);
231
+
232
+
233
+
234
+ }
235
+
236
+
237
+
238
+ public function getRowUrl($row)
239
+ {
240
+
241
+
242
+
243
+ return $this->getUrl('*/*/edit', array(
244
+ 'id' => $row->getId()
245
+ ));
246
+
247
+
248
+
249
+ }
250
+
251
+
252
+
253
+ }
app/code/community/CP/Feed/Block/Adminhtml/Items/Grid/Renderer/AccessUrl.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Block_Adminhtml_Items_Grid_Renderer_AccessUrl extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract{
23
+
24
+
25
+
26
+ public function render(Varien_Object $feed){
27
+
28
+
29
+
30
+ if($url = $feed->getUrl()){
31
+
32
+ return sprintf('<a href="%s" target="_blank">%s</a>', $url, $url);
33
+
34
+ }
35
+
36
+
37
+
38
+ }
39
+
40
+ }
app/code/community/CP/Feed/Block/Adminhtml/Items/Grid/Renderer/Datetime.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ class Cp_Feed_Block_Adminhtml_Items_Grid_Renderer_Datetime extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Datetime{
22
+
23
+
24
+
25
+ public function render(Varien_Object $row)
26
+
27
+ {
28
+
29
+ if('0000-00-00 00:00:00' == $this->_getValue($row)){
30
+
31
+
32
+
33
+ return $this->getColumn()->getDefault();
34
+
35
+
36
+
37
+ }
38
+
39
+ return parent::render($row);
40
+
41
+ }
42
+
43
+
44
+
45
+ }
app/code/community/CP/Feed/Helper/Data.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Helper_Data extends Mage_Core_Helper_Abstract{
23
+
24
+ public function getConfigData($node){
25
+ return Mage::getStoreConfig('cp_feed/'.$node);
26
+ }
27
+
28
+ public function getAllStoreDomains(){
29
+
30
+ $domains = array();
31
+
32
+ foreach (Mage::app()->getWebsites() as $website) {
33
+
34
+ $url = $website->getConfig('web/unsecure/base_url');
35
+
36
+ if($domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $url))){
37
+
38
+ $domains[] = $domain;
39
+
40
+ }
41
+
42
+ $url = $website->getConfig('web/secure/base_url');
43
+
44
+ if($domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $url))){
45
+
46
+ $domains[] = $domain;
47
+
48
+ }
49
+
50
+ }
51
+
52
+ return array_unique($domains);
53
+
54
+ }
55
+
56
+
57
+ public function getAmazonContentJson(){
58
+
59
+ $data = '[{"order":0,"name":"Id","attribute_value":"sku"},{"order":0,"name":"title","attribute_value":"name"},{"order":0,"name":"description","attribute_value":"description"},{"order":0,"name":"link","attribute_value":"url"},{"order":0,"name":"price","attribute_value":"price"},{"order":0,"name":"brand","attribute_value":"brand"},{"order":0,"name":"image_link","attribute_value":"image_link"},{"order":0,"name":"product_type","attribute_value":"product_type"},{"order":0,"name":"condition","attribute_value":"condition"},{"order":0,"name":"availability","attribute_value":"is_in_stock"},{"order":0,"name":"gtin","attribute_value":"gtin"},{"order":0,"name":"google_product_category","attribute_value":"google_product_category"},{"order":0,"name":"shipping_weight","attribute_value":"weight"},{"order":0,"name":"tax","attribute_value":"tax_class_id"},{"order":0,"name":"mpn","attribute_value":"mpn"},{"order":0,"name":"gender","attribute_value":"gender"},{"order":0,"name":"size","attribute_value":"size"},{"order":0,"name":"dispenser","attribute_value":"dispenser"},{"order":0,"name":"p_type","attribute_value":"p_type"},{"order":0,"name":"stock_qty","attribute_value":"qty"},{"order":0,"name":"amazon_price","attribute_value":"amazon_price"}]';
60
+
61
+ return $data;
62
+
63
+ }
64
+
65
+
66
+ public function getGoogleContentJson(){
67
+
68
+ $data = '[{"order":0,"name":"Id","attribute_value":"sku"},{"order":0,"name":"title","attribute_value":"name"},{"order":0,"name":"description","attribute_value":"description"},{"order":0,"name":"link","attribute_value":"url"},{"order":0,"name":"price","attribute_value":"price"},{"order":0,"name":"brand","attribute_value":"brand"},{"order":0,"name":"condition","attribute_value":"condition"},{"order":0,"name":"image_link","attribute_value":"image_link"},{"order":0,"name":"gtin","attribute_value":"gtin"},{"order":0,"name":"shipping","attribute_value":"shipment_type"},{"order":0,"name":"product_type","attribute_value":"product_type"},{"order":0,"name":"google_product_category","attribute_value":"google_product_category"},{"order":0,"name":"color","attribute_value":"color"},{"order":0,"name":"size","attribute_value":"size"},{"order":0,"name":"mpn","attribute_value":"mpn"},{"order":0,"name":"age group","attribute_value":"age_group"},{"order":0,"name":"gender","attribute_value":"gender"},{"order":0,"name":"availability","attribute_value":"is_in_stock"},{"order":0,"name":"c:druse:boolean","attribute_value":"c_druse"},{"order":0,"name":"item_group_id","attribute_value":"item_group_id"}]';
69
+
70
+ return $data;
71
+
72
+ }
73
+
74
+ }
app/code/community/CP/Feed/Model/Adminhtml/System/Config/Source/Store.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Model_Adminhtml_System_Config_Source_Store extends Mage_Adminhtml_Model_System_Store
23
+ {
24
+
25
+ }
app/code/community/CP/Feed/Model/Custom/Attribute.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Model_Custom_Attribute extends Mage_Core_Model_Abstract
23
+
24
+ {
25
+
26
+
27
+
28
+ public function _construct()
29
+
30
+ {
31
+
32
+ parent::_construct();
33
+
34
+ $this->_init('cp_feed/custom_attribute');
35
+
36
+ }
37
+
38
+
39
+
40
+ }
app/code/community/CP/Feed/Model/Item.php ADDED
@@ -0,0 +1,755 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Model_Item extends Mage_Core_Model_Abstract
23
+ {
24
+ protected $_productCollection;
25
+ protected $_categoryCollection;
26
+ protected $_parentProductsCache = array();
27
+
28
+ public function _construct()
29
+ {
30
+ parent::_construct();
31
+ $this->_init('cp_feed/item');
32
+ }
33
+
34
+ public function getBaseUrl($useRewrites = false)
35
+ {
36
+ $baseUrl = Mage::app()
37
+ ->getStore($this->getStoreId())
38
+ ->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, false);
39
+ if (!$useRewrites) {
40
+ $baseUrl .= 'index.php/';
41
+ }
42
+ return $baseUrl;
43
+ }
44
+
45
+ public function getProductUrl($product, $baseUrl)
46
+ {
47
+ $value = $baseUrl . $product->getUrlPath();
48
+ return $value;
49
+ }
50
+
51
+ public function getCategoriesCollection()
52
+ {
53
+ if (is_null($this->_categoryCollection)) {
54
+ $this->_categoryCollection = Mage::getResourceModel('catalog/category_collection')->addAttributeToSelect('name');
55
+ }
56
+ return $this->_categoryCollection;
57
+ }
58
+
59
+ public function getParentProduct(Varien_Object $product, $collection = null)
60
+ {
61
+ $childId = $product->getId();
62
+ if (!isset($this->_parentProductsCache[$childId])) {
63
+ $connection = Mage::getSingleton('core/resource')->getConnection('read');
64
+ $table = Mage::getSingleton('core/resource')->getTableName('catalog_product_relation');
65
+ $sql = 'SELECT `parent_id` FROM ' . $table . ' WHERE `child_id` = ' . intval($childId);
66
+ $parent_id = $connection->fetchOne($sql);
67
+ $parent_product = null;
68
+ if ($parent_id) {
69
+ if ($collection) {
70
+ $parent_product = $collection->getItemById($parent_id);
71
+ }
72
+ if (!$parent_product->getId()) {
73
+ $parent_product = Mage::getModel('catalog/product')->load($parent_id);
74
+ }
75
+ $this->_parentProductsCache[$childId] = $parent_product;
76
+ } else {
77
+ $this->_parentProductsCache[$childId] = new Varien_Object();
78
+ }
79
+ }
80
+ return $this->_parentProductsCache[$childId];
81
+ }
82
+
83
+ public function getRootCategory()
84
+ {
85
+ $category = Mage::getModel('catalog/category')->load(Mage::app()->getStore()->getRootCategoryId());
86
+ return $category;
87
+ }
88
+
89
+ public function getProductsCollection($filterData = '', $current_page = 0, $length = 50)
90
+ {
91
+ //if (is_null($this->_productCollection) && $this->getId()){
92
+ $collection = Mage::getModel('cp_feed/product_collection')->addAttributeToSelect('*');
93
+ $collection->addStoreFilter(Mage::app()->getStore());
94
+ /*if($length != 0){
95
+ $collection->setPage($current_page+1, $length);
96
+ }*/
97
+
98
+ $fileDir = sprintf('%s/productsfeed', Mage::getBaseDir('media'));
99
+
100
+ $collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
101
+ ->addMinimalPrice()
102
+ ->addFinalPrice()
103
+ ->addTaxPercents()
104
+ ->addUrlRewrite($this->getRootCategory()->getId());
105
+ $this->addStockToCollection($collection);
106
+
107
+
108
+ // Filter by Stock
109
+ if ($this->getUseLayer()) {
110
+ // filter only in stock product
111
+ // addSaleableFilterToCollection is required
112
+ // for Configurable products to properly manage the stock
113
+
114
+ Mage::getSingleton('cataloginventory/stock')
115
+ ->addInStockFilterToCollection($collection);
116
+
117
+ /* Mage::getSingleton('catalog/product_status')
118
+ ->addSaleableFilterToCollection($collection); */
119
+ }
120
+
121
+ // Filter Disabled
122
+ if ($this->getUseDisabled() == 1) {
123
+ $collection->addAttributeToFilter('status', 1);
124
+ }
125
+
126
+ if ($this->getProductCategories() != '') {
127
+ $categoryids = $myArray = explode(',', $this->getProductCategories());
128
+ $collection->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'left');
129
+ $collection->addAttributeToFilter('category_id', array(
130
+ 'in' => array(
131
+ $categoryids
132
+ )
133
+ ));
134
+ $collection->getSelect()->group('e.entity_id');
135
+ }
136
+
137
+ if ($this->getProductVisibility() != '' && $this->getProductVisibility() != '0') {
138
+ //echo $feed->getProductVisibility();
139
+ $collection->addAttributeToFilter('visibility', $this->getProductVisibility());
140
+ //echo 'Cnt--'.count($collection);
141
+ //exit;
142
+ }
143
+
144
+ $this->_productCollection = $collection;
145
+ //}
146
+ return $this->_productCollection;
147
+ }
148
+
149
+ public function _beforeSave()
150
+ {
151
+ if (!$this->getFilename()) {
152
+ $this->setFilename(preg_replace('/[^\w\d]/', '-', trim(strtolower($this->getName()))) . '.csv');
153
+ }
154
+ if (strpos($this->getFilename(), '.') === false) {
155
+ $this->setFilename($this->getFilename() . '.csv');
156
+ }
157
+ if ($id = Mage::getModel('cp_feed/item')->load($this->getFilename(), 'filename')->getId()) {
158
+ if ($id != $this->getId()) {
159
+ throw new Mage_Core_Exception(Mage::helper('cp_feed')->__('Filename "%s" exists', $this->getFilename()));
160
+ }
161
+ }
162
+ return parent::_beforeSave();
163
+ }
164
+
165
+ public function getDirPath()
166
+ {
167
+ return sprintf('%s/productsfeed', Mage::getBaseDir('media'));
168
+ }
169
+
170
+ public function getTempFilePath($start = '')
171
+ {
172
+ $filename = 'feed-gen-data-' . $this->getId() . $start . '.tmp';
173
+ return sprintf('%s/productsfeed/%s', Mage::getBaseDir('media'), $filename);
174
+ }
175
+
176
+ public function writeTempFile($start, $length, $filename = '')
177
+ {
178
+ try {
179
+ //echo " length ".$length;
180
+ $filePath = $this->getTempFilePath($start);
181
+ $fileDir = sprintf('%s/productsfeed', Mage::getBaseDir('media'));
182
+ $hasRewriteEnabled = Mage::getStoreConfig('web/seo/use_rewrites', $this->getStoreId());
183
+ $baseUrl = $this->getBaseUrl($hasRewriteEnabled);
184
+ if (!file_exists($fileDir)) {
185
+ mkdir($fileDir);
186
+ chmod($fileDir, 0777);
187
+ }
188
+ if (is_dir($fileDir)) {
189
+ switch ($this->getDelimiter()) {
190
+ case('comma'):
191
+ default:
192
+ $delimiter = ",";
193
+ break;
194
+ case('tab'):
195
+ $delimiter = "\t";
196
+ break;
197
+ case('colon'):
198
+ $delimiter = ":";
199
+ break;
200
+ case('space'):
201
+ $delimiter = " ";
202
+ break;
203
+ case('vertical pipe'):
204
+ $delimiter = "|";
205
+ break;
206
+ case('semi-colon'):
207
+ $delimiter = ";";
208
+ break;
209
+ }
210
+ switch ($this->getEnclosure()) {
211
+ case(1):
212
+ default:
213
+ $enclosure = "'";
214
+ break;
215
+ case(2):
216
+ $enclosure = '"';
217
+ break;
218
+ case(3):
219
+ $enclosure = ' ';
220
+ break;
221
+ }
222
+ $collection = $this->getProductsCollection();
223
+ $collection->getSelect()->limit($length, $start);
224
+ //echo "<br><br>Count: ". count($collection);
225
+ $maping = json_decode($this->getContent());
226
+ $fp = fopen($filePath, 'w');
227
+ $codes = array();
228
+ foreach ($maping as $col) {
229
+ //echo "<pre>";print_r($col);exit;
230
+ //if($col->type == 'attribute'){
231
+ $codes[] = $col->attribute_value;
232
+ //}
233
+ }
234
+ $attributes = Mage::getModel('eav/entity_attribute')
235
+ ->getCollection()
236
+ ->setEntityTypeFilter(Mage::getResourceModel('catalog/product')->getEntityType()->getData('entity_type_id'))
237
+ ->setCodeFilter($codes);
238
+ $log_fp = fopen(sprintf('%s/productsfeed/%s', Mage::getBaseDir('media'), 'log-' . $this->getId() . '.txt'), 'a');
239
+ fwrite($log_fp, date("F j, Y, g:i:s a") . ', page:' . $start . ', items selected:' . count($collection) . "\n");
240
+ fclose($log_fp);
241
+ $store = Mage::getModel('core/store')->load($this->getStoreId());
242
+ $root_category = Mage::getModel('catalog/category')->load($store->getRootCategoryId());
243
+ if (Mage::getStoreConfig('cp_feedpro/imagesettings/enable')) {
244
+ $image_width = intval(Mage::getStoreConfig('cp_feedpro/imagesettings/width'));
245
+ $image_height = intval(Mage::getStoreConfig('cp_feedpro/imagesettings/height'));
246
+ } else {
247
+ $image_width = 0;
248
+ $image_height = 0;
249
+ }
250
+ foreach ($collection as $product) {
251
+ //echo "<br>Product: ".$product->getId();
252
+ $fields = array();
253
+ $category = null;
254
+ foreach ($product->getCategoryIds() as $id) {
255
+ $_category = $this->getCategoriesCollection()->getItemById($id);
256
+ if (is_null($category) || ($category && $_category && $category->getLevel() < $_category->getLevel())) {
257
+ $category = $_category;
258
+ }
259
+ }
260
+ if ($category) {
261
+ $category_path = array($category->getName());
262
+ $parent_id = $category->getParentId();
263
+ if ($category->getLevel() > $root_category->getLevel()) {
264
+ while ($_category = $this->getCategoriesCollection()->getItemById($parent_id)) {
265
+ if ($_category->getLevel() <= $root_category->getLevel()) {
266
+ break;
267
+ }
268
+ $category_path[] = $_category->getName();
269
+ $parent_id = $_category->getParentId();
270
+ }
271
+ }
272
+ $product->setCategory($category->getName());
273
+ $product->setCategoryId($category->getEntityId());
274
+ $product->setCategorySubcategory(implode(' > ', array_reverse($category_path)));
275
+ } else {
276
+ $product->setCategory('');
277
+ $product->setCategorySubcategory('');
278
+ }
279
+ $parent_product = $this->getParentProduct($product, $collection);
280
+ $_prod = Mage::getModel('catalog/product')->load($product->getId());
281
+ foreach ($maping as $col) {
282
+ $value = null;
283
+ if ($col->attribute_value) {
284
+ switch ($col->attribute_value) {
285
+ case ('parent_sku'):
286
+ if ($parent_product && $parent_product->getEntityId()) {
287
+ $value = $parent_product->getSku();
288
+ } else {
289
+ $value = '';
290
+ }
291
+ break;
292
+ case ('price'):
293
+ if (in_array($product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_GROUPED, Mage_Catalog_Model_Product_Type::TYPE_BUNDLE)))
294
+ $value = $store->convertPrice($product->getMinimalPrice(), false, false);
295
+ else
296
+ $value = $store->convertPrice($product->getPrice(), false, false);
297
+ break;
298
+ case ('store_price'):
299
+ $value = $store->convertPrice($product->getFinalPrice(), false, false);
300
+ break;
301
+ case ('parent_url'):
302
+ if ($parent_product && $parent_product->getEntityId()) {
303
+ $value = $this->getProductUrl($parent_product, $baseUrl);
304
+ // $value = $parent_product->getProductUrl(false);
305
+ } else {
306
+ $value = $this->getProductUrl($product, $baseUrl);
307
+ }
308
+ break;
309
+ case 'parent_base_image':
310
+ if ($parent_product && $parent_product->getEntityId() > 0) {
311
+ $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
312
+ }
313
+ try {
314
+ if ($image_width || $image_height) {
315
+ $image_url = (string)Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
316
+ } else {
317
+ $image_url = (string)Mage::helper('catalog/image')->init($_prod, 'image');
318
+ }
319
+ } catch (Exception $e) {
320
+ $image_url = '';
321
+ }
322
+ $value = $image_url;
323
+ break;
324
+ case 'parent_description':
325
+ $description = '';
326
+ if ($parent_product && $parent_product->getEntityId() > 0) {
327
+ $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
328
+ }
329
+ try {
330
+ $description = $_prod->getDescription();
331
+ } catch (Exception $e) {
332
+ $description = '';
333
+ }
334
+ $value = $description;
335
+ break;
336
+ case 'parent_product_price':
337
+ if ($parent_product && $parent_product->getEntityId() > 0) {
338
+ $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
339
+ }
340
+ try {
341
+ $price = $_prod->getResource()->getAttribute('price')->getFrontend()->getValue($_prod);
342
+ } catch (Exception $e) {
343
+ $price = '';
344
+ }
345
+ $value = number_format($price);
346
+ break;
347
+ case 'parent_product_special_price':
348
+ if ($parent_product && $parent_product->getEntityId() > 0) {
349
+ $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
350
+ }
351
+ try {
352
+ $specialprice = $_prod->getResource()->getAttribute('special_price')->getFrontend()->getValue($_prod);
353
+ } catch (Exception $e) {
354
+ $specialprice = '';
355
+ }
356
+ $value = number_format($specialprice);
357
+ break;
358
+ case 'parent_brand':
359
+ $brand = '';
360
+ if ($parent_product && $parent_product->getEntityId() > 0) {
361
+ $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
362
+ try {
363
+ $brandAttr = $_prod->getResource()->getAttribute('brand');
364
+ if ($brandAttr){
365
+ $brand = $brandAttr->getFrontend()->getValue($_prod);
366
+ }
367
+ } catch (Exception $e) {
368
+ $brand = '';
369
+ }
370
+ }
371
+ $value = $brand;
372
+ break;
373
+ case 'image_link':
374
+ $url = Mage::getBaseUrl('media') . "catalog/product" . $_prod->getImage();
375
+ if (!$_prod->getImage()) {
376
+ if ($parent_product && $parent_product->getEntityId() > 0) {
377
+ $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
378
+ $url = Mage::getBaseUrl('media') . "catalog/product" . $_prod->getImage();
379
+ }
380
+ } else {
381
+ $url = Mage::getBaseUrl('media') . "catalog/product" . $_prod->getImage();
382
+ }
383
+ if ($url == Mage::getBaseUrl('media') . "catalog/product" || $url == Mage::getBaseUrl('media') . "catalog/productno_selection") {
384
+ $url = Mage::getBaseUrl('media') . "catalog/product/i/m/img-na-450_1.jpg";
385
+ }
386
+ $value = $url;
387
+ break;
388
+ case 'parent_name':
389
+ if ($parent_product && $parent_product->getEntityId() > 0) {
390
+ $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
391
+ $name = $_prod->getName();
392
+ } else {
393
+ $name = '';
394
+ }
395
+ $value = $name;
396
+ break;
397
+ case('image'):
398
+ case('gallery'):
399
+ case('media_gallery'):
400
+ if (!$product->hasData('product_base_image')) {
401
+ try {
402
+ if ($image_width || $image_height) {
403
+ $image_url = (string)Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
404
+ } else {
405
+ $image_url = (string)Mage::helper('catalog/image')->init($_prod, 'image');
406
+ }
407
+ } catch (Exception $e) {
408
+ $image_url = '';
409
+ }
410
+ $product->setData('product_base_image', $image_url);
411
+ $value = $image_url;
412
+ } else {
413
+ $value = $product->getData('product_base_image');
414
+ }
415
+ break;
416
+ case('image_2'):
417
+ case('image_3'):
418
+ case('image_4'):
419
+ case('image_5'):
420
+ if (!$product->hasData('media_gallery_images')) {
421
+ $product->setData('media_gallery_images', $_prod->getMediaGalleryImages());
422
+ }
423
+ $i = 0;
424
+ foreach ($product->getMediaGalleryImages() as $_image) {
425
+ $i++;
426
+ if (('image_' . $i) == $col->attribute_value) {
427
+ if ($image_width || $image_height) {
428
+ $value = (string)Mage::helper('catalog/image')->init($product, 'image', $_image->getFile())->resize($image_width, $image_height);
429
+ } else {
430
+ $value = $_image['url'];
431
+ }
432
+ }
433
+ }
434
+ break;
435
+ case('url'):
436
+ $value = $this->getProductUrl($product, $baseUrl);
437
+ // $value = $product->getProductUrl();
438
+ break;
439
+ case('qty'):
440
+ $value = ceil((int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty());
441
+ break;
442
+ case('category'):
443
+ $value = $product->getCategory();
444
+ break;
445
+ case ('product_type'):
446
+ $value = $product->getTypeId();
447
+ break;
448
+ case('is_in_stock'):
449
+ // $value = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
450
+ $value = $product->getData('is_in_stock');
451
+ // $value = $product->getData('is_salable');
452
+ break;
453
+ default:
454
+ if ($attribute = $attributes->getItemByColumnValue('attribute_code', $col->attribute_value)) {
455
+ if ($attribute->getFrontendInput() == 'select' || $attribute->getFrontendInput() == 'multiselect') {
456
+ $value = implode(', ', (array)$product->getAttributeText($col->attribute_value));
457
+ } else {
458
+ $value = $product->getData($col->attribute_value);
459
+ }
460
+ } else {
461
+ $value = $product->getData($col->attribute_value);
462
+ }
463
+ break;
464
+ }
465
+ } else {
466
+ $value = '';
467
+ }
468
+ $fields[] = $value;
469
+ }
470
+ if ($enclosure != ' ') {
471
+ fputcsv($fp, $fields, $delimiter, $enclosure);
472
+ } else {
473
+ $this->myfputcsv($fp, $fields, $delimiter);
474
+ }
475
+ // only simple can be unset or we will lose the parents
476
+ if ($product->getTypeId() == 'simple') {
477
+ $product->clearInstance();
478
+ }
479
+ }
480
+ fclose($fp);
481
+ foreach ($this->_parentProductsCache as $one_cache_key => $one_cache_val) {
482
+ if ($one_cache_val != null && $one_cache_val instanceof Mage_Core_Model_Abstract) {
483
+ $one_cache_val->clearInstance();
484
+ }
485
+ unset($this->_parentProductsCache[$one_cache_key]);
486
+ unset($one_cache_val);
487
+ }
488
+ $this->_parentProductsCache = array();
489
+ $collection->clear();
490
+ unset($collection);
491
+ gc_collect_cycles();
492
+ }
493
+ } catch (Mage_Core_Exception $e) {
494
+ //mail('___CHANGEME___','exception1',$e->getMessage());
495
+ } catch (Exception $e) {
496
+ Mage::logException($e);
497
+ //mail('___CHANGEME___',' exception #2', date('r') ."\n===============================================\n". $e->getMessage() ."\n\n=========================================\n". $e->getTraceAsString() );
498
+ }
499
+ }
500
+
501
+ public function generateFeed()
502
+ {
503
+ //ini_set("memory_limit", "-1");
504
+ //ini_set("upload_max_filesize", "100M");
505
+ //ini_set("post_max_size", "100M");
506
+ //set_time_limit(intval(9999999));
507
+ //ini_set("max_execution_time", 9999999);
508
+ $fileDir = sprintf('%s/productsfeed', Mage::getBaseDir('media'));
509
+ $filePath = sprintf('%s/productsfeed/%s', Mage::getBaseDir('media'), $this->getFilename());
510
+ $logFilepath = sprintf('%s/productsfeed/%s', Mage::getBaseDir('media'), 'log-' . $this->getId() . '.txt');
511
+ @unlink($filePath);
512
+ @unlink($logFilepath);
513
+ if (!file_exists($fileDir)) {
514
+ mkdir($fileDir);
515
+ chmod($fileDir, 0777);
516
+ }
517
+ if (is_dir($fileDir)) {
518
+ switch ($this->getDelimiter()) {
519
+ case('comma'):
520
+ default:
521
+ $delimiter = ",";
522
+ break;
523
+ case('tab'):
524
+ $delimiter = "\t";
525
+ break;
526
+ case('colon'):
527
+ $delimiter = ":";
528
+ break;
529
+ case('space'):
530
+ $delimiter = " ";
531
+ break;
532
+ case('vertical pipe'):
533
+ $delimiter = "|";
534
+ break;
535
+ case('semi-colon'):
536
+ $delimiter = ";";
537
+ break;
538
+ }
539
+ switch ($this->getEnclosure()) {
540
+ case(1):
541
+ default:
542
+ $enclosure = "'";
543
+ break;
544
+ case(2):
545
+ $enclosure = '"';
546
+ break;
547
+ case(3):
548
+ $enclosure = ' ';
549
+ break;
550
+ }
551
+ $maping = json_decode($this->getContent());
552
+ $fp = fopen($filePath, 'w');
553
+ if ($this->getData('use_addition_header') == 1) {
554
+ fwrite($fp, $this->getData('addition_header'));
555
+ }
556
+ if ($this->getShowHeaders()) {
557
+ $fields = array();
558
+ foreach ($maping as $col) {
559
+ $fields[] = $col->name;
560
+ }
561
+ fputcsv($fp, $fields, $delimiter, $enclosure);
562
+ }
563
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
564
+ for ($i = 0; $i < 2000000; $i += 500) {
565
+ $current_time = time();
566
+ $write->query("UPDATE cp_feed SET vartimestamp='$current_time' WHERE id=1");
567
+ //continue;
568
+ $this->writeTempFile($i, 500);
569
+ if (0 == filesize($this->getTempFilePath($i))) {
570
+ if (file_exists($this->getTempFilePath($i))) {
571
+ unlink($this->getTempFilePath($i));
572
+ }
573
+ break;
574
+ } else {
575
+ $csv_data = @file_get_contents($this->getTempFilePath($i));
576
+ fwrite($fp, $csv_data);
577
+ unset($csv_data);
578
+ gc_collect_cycles();
579
+ if (file_exists($this->getTempFilePath($i))) {
580
+ unlink($this->getTempFilePath($i));
581
+ }
582
+ }
583
+ }
584
+ //mail('___CHANGEME___','Done Feed','FEED Done - Memory Usage : '. round( ( memory_get_usage() / 1024 / 1024 ) , 2 ) . date('r') ."\n===============================================\n" );
585
+ //fwrite($fp, $csv_data);
586
+ /* if (file_exists($this->getTempFilePath()))
587
+ {
588
+ unlink($this->getTempFilePath());
589
+ }
590
+ fclose($fp);*/
591
+ }
592
+ $this->setData('restart_cron', 0);
593
+ $this->setData('generated_at', date('Y-m-j H:i:s', time()));
594
+ $this->save();
595
+ }
596
+
597
+ public function generate()
598
+ {
599
+ $fileDir = sprintf('%s/productsfeed', Mage::getBaseDir('media'));
600
+ $filePath = sprintf('%s/productsfeed/%s', Mage::getBaseDir('media'), $this->getFilename());
601
+ $logFilepath = sprintf('%s/productsfeed/%s', Mage::getBaseDir('media'), 'log-' . $this->getId() . '.txt');
602
+ @unlink($filePath);
603
+ @unlink($logFilepath);
604
+ $filePath = sprintf('%s/productsfeed/%s', Mage::getBaseDir('media'), $this->getFilename());
605
+ if (!file_exists($fileDir)) {
606
+ mkdir($fileDir);
607
+ chmod($fileDir, 0777);
608
+ }
609
+ if (is_dir($fileDir)) {
610
+ switch ($this->getDelimiter()) {
611
+ case('comma'):
612
+ default:
613
+ $delimiter = ",";
614
+ break;
615
+ case('tab'):
616
+ $delimiter = "\t";
617
+ break;
618
+ case('colon'):
619
+ $delimiter = ":";
620
+ break;
621
+ case('space'):
622
+ $delimiter = " ";
623
+ break;
624
+ case('vertical pipe'):
625
+ $delimiter = "|";
626
+ break;
627
+ case('semi-colon'):
628
+ $delimiter = ";";
629
+ break;
630
+ }
631
+ //$delimiter = $this->getDelimiter();
632
+ switch ($this->getEnclosure()) {
633
+ case(1):
634
+ default:
635
+ $enclosure = "'";
636
+ break;
637
+ case(2):
638
+ $enclosure = '"';
639
+ break;
640
+ case(3):
641
+ $enclosure = ' ';
642
+ break;
643
+ }
644
+ $maping = json_decode($this->getContent());
645
+ $fp = fopen($filePath, 'w');
646
+ if ($this->getData('use_addition_header') == 1) {
647
+ fwrite($fp, $this->getData('addition_header'));
648
+ }
649
+ if ($this->getShowHeaders()) {
650
+ $fields = array();
651
+ foreach ($maping as $col) {
652
+ $fields[] = $col->name;
653
+ }
654
+ fputcsv($fp, $fields, $delimiter, $enclosure);
655
+ }
656
+ if ($csv_data = @file_get_contents($this->getTempFilePath())) {
657
+ fwrite($fp, $csv_data);
658
+ }
659
+ if (file_exists($this->getTempFilePath())) {
660
+ unlink($this->getTempFilePath());
661
+ }
662
+ fclose($fp);
663
+ }
664
+ $this->setData('generated_at', date('Y-m-j H:i:s', time()));
665
+ $this->save();
666
+ }
667
+
668
+ public function getUrl()
669
+ {
670
+ $file_path = sprintf('productsfeed/%s', $this->getFilename());
671
+ if (file_exists(Mage::getBaseDir('media') . '/' . $file_path)) {
672
+ return Mage::getBaseUrl('media', false) . $file_path;
673
+ }
674
+ return '';
675
+ }
676
+
677
+ public function delete()
678
+ {
679
+ if ($this->getFilename()) {
680
+ $fileDir = sprintf('%s/productsfeed', Mage::getBaseDir('media'));
681
+ $filePath = sprintf('%s/productsfeed/%s', Mage::getBaseDir('media'), $this->getFilename());
682
+ $logFilepath = sprintf('%s/productsfeed/%s', Mage::getBaseDir('media'), 'log-' . $this->getId() . '.txt');
683
+ @unlink($filePath);
684
+ @unlink($logFilepath);
685
+ }
686
+ return parent::delete();
687
+ }
688
+
689
+ public function myfputcsv($fp, $fields, $delimiter = ';', $enclosure = ' ')
690
+ {
691
+ for ($i = 0; $i < sizeof($fields); $i++) {
692
+ $use_enclosure = false;
693
+ if (strpos($fields[$i], $delimiter) !== false) {
694
+ $use_enclosure = true;
695
+ }
696
+ if (strpos($fields[$i], $enclosure) !== false) {
697
+ $use_enclosure = true;
698
+ }
699
+ if (strpos($fields[$i], "\\") !== false) {
700
+ $use_enclosure = true;
701
+ }
702
+ if (strpos($fields[$i], "\n") !== false) {
703
+ $use_enclosure = true;
704
+ }
705
+ if (strpos($fields[$i], "\r") !== false) {
706
+ $use_enclosure = true;
707
+ }
708
+ if (strpos($fields[$i], "\t") !== false) {
709
+ $use_enclosure = true;
710
+ }
711
+ if (strpos($fields[$i], " ") !== false) {
712
+ $use_enclosure = true;
713
+ }
714
+ if ($use_enclosure == true) {
715
+ $fields[$i] = explode("\$enclosure", $fields[$i]);
716
+ for ($j = 0; $j < sizeof($fields[$i]); $j++) {
717
+ $fields[$i][$j] = explode($enclosure, $fields[$i][$j]);
718
+ $fields[$i][$j] = implode("{$enclosure}", $fields[$i][$j]);
719
+ }
720
+ $fields[$i] = implode("\$enclosure", $fields[$i]);
721
+ $fields[$i] = "{$fields[$i]}";
722
+ }
723
+ }
724
+ return fwrite($fp, implode($delimiter, $fields) . "\n");
725
+ }
726
+
727
+ public function addStockToCollection($collection)
728
+ {
729
+ $manageStockConfig = Mage::getStoreConfig('cataloginventory/item_options/manage_stock', $this->getStoreId());
730
+ $stkConditions = 'e.entity_id=stk.product_id';
731
+
732
+ if ($manageStockConfig) {
733
+ // System Manage stock is On
734
+ $ifCase = $this->_getCheckSql('(stk.use_config_manage_stock = 1 OR ( stk.use_config_manage_stock = 0 AND stk.manage_stock = 1) )', 'stk.is_in_stock', '1');
735
+ } else {
736
+ // System Manage stock is On
737
+ $ifCase = $this->_getCheckSql('((stk.use_config_manage_stock = 0 AND stk.manage_stock = 0 ) OR (stk.use_config_manage_stock = 1))', '1', 'stk.is_in_stock');
738
+ }
739
+
740
+ $collection->getSelect()->join(
741
+ array('stk' => $collection->getTable('cataloginventory/stock_item')), $stkConditions, array('is_in_stock' => $ifCase, 'manage_stock', 'use_config_manage_stock'));
742
+ // die((string)$collection->getSelect());
743
+ }
744
+
745
+ protected function _getCheckSql($expression, $true, $false)
746
+ {
747
+ if ($expression instanceof Zend_Db_Expr || $expression instanceof Zend_Db_Select) {
748
+ $expression = sprintf("IF((%s), %s, %s)", $expression, $true, $false);
749
+ } else {
750
+ $expression = sprintf("IF(%s, %s, %s)", $expression, $true, $false);
751
+ }
752
+
753
+ return new Zend_Db_Expr($expression);
754
+ }
755
+ }
app/code/community/CP/Feed/Model/Item/Block.php ADDED
@@ -0,0 +1,369 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Model_Item_Block extends Varien_Object
23
+ {
24
+ protected $content = '';
25
+ protected $pattern = '/\\{\\{block\b(.*?)\\}\\}(.*)\\{\\{\\/block\\}\\}/is';
26
+ protected $var_pattern = '/\\{\\{var:(.+?)(\s.*?)?\\}\\}/s';
27
+ protected $increment_id = 0;
28
+ protected $children = array();
29
+ protected $feed;
30
+
31
+ public function getFeed(){
32
+ return $this->feed;
33
+ }
34
+ public function setFeed(Cp_Feed_Model_Item $feed){
35
+ $this->feed = $feed;
36
+ return $this;
37
+ }
38
+
39
+
40
+ public function __construct($vars){
41
+
42
+ extract($vars);
43
+
44
+ if($feed instanceof Cp_Feed_Model_Item){
45
+
46
+ $this->feed = $feed;
47
+
48
+ $this->setDate(Date('Y-m-d H:i'));
49
+
50
+ if(isset($content) && $content){
51
+ if(isset($is_xml) && $is_xml){
52
+ $this->content = (string)$content;
53
+ }else{
54
+
55
+ $content = str_replace('<', '|lquote|', $content);
56
+ $content = str_replace('>', '|rquote|', $content);
57
+
58
+ $content = preg_replace('/{{(block.*?)}}/is', '<$1>', $content);
59
+ $content = preg_replace('/{{(\\/block)}}/is', '<$1>', $content);
60
+
61
+ $this->content = $content;
62
+
63
+ }
64
+ $this->parse();
65
+
66
+ }
67
+
68
+ }else{
69
+ throw new Exception('Feed must be instane of "Cp_Feed_Model_Item"');
70
+ }
71
+ }
72
+
73
+ protected function _parseChildBlocks(){
74
+
75
+
76
+
77
+ }
78
+
79
+
80
+
81
+ protected function parse(){
82
+
83
+ $match_block = array();
84
+
85
+
86
+
87
+ $xml = new Varien_Simplexml_Config(sprintf('<xml><body>%s</body></xml>', $this->content));
88
+
89
+ $root = $xml->getNode()->descend('body');
90
+
91
+ $this->content = preg_replace('/<body\b.*?>(.*)<\\/body>/is', '$1', (string)$root->asXML());
92
+
93
+
94
+ foreach($root->children() as $nodeName=>$xml_block){
95
+ /*
96
+ while(preg_match($this->pattern, $this->content, $match_block)){
97
+ if(isset($match_block[2]) && ($content = trim($match_block[2]))){ /**/
98
+
99
+ $wrapper = trim($xml_block->asXML());
100
+
101
+ $content = trim(preg_replace('/<block\b.*?>(.*)<\\/block>/is', '\1', $wrapper));
102
+
103
+ /*
104
+
105
+ $attributes = array();
106
+
107
+ if(isset($match_block[1]) && $match_block[1]){
108
+
109
+ $_attributes = array();
110
+
111
+ preg_match_all('/(.*?)\="(.*?)"/', $match_block[1], $_attributes);
112
+
113
+ $attribute_count = count($_attributes[0]);
114
+
115
+ for($i=0;$i<$attribute_count;$i++){
116
+
117
+ if(isset($_attributes[1][$i]) && isset($_attributes[2][$i]) ){
118
+
119
+ $attributes[trim($_attributes[1][$i])] = trim($_attributes[2][$i]);
120
+
121
+ }
122
+
123
+ }
124
+
125
+ }
126
+ */
127
+ $block = null;
128
+
129
+ if(($type = $xml_block->getAttribute('type')) && ($modelClassName = Mage::getConfig()->getModelClassName('cp_feed/item_block_'.strtolower($type)))){
130
+
131
+ try{
132
+
133
+ class_exists($modelClassName);
134
+
135
+ $block = new $modelClassName(array('content'=>$content, 'feed'=>$this->feed, 'is_xml'=>1));
136
+
137
+ if(false == ($block instanceof Cp_Feed_Model_Item_Block)){
138
+
139
+ $block = null;
140
+
141
+ }
142
+
143
+ }catch(Exception $e){
144
+ $block = null;
145
+ }
146
+
147
+ }
148
+
149
+ if(is_null($block)){
150
+
151
+ $block = Mage::getModel('cp_feed/item_block', array('content'=>$content, 'feed'=>$this->feed, 'is_xml'=>1));
152
+
153
+ }
154
+
155
+ $attrs = array();
156
+
157
+ foreach($xml_block->attributes() as $key=>$value){
158
+ $attrs[$key] = $value;
159
+ }
160
+
161
+ $block->addData($attrs);
162
+
163
+
164
+ /*
165
+ if(!empty($attributes)){
166
+
167
+ $block->addData($attributes);
168
+
169
+ }
170
+ */
171
+
172
+ $this->children[$this->increment_id] = $block;
173
+
174
+ $this->content = str_replace($wrapper, sprintf('{{block:%d}}', $this->increment_id), $this->content);
175
+
176
+ $this->increment_id++;
177
+
178
+ /*}*/
179
+
180
+ }
181
+ }
182
+ public function getChildren(){
183
+ return $this->children;
184
+ }
185
+ public function getContent(){
186
+ return $this->content;
187
+ }
188
+ public function render(){
189
+
190
+ foreach($this->children as $id=>$block){
191
+ $this->content = str_replace(sprintf('{{block:%d}}', $id), $block->render(), $this->content);
192
+ }
193
+
194
+ $this->content = str_replace('|lquote|', '<', $this->content);
195
+ $this->content = str_replace('|rquote|', '>', $this->content);
196
+
197
+
198
+ return $this->setVars($this->content, null, (get_class($this) == 'Cp_Feed_Model_Item_Block'));
199
+
200
+ }
201
+
202
+ public function applyAttribute($attribute_name, $attribute_value, $value){
203
+
204
+
205
+ switch(trim($attribute_name)){
206
+ case 'format':
207
+
208
+ switch(trim($attribute_value)){
209
+ case 'float':
210
+
211
+ $value = number_format($value, 2, '.', '');
212
+
213
+ break;
214
+
215
+ case 'int':
216
+
217
+ $value = intval($value);
218
+
219
+ break;
220
+
221
+ case 'striptags':
222
+
223
+ $value = strip_tags($value);
224
+ $value = trim($value);
225
+
226
+ break;
227
+
228
+ case 'htmlspecialchars':
229
+ $encoding = mb_detect_encoding($value);
230
+ $value = mb_convert_encoding($value, "UTF-8", $encoding);
231
+ $value = htmlentities($value, null, "UTF-8");
232
+ break;
233
+
234
+ case 'htmlspecialchars_decode':
235
+
236
+ $value = htmlspecialchars_decode($value);
237
+
238
+ break;
239
+
240
+ case 'delete_space':
241
+
242
+ $value = str_replace(" ", "", $value);
243
+
244
+ break;
245
+
246
+ }
247
+
248
+ break;
249
+
250
+ case 'limit':
251
+ if(intval($attribute_value) && $value){
252
+ $value = substr($value, 0, intval($attribute_value));
253
+ }
254
+ break;
255
+
256
+ }
257
+
258
+ return $value;
259
+
260
+ }
261
+
262
+ public function getAllVars($content = null){
263
+
264
+ if(is_null($content)){
265
+ $content = $this->getContent();
266
+ }
267
+
268
+ $vars = array();
269
+ $match = array();
270
+
271
+ preg_match_all($this->var_pattern, $content, $match);
272
+
273
+ if($var_num = count($match[0])){
274
+
275
+ while($var_num--){
276
+ $vars[] = $match[1][$var_num];
277
+ }
278
+
279
+ }
280
+
281
+ return $vars;
282
+
283
+ }
284
+
285
+ public function setVars($content = null, $dataObject = null, $clearVars = false){
286
+
287
+ if(is_null($content)){
288
+ $content = $this->getContent();
289
+ }
290
+ if(is_null($dataObject)){
291
+ $dataObject = $this;
292
+ }
293
+
294
+ $match = array();
295
+
296
+ preg_match_all('/{{var:(.+?)(\s.*?)?}}/s', $content, $match);
297
+
298
+
299
+ if(!empty($match)){
300
+
301
+ if($var_num = count($match[0])){
302
+
303
+ while($var_num--){
304
+
305
+ $props = explode('.', $match[1][$var_num]);
306
+ reset($props);
307
+
308
+ $value = '';
309
+
310
+ if($props_count = count($props)){
311
+
312
+ try{
313
+
314
+ $value = $dataObject->getData($props[0]);
315
+
316
+ if($props_count > 1){
317
+
318
+ for($i = 1; $i < $props_count;$i++){
319
+
320
+ if($value instanceof Varien_Object){
321
+
322
+ $value = $value->getData($props[$i]);
323
+
324
+ }else{
325
+
326
+ break;
327
+
328
+ }
329
+
330
+ }
331
+
332
+ }
333
+
334
+ $attributes = array();
335
+
336
+ if($attributes_value = $match[2][$var_num]){
337
+
338
+ preg_match_all('/(.*?)\="(.*?)"/s', $attributes_value, $attributes);
339
+
340
+ foreach($attributes[1] as $i=>$attribute_name){
341
+
342
+ $value = $this->applyAttribute($attribute_name, $attributes[2][$i], $value);
343
+
344
+ }
345
+
346
+ }
347
+
348
+ }catch(Exception $e){
349
+ $value = '';
350
+ }
351
+
352
+
353
+ if($value !== null || $clearVars == true){
354
+
355
+ $content = str_replace($match[0][$var_num], strval($value), $content);
356
+
357
+ }
358
+
359
+ }
360
+ }
361
+ }
362
+ }
363
+
364
+ return $content;
365
+ }
366
+
367
+ }
368
+
369
+
app/code/community/CP/Feed/Model/Item/Block/Category.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Model_Item_Block_Category extends Cp_Feed_Model_Item_Block{
23
+
24
+ public function setVars($content = null, $dataObject=null, $remove_empty=false){
25
+
26
+
27
+
28
+ $categories = $this->getFeed()->getCategoriesCollection();
29
+
30
+
31
+
32
+ $contents = array();
33
+
34
+
35
+
36
+ foreach($categories as $category){
37
+
38
+
39
+
40
+ if($category->getLevel() > 1){
41
+
42
+
43
+
44
+ $contents[] = parent::setVars($content, $category);
45
+
46
+
47
+
48
+ }
49
+
50
+
51
+
52
+ }
53
+
54
+
55
+
56
+ return implode("\r\n", $contents);
57
+
58
+
59
+
60
+ }
61
+
62
+
63
+
64
+ }
app/code/community/CP/Feed/Model/Item/Block/Product.php ADDED
@@ -0,0 +1,483 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Model_Item_Block_Product extends Cp_Feed_Model_Item_Block
23
+ {
24
+ public function writeTempFile($curr_page = 0, $length = 50, $filename = '')
25
+ {
26
+ $products = $this->getFeed()->getProductsCollection('', $curr_page, $length);
27
+ $stock_collection = Mage::getResourceModel('cataloginventory/stock_item_collection');
28
+ $content = file_get_contents($this->getFeed()->getDirPath() . '/feed-' . $this->getFeed()->getId() . '-xml-product-block-template.tmp');
29
+ $fp = fopen($this->getFeed()->getTempFilePath(), 'a');
30
+ $log_fp = fopen(sprintf('%s/productsfeed/%s', Mage::getBaseDir('media'), 'log-' . $this->getFeed()->getId() . '.txt'), 'a');
31
+ $log_content = date("F j, Y, g:i:s a") . ', page:' . $curr_page . ', items selected:' . count($products) . "\n";
32
+ fwrite($log_fp, $log_content);
33
+ fclose($log_fp);
34
+ $store = Mage::getModel('core/store')->load($this->getFeed()->getStoreId());
35
+ $root_category = Mage::getModel('catalog/category')->load($store->getRootCategoryId());
36
+ if (Mage::getStoreConfig('cp_feedpro/imagesettings/enable')) {
37
+ $image_width = intval(Mage::getStoreConfig('cp_feedpro/imagesettings/width'));
38
+ $image_height = intval(Mage::getStoreConfig('cp_feedpro/imagesettings/height'));
39
+ } else {
40
+ $image_width = 0;
41
+ $image_height = 0;
42
+ }
43
+ foreach ($products as $_product) {
44
+ $category_path = array();
45
+ $category = null;
46
+ foreach ($_product->getCategoryIds() as $id) {
47
+ $_category = $this->getFeed()->getCategoriesCollection()->getItemById($id);
48
+ if (is_null($category) || ($category && $_category && $category->getLevel() < $_category->getLevel())) {
49
+ $category = $_category;
50
+ }
51
+ }
52
+ if ($category) {
53
+ $category_path = array($category->getName());
54
+ $parent_id = $category->getParentId();
55
+ if ($category->getLevel() > $root_category->getLevel()) {
56
+ while ($_category = $this->getFeed()->getCategoriesCollection()->getItemById($parent_id)) {
57
+ if ($_category->getLevel() <= $root_category->getLevel()) {
58
+ break;
59
+ }
60
+ $category_path[] = $_category->getName();
61
+ $parent_id = $_category->getParentId();
62
+ }
63
+ }
64
+ }
65
+ $product = new Varien_Object();
66
+ if ($category) {
67
+ $product->setCategory($category->getName());
68
+ $product->setCategoryId($category->getEntityId());
69
+ $product->setCategorySubcategory(implode(' -&gt; ', array_reverse($category_path)));
70
+ } else {
71
+ $product->setCategory('');
72
+ $product->setCategorySubcategory('');
73
+ }
74
+ $template_attributes = $this->getAllVars($content);
75
+ $custom_attributes = Mage::getResourceModel('cp_feed/custom_attribute_collection');
76
+ $custom_attributes->load();
77
+ foreach ($template_attributes as $attribute_code) {
78
+ $value = null;
79
+ switch ($attribute_code):
80
+ case ('parent_sku'):
81
+ if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
82
+ $value = $parent_product->getSku();
83
+ } else {
84
+ $value = '';
85
+ }
86
+ break;
87
+ case 'parent_base_image':
88
+ if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
89
+ $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
90
+ } else {
91
+ $_prod = Mage::getModel('catalog/product')->load($_product->getId());
92
+ }
93
+ try {
94
+ if ($image_width || $image_height) {
95
+ $image_url = (string)Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
96
+ } else {
97
+ $image_url = (string)Mage::helper('catalog/image')->init($_prod, 'image');
98
+ }
99
+ } catch (Exception $e) {
100
+ $image_url = '';
101
+ }
102
+ $value = $image_url;
103
+ break;
104
+ case ('price'):
105
+ if (in_array($_product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_GROUPED, Mage_Catalog_Model_Product_Type::TYPE_BUNDLE)))
106
+ $value = $store->convertPrice($_product->getMinimalPrice(), false, false);
107
+ else
108
+ $value = $store->convertPrice($_product->getPrice(), false, false);
109
+ break;
110
+ case ('store_price'):
111
+ case ('final_price'):
112
+ $value = $store->convertPrice($_product->getFinalPrice(), false, false);
113
+ break;
114
+ case('image'):
115
+ case('gallery'):
116
+ case('media_gallery'):
117
+ $_prod = Mage::getModel('catalog/product')->load($_product->getId());
118
+ try {
119
+ if ($image_width || $image_height) {
120
+ $image_url = (string)Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
121
+ } else {
122
+ $image_url = (string)Mage::helper('catalog/image')->init($_prod, 'image');
123
+ }
124
+ } catch (Exception $e) {
125
+ $image_url = '';
126
+ }
127
+ $product->setData($attribute_code, $image_url);
128
+ break;
129
+ case('image_2'):
130
+ case('image_3'):
131
+ case('image_4'):
132
+ case('image_5'):
133
+ if (!$_product->hasData('media_gallery_images')) {
134
+ $_prod = Mage::getModel('catalog/product')->load($_product->getId());
135
+ $_product->setData('media_gallery_images', $_prod->getMediaGalleryImages());
136
+ }
137
+ $i = 0;
138
+ foreach ($_product->getMediaGalleryImages() as $_image) {
139
+ $i++;
140
+ if (('image_' . $i) == $attribute_code) {
141
+ if ($image_width || $image_height) {
142
+ $product->setData($attribute_code, (string)Mage::helper('catalog/image')->init($_product, 'image', $_image->getFile())->resize($image_width, $image_height));
143
+ } else {
144
+ $product->setData($attribute_code, $_image['url']);
145
+ }
146
+ }
147
+ }
148
+ break;
149
+ case ('parent_url'):
150
+ if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
151
+ $product->setParentUrl($parent_product->getProductUrl(false));
152
+ break;
153
+ }
154
+ $product->setParentUrl($_product->getProductUrl(false));
155
+ break;
156
+ case('url'):
157
+ $product->setUrl($_product->getProductUrl(false));
158
+ break;
159
+ default:
160
+ if (strpos($attribute_code, 'custom:') === 0) {
161
+ $custom_code = trim(str_replace('custom:', '', $attribute_code));
162
+ if ($custom_attribute = $custom_attributes->getItemByColumnValue('code', $custom_code)) {
163
+ $options = Zend_Json::decode($custom_attribute->getData('data'));
164
+ foreach ($options as $option) {
165
+ foreach ($option['condition'] as $condition) {
166
+ switch ($condition['attribute_code']):
167
+ case ('product_type'):
168
+ $attr_value = $_product->getTypeId();
169
+ break;
170
+ case ('price'):
171
+ if (in_array($_product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_GROUPED, Mage_Catalog_Model_Product_Type::TYPE_BUNDLE)))
172
+ $attr_value = $store->convertPrice($_product->getMinimalPrice(), false, false);
173
+ else
174
+ $attr_value = $store->convertPrice($_product->getPrice(), false, false);
175
+ break;
176
+ case ('store_price'):
177
+ $attr_value = $store->convertPrice($_product->getFinalPrice(), false, false);
178
+ break;
179
+ case ('parent_url'):
180
+ if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
181
+ $attr_value = $parent_product->getProductUrl(false);
182
+ break;
183
+ }
184
+ $attr_value = $_product->getProductUrl(false);
185
+ break;
186
+ case('image'):
187
+ case('gallery'):
188
+ case('media_gallery'):
189
+ if (!$_product->hasData('product_base_image')) {
190
+ $_prod = Mage::getModel('catalog/product')->load($_product->getId());
191
+ try {
192
+ if ($image_width || $image_height) {
193
+ $image_url = (string)Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
194
+ } else {
195
+ $image_url = (string)Mage::helper('catalog/image')->init($_prod, 'image');
196
+ }
197
+ } catch (Exception $e) {
198
+ $image_url = '';
199
+ }
200
+ $_product->setData('product_base_image', $image_url);
201
+ $attr_value = $image_url;
202
+ } else {
203
+ $attr_value = $_product->getData('product_base_image');
204
+ }
205
+ break;
206
+ case('url'):
207
+ $attr_value = $_product->getProductUrl(false);
208
+ break;
209
+ case('qty'):
210
+ if ($stock_item = $stock_collection->getItemByColumnValue('product_id', $_product->getId())) {
211
+ $attr_value = ceil($stock_collection->getItemByColumnValue('product_id', $_product->getId())->getQty());
212
+ } else {
213
+ $attr_value = 0;
214
+ }
215
+ break;
216
+ case('is_in_stock'):
217
+ if ($stock_item = $stock_collection->getItemByColumnValue('product_id', $_product->getId())) {
218
+ $attr_value = $stock_collection->getItemByColumnValue('product_id', $_product->getId())->getData('is_in_stock');
219
+ } else {
220
+ $attr_value = 0;
221
+ }
222
+ break;
223
+ case('category'):
224
+ $attr_value = $product->getCategory();
225
+ break;
226
+ case('category_id'):
227
+ $attr_value = $_product->getCategoryIds();
228
+ break;
229
+ default:
230
+ $attr_value = $_product->getData($condition['attribute_code']);
231
+ endswitch;
232
+ $cond_value = $condition['value'];
233
+ $is_multi = false;
234
+ if ($product_attribute = $_product->getResource()->getAttribute($condition['attribute_code'])) {
235
+ if ($product_attribute->getFrontendInput() == 'multiselect') {
236
+ $is_multi = true;
237
+ $attr_value = explode(',', $attr_value);
238
+ }
239
+ }
240
+ if ($condition['attribute_code'] == 'category_id') {
241
+ $is_multi = true;
242
+ }
243
+ switch ($condition['condition']):
244
+ case('eq'):
245
+ if (!$is_multi && $attr_value == $cond_value || $is_multi && in_array($cond_value, $attr_value)) {
246
+ continue 2;
247
+ } else {
248
+ continue 3;
249
+ }
250
+ break;
251
+ case('neq'):
252
+ if (!$is_multi && $attr_value != $cond_value || $is_multi && !in_array($cond_value, $attr_value)) {
253
+ continue 2;
254
+ } else {
255
+ continue 3;
256
+ }
257
+ break;
258
+ case('gt'):
259
+ if ($attr_value > $cond_value) {
260
+ continue 2;
261
+ } else {
262
+ continue 3;
263
+ }
264
+ break;
265
+ case('lt'):
266
+ if ($attr_value < $cond_value) {
267
+ continue 2;
268
+ } else {
269
+ continue 3;
270
+ }
271
+ break;
272
+ case('gteq'):
273
+ if ($attr_value >= $cond_value) {
274
+ continue 2;
275
+ } else {
276
+ continue 3;
277
+ }
278
+ break;
279
+ case('lteq'):
280
+ if ($attr_value <= $cond_value) {
281
+ continue 2;
282
+ } else {
283
+ continue 3;
284
+ }
285
+ break;
286
+ case('like'):
287
+ if (strpos($attr_value, $cond_value) !== false) {
288
+ continue 2;
289
+ } else {
290
+ continue 3;
291
+ }
292
+ break;
293
+ case('nlike'):
294
+ if (strpos($attr_value, $cond_value) === false) {
295
+ continue 2;
296
+ } else {
297
+ continue 3;
298
+ }
299
+ break;
300
+ endswitch;
301
+ }
302
+ if (in_array($option['value_type'], array('percent', 'attribute'))) {
303
+ switch ($option['value_type_attribute']):
304
+ case ('price'):
305
+ if (in_array($_product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_GROUPED, Mage_Catalog_Model_Product_Type::TYPE_BUNDLE)))
306
+ $attribute_value = $store->convertPrice($_product->getMinimalPrice(), false, false);
307
+ else
308
+ $attribute_value = $store->convertPrice($_product->getPrice(), false, false);
309
+ break;
310
+ case ('store_price'):
311
+ $attribute_value = $store->convertPrice($_product->getFinalPrice(), false, false);
312
+ break;
313
+ case ('parent_url'):
314
+ if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
315
+ $attribute_value = $parent_product->getProductUrl(false);
316
+ break;
317
+ }
318
+ $attribute_value = $_product->getProductUrl(false);
319
+ break;
320
+ case('image'):
321
+ case('gallery'):
322
+ case('media_gallery'):
323
+ if (!$_product->hasData('product_base_image')) {
324
+ $_prod = Mage::getModel('catalog/product')->load($_product->getId());
325
+ try {
326
+ if ($image_width || $image_height) {
327
+ $image_url = (string)Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
328
+ } else {
329
+ $image_url = (string)Mage::helper('catalog/image')->init($_prod, 'image');
330
+ }
331
+ } catch (Exception $e) {
332
+ $image_url = '';
333
+ }
334
+ $_product->setData('product_base_image', $image_url);
335
+ $attribute_value = $image_url;
336
+ } else {
337
+ $attribute_value = $_product->getData('product_base_image');
338
+ }
339
+ break;
340
+ case('url'):
341
+ $attribute_value = $_product->getProductUrl(false);
342
+ break;
343
+ case('qty'):
344
+ if ($stock_item = $stock_collection->getItemByColumnValue('product_id', $_product->getId())) {
345
+ $attribute_value = ceil($stock_collection->getItemByColumnValue('product_id', $_product->getId())->getQty());
346
+ } else {
347
+ $attribute_value = 0;
348
+ }
349
+ break;
350
+ case('category'):
351
+ $attribute_value = $product->getCategory();
352
+ break;
353
+ default:
354
+ $attribute_value = $_product->getData($option['value_type_attribute']);
355
+ endswitch;
356
+ }
357
+ if ($option['value_type'] == 'percent') {
358
+ $value = floatval($attribute_value) / 100 * floatval($option['value']);
359
+ } elseif ($option['value_type'] == 'attribute') {
360
+ $value = $attribute_value;
361
+ } else {
362
+ $value = $option['value'];
363
+ }
364
+ break;
365
+ }
366
+ if ($value === null && $custom_attribute->getDefaultValue()) {
367
+ switch ($custom_attribute->getDefaultValue()):
368
+ case ('price'):
369
+ if (in_array($_product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_GROUPED, Mage_Catalog_Model_Product_Type::TYPE_BUNDLE)))
370
+ $value = $store->convertPrice($_product->getMinimalPrice(), false, false);
371
+ else
372
+ $value = $store->convertPrice($_product->getPrice(), false, false);
373
+ break;
374
+ case ('store_price'):
375
+ $value = $store->convertPrice($_product->getFinalPrice(), false, false);
376
+ break;
377
+ case ('parent_url'):
378
+ if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
379
+ $value = $parent_product->getProductUrl(false);
380
+ break;
381
+ }
382
+ $value = $_product->getProductUrl(false);
383
+ break;
384
+ case('image'):
385
+ case('gallery'):
386
+ case('media_gallery'):
387
+ if (!$_product->hasData('product_base_image')) {
388
+ $_prod = Mage::getModel('catalog/product')->load($_product->getId());
389
+ try {
390
+ if ($image_width || $image_height) {
391
+ $image_url = (string)Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
392
+ } else {
393
+ $image_url = (string)Mage::helper('catalog/image')->init($_prod, 'image');
394
+ }
395
+ } catch (Exception $e) {
396
+ $image_url = '';
397
+ }
398
+ $_product->setData('product_base_image', $image_url);
399
+ $value = $image_url;
400
+ } else {
401
+ $value = $_product->getData('product_base_image');
402
+ }
403
+ break;
404
+ case('url'):
405
+ $value = $_product->getProductUrl(false);
406
+ break;
407
+ case('qty'):
408
+ if ($stock_item = $stock_collection->getItemByColumnValue('product_id', $_product->getId())) {
409
+ $value = ceil($stock_collection->getItemByColumnValue('product_id', $_product->getId())->getQty());
410
+ } else {
411
+ $value = 0;
412
+ }
413
+ break;
414
+ case('category'):
415
+ $value = $product->getCategory();
416
+ break;
417
+ default:
418
+ $value = $_product->getData($custom_attribute->getDefaultValue());
419
+ endswitch;
420
+ }
421
+ }
422
+ } elseif ($attribute_model = $_product->getResource()->getAttribute($attribute_code)) {
423
+ switch ($attribute_model->getFrontendInput()):
424
+ case ('select'):
425
+ case ('multiselect'):
426
+ $value = implode(', ', (array)$_product->getAttributeText($attribute_code));
427
+ break;
428
+ default:
429
+ $value = $_product->getData($attribute_code);
430
+ break;
431
+ endswitch;
432
+ }
433
+ break;
434
+ endswitch;
435
+ if ($value && !$product->getData($attribute_code)) {
436
+ $product->setData($attribute_code, $value);
437
+ }
438
+ }
439
+ $product->setDescription(strip_tags(preg_replace('/<br.*?>/s', "\r\n", $_product->getDescription())));
440
+ $product->setShortDescription(strip_tags(preg_replace('/<br.*?>/s', "\r\n", $_product->getShortDescription())));
441
+ $product->setQty(ceil(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()));
442
+ fwrite($fp, parent::setVars($content, $product) . "\r\n");
443
+ }
444
+ fclose($fp);
445
+ }
446
+
447
+ public function setVars($content = null, $dataObject = null, $remove_empty = false)
448
+ {
449
+ $template_temp_file = $this->getFeed()->getDirPath() . '/feed-' . $this->getFeed()->getId() . '-xml-product-block-template.tmp';
450
+ file_put_contents($template_temp_file, $content);
451
+ $collection = $this->getFeed()->getProductsCollection();
452
+ $total_products = $collection->getSize();
453
+ $per_page = intval($this->getFeed()->getIterationLimit());
454
+ if ($per_page) {
455
+ $pages = ceil($total_products / $per_page);
456
+ } else {
457
+ $pages = 1;
458
+ $per_page = 0;
459
+ }
460
+ file_put_contents(sprintf('%s/productsfeed', Mage::getBaseDir('media')) . '/log-' . $this->getFeed()->getId() . '.txt', "started at:" . date("F j, Y, g:i:s a") . ", pages:{$pages}, per_page:{$per_page} \n");
461
+ for ($i = 0; $i < $pages; $i++) {
462
+ if ($_fp = fopen(Mage::getSingleton('core/store')->load($this->getFeed()->getStoreId())->getUrl('feed/index/index', array('id' => $this->getFeed()->getId(), 'start' => $i, 'length' => $per_page, '_nosid' => true)), 'r')) {
463
+ $contents = '';
464
+ while (!feof($_fp)) {
465
+ $contents .= fread($_fp, 8192);
466
+ }
467
+ $response = Zend_Json::decode($contents);
468
+ if (!isset($response['result']) || !$response['result']) {
469
+ throw new Mage_Core_Exception(Mage::helper('cp_feed')->__('There was an error while generating file. Change "Number of Products" in the Advanced Settings.
470
+ Try to change "Number of Products" in the Advanced Settings.
471
+ For example: set "Number of Products" equal 50 or 100.'));
472
+ }
473
+ } else {
474
+ throw new Mage_Core_Exception(Mage::helper('cp_feed')->__('Cant open temp file'));
475
+ }
476
+ fclose($_fp);
477
+ }
478
+ $content = file_get_contents($this->getFeed()->getTempFilePath());
479
+ unlink($template_temp_file);
480
+ unlink($this->getFeed()->getTempFilePath());
481
+ return $content;
482
+ }
483
+ }
app/code/community/CP/Feed/Model/Mysql4/Custom/Attribute.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Model_Mysql4_Custom_Attribute extends Mage_Core_Model_Mysql4_Abstract
23
+
24
+ {
25
+
26
+ public function _construct()
27
+
28
+ {
29
+
30
+ $this->_init('cp_feed/custom_attribute', 'id');
31
+
32
+ }
33
+
34
+
35
+
36
+ }
app/code/community/CP/Feed/Model/Mysql4/Custom/Attribute/Collection.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Model_Mysql4_Custom_Attribute_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
23
+
24
+ {
25
+
26
+ public function _construct()
27
+
28
+ {
29
+
30
+ parent::_construct();
31
+
32
+ $this->_init('cp_feed/custom_attribute');
33
+
34
+ }
35
+
36
+
37
+
38
+ }
app/code/community/CP/Feed/Model/Mysql4/Item.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Model_Mysql4_Item extends Mage_Core_Model_Mysql4_Abstract
23
+
24
+ {
25
+
26
+ public function _construct()
27
+
28
+ {
29
+
30
+ $this->_init('cp_feed/item', 'id');
31
+
32
+ }
33
+
34
+
35
+
36
+ }
app/code/community/CP/Feed/Model/Mysql4/Item/Collection.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Model_Mysql4_Item_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
23
+
24
+ {
25
+
26
+ public function _construct()
27
+
28
+ {
29
+
30
+ parent::_construct();
31
+
32
+ $this->_init('cp_feed/item');
33
+
34
+ }
35
+
36
+
37
+
38
+ }
app/code/community/CP/Feed/Model/Observer.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Model_Observer extends Mage_Cron_Model_Observer
23
+ {
24
+ protected function _isWrongTimeStamp(){
25
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
26
+ $result = $write->query("SELECT vartimestamp FROM cp_feed WHERE id=1");
27
+ /** @var $result Varien_Db_Statement_Pdo_Mysql */
28
+ $row = $result->fetchAll();
29
+ $prev_timestamp = $row[0]['vartimestamp'] + (60 * 4);
30
+
31
+ return ($prev_timestamp > time());
32
+ }
33
+
34
+ /* public function proccessFeedsTest()
35
+ {
36
+
37
+ $saveTestimonial = Mage::getModel('testimonial/testimonial');
38
+ $saveTestimonial->setName('Cp_Feed_Model_Observer');
39
+ $saveTestimonial->save();
40
+
41
+ $msg = "First line of text\nSecond line1414 of text";
42
+ $msg = wordwrap($msg,70);
43
+ mail("commerce.pundit61@gmail.com","My subject",$msg);
44
+ } */
45
+
46
+ public function proccessFeeds()
47
+ {
48
+
49
+ if ($this->_isWrongTimeStamp()) {
50
+ // Handle the exit
51
+ return;
52
+ }
53
+
54
+
55
+ $collection = Mage::getResourceModel('cp_feed/item_collection')
56
+ //->addFieldToFilter('restart_cron', '1')
57
+ ->addFieldToFilter('upload_day', array(
58
+ 'like' => '%' . strtolower(date('D')) . '%'
59
+ ));
60
+ //echo count($collection);
61
+ //exit;
62
+
63
+
64
+ foreach ($collection as $feed) {
65
+ try {
66
+ /** @var $feed Cp_Feed_Model_Item */
67
+ $feed->generateFeed();
68
+ $feed->clearInstance();
69
+ unset($feed);
70
+ // }
71
+ } catch (Exception $e) {
72
+ $feed->setData('restart_cron', intval($feed->getData('restart_cron')) + 1);
73
+ $feed->save();
74
+ continue;
75
+ }
76
+ }
77
+
78
+
79
+ }
80
+
81
+ static function generateAll()
82
+ {
83
+ $collection = Mage::getResourceModel('cp_feed / item_collection');
84
+ foreach ($collection as $feed) {
85
+ try {
86
+ Mage::app()->setCurrentStore($feed->getStoreId());
87
+ $feed->generate();
88
+ } catch (Exception $e) {
89
+ continue;
90
+ }
91
+ }
92
+ }
93
+
94
+ }
app/code/community/CP/Feed/Model/Option/Productcategories.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Model_Option_Productcategories extends Varien_Object
23
+ {
24
+ const REPEATER = '_';
25
+ const PREFIX_END = '';
26
+ protected $_options = array();
27
+ /**
28
+ * @param int $parentId
29
+ * @param int $recursionLevel
30
+ *
31
+ * @return array
32
+ */
33
+ public function getOptionArray($parentId = 1, $recursionLevel = 3)
34
+ {
35
+ $recursionLevel = (int)$recursionLevel;
36
+ $parentId = (int)$parentId;
37
+ $category = Mage::getModel('catalog/category');
38
+ /* @var $category Mage_Catalog_Model_Category */
39
+ $storeCategories = $category->getCategories($parentId, $recursionLevel, TRUE, FALSE, TRUE);
40
+ foreach ($storeCategories as $node) {
41
+ /* @var $node Varien_Data_Tree_Node */
42
+ $this->_options[] = array(
43
+ 'label' => $node->getName(),
44
+ 'value' => $node->getEntityId()
45
+ );
46
+ if ($node->hasChildren()) {
47
+ $this->_getChildOptions($node->getChildren());
48
+ }
49
+ }
50
+ return $this->_options;
51
+ }
52
+ /**
53
+ * @param Varien_Data_Tree_Node_Collection $nodeCollection
54
+ */
55
+ protected function _getChildOptions(Varien_Data_Tree_Node_Collection $nodeCollection)
56
+ {
57
+ foreach ($nodeCollection as $node) {
58
+ /* @var $node Varien_Data_Tree_Node */
59
+ $prefix = str_repeat(self::REPEATER, $node->getLevel() * 1) . self::PREFIX_END;
60
+ $this->_options[] = array(
61
+ 'label' => $prefix . $node->getName(),
62
+ 'value' => $node->getEntityId()
63
+ );
64
+ if ($node->hasChildren()) {
65
+ $this->_getChildOptions($node->getChildren());
66
+ }
67
+ }
68
+ }
69
+ }
app/code/community/CP/Feed/Model/Product/Collection.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Model_Product_Collection extends Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
23
+ {
24
+
25
+ protected $_feed_categories = array();
26
+ protected $_prepared_feed_categories = array(
27
+ 'inclusion' => array(),
28
+ 'exclusion' => array());
29
+
30
+ public function isEnabledFlat()
31
+ {
32
+ return false;
33
+ }
34
+
35
+ protected function _productLimitationJoinPrice()
36
+ {
37
+ $filters = $this->_productLimitationFilters;
38
+ if (empty($filters['use_price_index'])) {
39
+ return $this;
40
+ }
41
+
42
+ $connection = $this->getConnection();
43
+
44
+ $joinCond = $joinCond = join(' AND ', array(
45
+ 'price_index.entity_id = e.entity_id',
46
+ $connection->quoteInto('price_index.website_id = ?', $filters['website_id']),
47
+ $connection->quoteInto('price_index.customer_group_id = ?', $filters['customer_group_id'])
48
+ ));
49
+
50
+ $fromPart = $this->getSelect()->getPart(Zend_Db_Select::FROM);
51
+ if (!isset($fromPart['price_index'])) {
52
+ $minimalExpr = new Zend_Db_Expr(
53
+ 'IF(`price_index`.`tier_price`, LEAST(`price_index`.`min_price`, `price_index`.`tier_price`), `price_index`.`min_price`)'
54
+ );
55
+ $this->getSelect()->joinLeft(
56
+ array('price_index' => $this->getTable('catalog/product_index_price')),
57
+ $joinCond,
58
+ array('price', 'tax_class_id', 'final_price', 'minimal_price' => $minimalExpr, 'min_price', 'max_price', 'tier_price')
59
+ );
60
+
61
+ // Set additional field filters
62
+ if (isset($this->_priceDataFieldFilters) && is_array($this->_priceDataFieldFilters)) {
63
+ foreach ($this->_priceDataFieldFilters as $filterData) {
64
+ $this->getSelect()->where(call_user_func_array('sprintf', $filterData));
65
+ }
66
+ }
67
+ } else {
68
+ $fromPart['price_index']['joinCondition'] = $joinCond;
69
+ $this->getSelect()->setPart(Zend_Db_Select::FROM, $fromPart);
70
+ }
71
+
72
+ return $this;
73
+ }
74
+
75
+ protected function _applyProductLimitations()
76
+ {
77
+ $this->_prepareProductLimitationFilters();
78
+ $this->_productLimitationJoinWebsite();
79
+ $this->_productLimitationJoinPrice();
80
+ $filters = $this->_productLimitationFilters;
81
+
82
+ if (!(isset($filters['category_id']) || count($this->_feed_categories)) && !isset($filters['visibility'])) {
83
+ return $this;
84
+ }
85
+
86
+ $conditions = array(
87
+ 'cat_index.product_id=e.entity_id',
88
+ $this->getConnection()->quoteInto('cat_index.store_id=?', $filters['store_id'])
89
+ );
90
+ if (isset($filters['visibility']) && !isset($filters['store_table'])) {
91
+ $conditions[] = $this->getConnection()
92
+ ->quoteInto('cat_index.visibility IN(?)', $filters['visibility']);
93
+ }
94
+
95
+ if (count($this->_feed_categories)) {
96
+ $conditions[] = $this->getConnection()
97
+ ->quoteInto('cat_index.category_id IN(?)', $this->_feed_categories);
98
+ $this->getSelect()->distinct();
99
+ } else
100
+ $conditions[] = $this->getConnection()
101
+ ->quoteInto('cat_index.category_id=?', $filters['category_id']);
102
+
103
+
104
+ if (isset($filters['category_is_anchor'])) {
105
+ $conditions[] = $this->getConnection()
106
+ ->quoteInto('cat_index.is_parent=?', $filters['category_is_anchor']);
107
+ }
108
+
109
+ $joinCond = join(' AND ', $conditions);
110
+ $fromPart = $this->getSelect()->getPart(Zend_Db_Select::FROM);
111
+ if (isset($fromPart['cat_index'])) {
112
+ $fromPart['cat_index']['joinCondition'] = $joinCond;
113
+ $this->getSelect()->setPart(Zend_Db_Select::FROM, $fromPart);
114
+ } else {
115
+ $this->getSelect()->join(
116
+ array('cat_index' => $this->getTable('catalog/category_product_index')),
117
+ $joinCond,
118
+ array('cat_index_position' => 0)
119
+ );
120
+ }
121
+
122
+ if (method_exists($this, '_productLimitationJoinStore'))
123
+ $this->_productLimitationJoinStore();
124
+
125
+ Mage::dispatchEvent('catalog_product_collection_apply_limitations_after', array(
126
+ 'collection' => $this
127
+ ));
128
+
129
+ return $this;
130
+ }
131
+
132
+ public function prepareFeedCategoryFilter($condition, $value)
133
+ {
134
+
135
+ $categories = Mage::getResourceModel('catalog/category_collection')
136
+ ->addIsActiveFilter();
137
+
138
+ $exclusion = in_array($condition, array('neq', 'nlike', 'nin'));
139
+ if ($exclusion) {
140
+ switch ($condition) {
141
+ case 'neq':
142
+ $condition = 'eq';
143
+ break;
144
+ case 'nlike':
145
+ $condition = 'like';
146
+ break;
147
+ case 'nin':
148
+ $condition = 'in';
149
+ break;
150
+ }
151
+ }
152
+ if ($condition == 'like' || $condition == 'nlike') {
153
+ $category = Mage::getModel('catalog/category')->load($value);
154
+ $categories->addFieldToFilter('name', array($condition => '%' . $category->getName() . '%'));
155
+ } else {
156
+ $categories->addFieldToFilter('entity_id', array($condition => $value));
157
+ }
158
+
159
+ foreach ($categories as $_cat) {
160
+ if ($exclusion) {
161
+ $this->_prepared_feed_categories['exclusion'][] = intval($_cat->getId());
162
+ } else {
163
+ $this->_prepared_feed_categories['inclusion'][] = intval($_cat->getId());
164
+ }
165
+ }
166
+
167
+ return $this;
168
+ }
169
+
170
+ public function addFeedCategoryFilter()
171
+ {
172
+
173
+ $categories = Mage::getResourceModel('catalog/category_collection')
174
+ ->addIsActiveFilter();
175
+
176
+ $all_categories_ids = array();
177
+
178
+ foreach ($categories as $_cat) {
179
+ $all_categories_ids[] = intval($_cat->getId());
180
+ }
181
+
182
+ if (count($this->_prepared_feed_categories['exclusion'])) {
183
+ $all_categories_ids = array_diff($all_categories_ids, $this->_prepared_feed_categories['exclusion']);
184
+ }
185
+ if (count($this->_prepared_feed_categories['inclusion'])) {
186
+ $all_categories_ids = array_intersect($all_categories_ids, $this->_prepared_feed_categories['inclusion']);
187
+ }
188
+
189
+ $this->_feed_categories = $all_categories_ids;
190
+
191
+ $this->_applyProductLimitations();
192
+
193
+ return $this;
194
+ }
195
+
196
+
197
+ }
app/code/community/CP/Feed/controllers/Adminhtml/ItemsController.php ADDED
@@ -0,0 +1,791 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_Adminhtml_ItemsController extends Mage_Adminhtml_Controller_Action
23
+ {
24
+
25
+ protected function _initAction()
26
+ {
27
+ $this->loadLayout()->_setActiveMenu('cp_feed')->_addBreadcrumb(Mage::helper('adminhtml')->__('Feed Manager'), Mage::helper('adminhtml')->__('Feed Manager'));
28
+
29
+ return $this;
30
+ }
31
+
32
+ public function indexAction()
33
+ {
34
+ $this->_initAction();
35
+ $prefix = Mage::getConfig()->getTablePrefix();
36
+ $table = $prefix . "cp_feed";
37
+
38
+ $istableExist = Mage::getSingleton('core/resource')->getConnection('backup_write')->showTableStatus($table);
39
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
40
+ if (!is_array($istableExist)) {
41
+ $write->query("CREATE TABLE " . $prefix . "cp_feed(
42
+ id smallint(6) NOT NULL auto_increment,
43
+ vartimestamp varchar(255) NOT NULL,
44
+ PRIMARY KEY (`id`)
45
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Cp Feed' AUTO_INCREMENT=1;");
46
+
47
+ $write->query("INSERT INTO " . $prefix . "cp_feed(id,vartimestamp) values(1,'321')");
48
+ }
49
+ $this->renderLayout();
50
+
51
+ }
52
+
53
+ /* public function writeTempData(){
54
+ if($feed_id = $this->getRequest()->getParam('id')){
55
+
56
+ $feed = Mage::getModel('cp_feed/item')->load($feed_id);
57
+ $start = intval($this->getRequest()->getParam('start'));
58
+ $length = intval($this->getRequest()->getParam('length'));
59
+ $feed->writeTempFile($start, $length);
60
+ }
61
+
62
+ }*/
63
+
64
+ public function saveAction()
65
+ {
66
+
67
+ if ($data = $this->getRequest()->getPost()) {
68
+
69
+ try {
70
+ $id = $this->getRequest()->getParam('id');
71
+
72
+ $model = Mage::getModel('cp_feed/item');
73
+
74
+
75
+ if (isset($data['field'])) {
76
+ $content_data = array();
77
+ $content_data_sorted = array();
78
+
79
+ foreach ($data['field'] as $field) {
80
+ if (intval($field['order']) && !isset($content_data_sorted[$field['order']])) {
81
+
82
+ $content_data_sorted[intval($field['order'])] = $field;
83
+
84
+ } else {
85
+
86
+ $field['order'] = 0;
87
+ $content_data[] = $field;
88
+ }
89
+
90
+ }
91
+
92
+ ksort($content_data_sorted);
93
+
94
+ $data['content'] = json_encode(array_merge($content_data, $content_data_sorted));
95
+
96
+ }
97
+
98
+ /*if(isset($data['filter']) && is_array($data['filter'])){
99
+
100
+ $data['filter'] = json_encode(array_merge($data['filter'], array()));
101
+
102
+ }else{
103
+ $data['filter'] = json_encode(array());
104
+ }*/
105
+
106
+ if (isset($data['upload_day']) && is_array($data['upload_day'])) {
107
+
108
+ $data['upload_day'] = implode(',', $data['upload_day']);
109
+
110
+ }
111
+
112
+ if (isset($data['product_categories']) && is_array($data['product_categories'])) {
113
+
114
+ $data['product_categories'] = implode(',', $data['product_categories']);
115
+
116
+ }
117
+
118
+ /* if (isset($data['upload_interval']) && in_array($data['upload_interval'], array(12,24))){
119
+ $data['upload_hour_to'] = null;
120
+ }
121
+ */
122
+ $model->setData($data)->setId($id)->save();
123
+
124
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('core')->__('Data successfully saved'));
125
+
126
+ if ($this->getRequest()->getParam('back')) {
127
+ $this->_redirect('*/*/edit', array(
128
+ 'id' => $model->getId()
129
+ ));
130
+ return;
131
+ }
132
+
133
+ }
134
+ catch (Mage_Core_Exception $e) {
135
+
136
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
137
+
138
+ Mage::getSingleton('core/session')->setFeedData($data);
139
+
140
+ if ($model->getId() > 0) {
141
+ $this->_redirect('*/*/edit', array(
142
+ 'id' => $model->getId()
143
+ ));
144
+ } else {
145
+ $this->_redirect('*/*/new', array(
146
+ 'type' => $model->getType()
147
+ ));
148
+ }
149
+ return false;
150
+
151
+ }
152
+ catch (Exception $e) {
153
+
154
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('core')->__('Can’t save data'));
155
+
156
+ Mage::getSingleton('core/session')->setFeedData($data);
157
+
158
+ if ($model->getId() > 0) {
159
+ $this->_redirect('*/*/edit', array(
160
+ 'id' => $model->getId()
161
+ ));
162
+ } else {
163
+ $this->_redirect('*/*/new', array(
164
+ 'type' => $model->getType()
165
+ ));
166
+ }
167
+ return false;
168
+
169
+ }
170
+ $this->_redirect('*/*/');
171
+ }
172
+ }
173
+
174
+ public function deleteAction()
175
+ {
176
+
177
+ if ($id = intval($this->getRequest()->getParam('id'))) {
178
+
179
+ $this->_deleteItems(array(
180
+ $id
181
+ ));
182
+
183
+ }
184
+ $this->_redirect('*/*/');
185
+ }
186
+
187
+ public function massDeleteAction()
188
+ {
189
+
190
+ if ($ids = $this->getRequest()->getParam('id')) {
191
+ if (is_array($ids) && !empty($ids)) {
192
+ $this->_deleteItems($ids);
193
+ }
194
+
195
+ }
196
+
197
+ $this->_redirect('*/*/');
198
+
199
+ }
200
+
201
+
202
+ protected function _deleteItems($ids)
203
+ {
204
+ if (is_array($ids) && !empty($ids)) {
205
+ foreach ($ids as $id) {
206
+
207
+ $item = Mage::getModel('cp_feed/item')->load($id);
208
+ $item->delete();
209
+
210
+ }
211
+ }
212
+ }
213
+
214
+ public function newAction()
215
+ {
216
+ $this->_initAction();
217
+
218
+ if ($data = Mage::getSingleton('core/session')->getFeedData()) {
219
+ Mage::register('cp_feed', Mage::getModel('cp_feed/item')->addData($data));
220
+ Mage::getSingleton('core/session')->setFeedData(null);
221
+ }
222
+
223
+ $this->_addContent($this->getLayout()->createBlock('cp_feed/adminhtml_items_edit'))->_addLeft($this->getLayout()->createBlock('cp_feed/adminhtml_items_edit_tabs'));
224
+
225
+ $this->renderLayout();
226
+
227
+ }
228
+
229
+ public function editAction()
230
+ {
231
+
232
+ $this->_initAction();
233
+
234
+ if ($id = $this->getRequest()->getParam('id')) {
235
+ Mage::register('cp_feed', Mage::getModel('cp_feed/item')->load($id));
236
+ }
237
+
238
+ $this->_addContent($this->getLayout()->createBlock('cp_feed/adminhtml_items_edit'))->_addLeft($this->getLayout()->createBlock('cp_feed/adminhtml_items_edit_tabs'));
239
+
240
+ $this->renderLayout();
241
+
242
+ }
243
+
244
+ public function uploadAction()
245
+ {
246
+
247
+ if ($id = $this->getRequest()->getParam('id')) {
248
+
249
+ $item = Mage::getModel('cp_feed/item')->load($id);
250
+
251
+ try {
252
+
253
+ if ($item->ftpUpload()) {
254
+
255
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('core')->__('File "%s" was uploaded!', $item->getFilename()));
256
+
257
+ }
258
+
259
+ }
260
+ catch (Mage_Core_Exception $e) {
261
+
262
+ Mage::getSingleton('adminhtml/session')->addError($item->getFilename() . ' - ' . $e->getMessage());
263
+
264
+ }
265
+ catch (Exception $e) {
266
+
267
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('core')->__('%s - Can\'t upload. Please, check your FTP Settings or Hosting Settings', $item->getFilename()));
268
+
269
+ }
270
+
271
+ return $this->_redirect('*/*/edit', array(
272
+ 'id' => $id
273
+ ));
274
+
275
+ }
276
+
277
+ $this->_redirect('*/*/index');
278
+
279
+ }
280
+ public function addStockToCollection($collection)
281
+ {
282
+ $id = $this->getRequest()->getParam('id');
283
+
284
+ $feed = Mage::getModel('cp_feed/item')->load($id);
285
+ $manageStockConfig = Mage::getStoreConfig('cataloginventory/item_options/manage_stock', $feed->getStoreId());
286
+ $stkConditions = 'e.entity_id=stk.product_id';
287
+
288
+ if ($manageStockConfig) {
289
+ // System Manage stock is On
290
+ $ifCase = $feed->_getCheckSql('(stk.use_config_manage_stock = 1 OR ( stk.use_config_manage_stock = 0 AND stk.manage_stock = 1) )', 'stk.is_in_stock', '1');
291
+ } else {
292
+ // System Manage stock is On
293
+ $ifCase = $feed->_getCheckSql('((stk.use_config_manage_stock = 0 AND stk.manage_stock = 0 ) OR (stk.use_config_manage_stock = 1))', '1', 'stk.is_in_stock');
294
+ }
295
+
296
+ $collection->getSelect()->join(array(
297
+ 'stk' => $collection->getTable('cataloginventory/stock_item')
298
+ ), $stkConditions, array(
299
+ 'is_in_stock' => $ifCase,
300
+ 'manage_stock',
301
+ 'use_config_manage_stock'
302
+ ));
303
+ // die((string)$collection->getSelect());
304
+ }
305
+
306
+ public function getProductsCollection($filterData = '', $current_page = 0, $length = 50)
307
+ {
308
+
309
+ $id = $this->getRequest()->getParam('id');
310
+
311
+ $feed = Mage::getModel('cp_feed/item')->load($id);
312
+ //if (is_null($this->_productCollection) && $this->getId()){
313
+ $collection = Mage::getModel('cp_feed/product_collection')->addAttributeToSelect('*');
314
+ $collection->addStoreFilter(Mage::app()->getStore());
315
+ /*if($length != 0){
316
+ $collection->setPage($current_page+1, $length);
317
+ }*/
318
+
319
+ $fileDir = sprintf('%s\productsfeed', Mage::getBaseDir('media'));
320
+ $collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addMinimalPrice()->addFinalPrice()->addTaxPercents()->addUrlRewrite(Mage::app()->getStore()->getRootCategoryId());
321
+ //$this->addStockToCollection($collection);
322
+ // Filter by Stock
323
+ if ($feed->getUseLayer()) {
324
+ // filter only in stock product
325
+ // addSaleableFilterToCollection is required
326
+ // for Configurable products to properly manage the stock
327
+
328
+ Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
329
+
330
+ Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);
331
+ }
332
+ // Export disable products
333
+ if ($feed->getUseDisabled() == 1) {
334
+ $collection->addAttributeToFilter('status', 1);
335
+ }
336
+
337
+ if ($feed->getProductCategories() != '') {
338
+ $categoryids = $myArray = explode(',', $feed->getProductCategories());
339
+ $collection->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'left');
340
+ $collection->addAttributeToFilter('category_id', array(
341
+ 'in' => array(
342
+ $categoryids
343
+ )
344
+ ));
345
+ $collection->getSelect()->group('e.entity_id');
346
+ }
347
+
348
+ if ($feed->getProductVisibility() != '' && $feed->getProductVisibility() != '0') {
349
+ //echo $feed->getProductVisibility();
350
+ $collection->addAttributeToFilter('visibility', $feed->getProductVisibility());
351
+ //echo 'Cnt--'.count($collection);
352
+ //exit;
353
+ }
354
+ //exit;
355
+ // Filter Disabled
356
+ if ($feed->getUseDisabled()) {
357
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
358
+ $collection->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
359
+ }
360
+ $this->_productCollection = $collection;
361
+ //}
362
+ return $this->_productCollection;
363
+ }
364
+
365
+ public function getParentProduct(Varien_Object $product, $collection = null)
366
+ {
367
+ $childId = $product->getId();
368
+ if (!isset($this->_parentProductsCache[$childId])) {
369
+ $connection = Mage::getSingleton('core/resource')->getConnection('read');
370
+ $table = Mage::getSingleton('core/resource')->getTableName('catalog_product_relation');
371
+ $sql = 'SELECT `parent_id` FROM ' . $table . ' WHERE `child_id` = ' . intval($childId);
372
+ $parent_id = $connection->fetchOne($sql);
373
+ $parent_product = null;
374
+ if ($parent_id) {
375
+ if ($collection) {
376
+ //$parent_product = $collection->getItemById($parent_id);
377
+ $parent_product = Mage::getModel('catalog/product')->load($parent_id);
378
+ }
379
+ if (!$parent_product->getId()) {
380
+ $parent_product = Mage::getModel('catalog/product')->load($parent_id);
381
+ }
382
+ $this->_parentProductsCache[$childId] = $parent_product;
383
+ } else {
384
+ $this->_parentProductsCache[$childId] = new Varien_Object();
385
+ }
386
+ }
387
+ return $this->_parentProductsCache[$childId];
388
+ }
389
+ public function getCategoriesCollection()
390
+ {
391
+ if (is_null($this->_categoryCollection)) {
392
+ $this->_categoryCollection = Mage::getResourceModel('catalog/category_collection')->addAttributeToSelect('name');
393
+ }
394
+ return $this->_categoryCollection;
395
+ }
396
+
397
+ public function generateAction()
398
+ {
399
+
400
+ if ($id = $this->getRequest()->getParam('id')) {
401
+
402
+ try {
403
+
404
+ $feed = Mage::getModel('cp_feed/item')->load($id);
405
+
406
+ $fileDir = sprintf('%s/productsfeed', Mage::getBaseDir('media'));
407
+ $filePath = sprintf('%s/productsfeed/%s', Mage::getBaseDir('media'), $feed->getFilename());
408
+ $logFilepath = sprintf('%s/productsfeed/%s', Mage::getBaseDir('media'), 'log-' . $feed->getId() . '.txt');
409
+ @unlink($filePath);
410
+ @unlink($logFilepath);
411
+ $filePath = sprintf('%s/productsfeed/%s', Mage::getBaseDir('media'), $feed->getFilename());
412
+
413
+ if (!file_exists($fileDir)) {
414
+ mkdir($fileDir);
415
+ chmod($fileDir, 0777);
416
+ }
417
+
418
+ if (is_dir($fileDir)) {
419
+
420
+ switch ($feed->getDelimiter()) {
421
+ case ('comma'):
422
+ default:
423
+ $delimiter = ",";
424
+ break;
425
+ case ('tab'):
426
+ $delimiter = "\t";
427
+ break;
428
+ case ('colon'):
429
+ $delimiter = ":";
430
+ break;
431
+ case ('space'):
432
+ $delimiter = " ";
433
+ break;
434
+ case ('vertical pipe'):
435
+ $delimiter = "|";
436
+ break;
437
+ case ('semi-colon'):
438
+ $delimiter = ";";
439
+ break;
440
+ }
441
+ //$delimiter = $this->getDelimiter();
442
+ switch ($feed->getEnclosure()) {
443
+ case (1):
444
+ default:
445
+ $enclosure = "'";
446
+ break;
447
+ case (2):
448
+ $enclosure = '"';
449
+ break;
450
+ case (3):
451
+ $enclosure = ' ';
452
+ break;
453
+ }
454
+
455
+ $maping = json_decode($feed->getContent());
456
+ $fp = fopen($filePath, 'w');
457
+ if ($feed->getData('use_addition_header') == 1) {
458
+ fwrite($fp, $feed->getData('addition_header'));
459
+ }
460
+ if ($feed->getShowHeaders()) {
461
+ $fields = array();
462
+ foreach ($maping as $col) {
463
+ $fields[] = $col->name;
464
+ $codes[] = $col->attribute_value;
465
+ }
466
+
467
+ fputcsv($fp, $fields, $delimiter, $enclosure);
468
+
469
+ }
470
+
471
+
472
+ $attributes = Mage::getModel('eav/entity_attribute')->getCollection()->setEntityTypeFilter(Mage::getResourceModel('catalog/product')->getEntityType()->getData('entity_type_id'))->setCodeFilter($codes);
473
+
474
+ $collection = $this->getProductsCollection();
475
+
476
+ foreach ($collection as $product) {
477
+ $fields = array();
478
+ $category = null;
479
+ foreach ($product->getCategoryIds() as $id) {
480
+ $_category = $this->getCategoriesCollection()->getItemById($id);
481
+ if (is_null($category) || ($category && $_category && $category->getLevel() < $_category->getLevel())) {
482
+ $category = $_category;
483
+ }
484
+ }
485
+ if ($category) {
486
+
487
+ $store = Mage::getModel('core/store')->load($feed->getStoreId());
488
+ $root_category = Mage::getModel('catalog/category')->load($store->getRootCategoryId());
489
+ $category_path = array(
490
+ $category->getName()
491
+ );
492
+ $parent_id = $category->getParentId();
493
+ if ($category->getLevel() > $root_category->getLevel()) {
494
+ while ($_category = $this->getCategoriesCollection()->getItemById($parent_id)) {
495
+ if ($_category->getLevel() <= $root_category->getLevel()) {
496
+ break;
497
+ }
498
+ $category_path[] = $_category->getName();
499
+ $parent_id = $_category->getParentId();
500
+ }
501
+ }
502
+ $product->setCategory($category->getName());
503
+ $product->setCategoryId($category->getEntityId());
504
+ $product->setCategorySubcategory(implode(' > ', array_reverse($category_path)));
505
+ } else {
506
+ $product->setCategory('');
507
+ $product->setCategorySubcategory('');
508
+ }
509
+ $parent_product = $this->getParentProduct($product, $collection);
510
+ $_prod = Mage::getModel('catalog/product')->load($product->getId());
511
+ foreach ($maping as $col) {
512
+ $value = null;
513
+ if ($col->attribute_value) {
514
+ switch ($col->attribute_value) {
515
+ case ('parent_sku'):
516
+ if ($parent_product && $parent_product->getEntityId()) {
517
+ $value = $parent_product->getSku();
518
+ } else {
519
+ $value = '';
520
+ }
521
+ break;
522
+ case ('price'):
523
+ if (in_array($product->getTypeId(), array(
524
+ Mage_Catalog_Model_Product_Type::TYPE_GROUPED,
525
+ Mage_Catalog_Model_Product_Type::TYPE_BUNDLE
526
+ )))
527
+ $value = $store->convertPrice($product->getMinimalPrice(), false, false);
528
+ else
529
+ $value = $store->convertPrice($product->getPrice(), false, false);
530
+ break;
531
+ case ('store_price'):
532
+ $value = $store->convertPrice($product->getFinalPrice(), false, false);
533
+ break;
534
+ case ('parent_url'):
535
+ if ($parent_product && $parent_product->getEntityId()) {
536
+ $value = $this->getProductUrl($parent_product, $baseUrl);
537
+ // $value = $parent_product->getProductUrl(false);
538
+ } else {
539
+ $value = $this->getProductUrl($product, $baseUrl);
540
+ }
541
+ break;
542
+ case 'parent_base_image':
543
+ if ($parent_product && $parent_product->getEntityId() > 0) {
544
+ $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
545
+ }
546
+ try {
547
+ if ($image_width || $image_height) {
548
+ $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
549
+ } else {
550
+ $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image');
551
+ }
552
+ }
553
+ catch (Exception $e) {
554
+ $image_url = '';
555
+ }
556
+ $value = $image_url;
557
+ break;
558
+ case 'parent_description':
559
+ $description = '';
560
+ if ($parent_product && $parent_product->getEntityId() > 0) {
561
+ $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
562
+ }
563
+ try {
564
+ $description = $_prod->getDescription();
565
+ }
566
+ catch (Exception $e) {
567
+ $description = '';
568
+ }
569
+ $value = $description;
570
+ break;
571
+ case 'parent_product_price':
572
+ if ($parent_product && $parent_product->getEntityId() > 0) {
573
+ $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
574
+ }
575
+ try {
576
+ $price = $_prod->getResource()->getAttribute('price')->getFrontend()->getValue($_prod);
577
+ }
578
+ catch (Exception $e) {
579
+ $price = '';
580
+ }
581
+ $value = number_format($price);
582
+ break;
583
+ case 'parent_product_special_price':
584
+ if ($parent_product && $parent_product->getEntityId() > 0) {
585
+ $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
586
+ }
587
+ try {
588
+ $specialprice = $_prod->getResource()->getAttribute('special_price')->getFrontend()->getValue($_prod);
589
+ }
590
+ catch (Exception $e) {
591
+ $specialprice = '';
592
+ }
593
+ $value = number_format($specialprice);
594
+ break;
595
+ case 'parent_brand':
596
+ $brand = '';
597
+ if ($parent_product && $parent_product->getEntityId() > 0) {
598
+ $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
599
+ try {
600
+ $brandAttr = $_prod->getResource()->getAttribute('brand');
601
+ if ($brandAttr) {
602
+ $brand = $brandAttr->getFrontend()->getValue($_prod);
603
+ }
604
+ }
605
+ catch (Exception $e) {
606
+ $brand = '';
607
+ }
608
+ }
609
+ $value = $brand;
610
+ break;
611
+ case 'image_link':
612
+ $url = Mage::getBaseUrl('media') . "catalog/product" . $_prod->getImage();
613
+ if (!$_prod->getImage()) {
614
+ if ($parent_product && $parent_product->getEntityId() > 0) {
615
+ $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
616
+ $url = Mage::getBaseUrl('media') . "catalog/product" . $_prod->getImage();
617
+ }
618
+ } else {
619
+ $url = Mage::getBaseUrl('media') . "catalog/product" . $_prod->getImage();
620
+ }
621
+ if ($url == Mage::getBaseUrl('media') . "catalog/product" || $url == Mage::getBaseUrl('media') . "catalog/productno_selection") {
622
+ $url = Mage::getBaseUrl('media') . "catalog/product/i/m/img-na-450_1.jpg";
623
+ }
624
+ $value = $url;
625
+ break;
626
+ case 'parent_name':
627
+ if ($parent_product && $parent_product->getEntityId() > 0) {
628
+ $_prod = Mage::getModel('catalog/product')->load($parent_product->getId());
629
+ $name = $_prod->getName();
630
+ } else {
631
+ $name = '';
632
+ }
633
+ $value = $name;
634
+ break;
635
+ case ('image'):
636
+ case ('gallery'):
637
+ case ('media_gallery'):
638
+ if (!$product->hasData('product_base_image')) {
639
+ try {
640
+ if ($image_width || $image_height) {
641
+ $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
642
+ } else {
643
+ $image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image');
644
+ }
645
+ }
646
+ catch (Exception $e) {
647
+ $image_url = '';
648
+ }
649
+ $product->setData('product_base_image', $image_url);
650
+ $value = $image_url;
651
+ } else {
652
+ $value = $product->getData('product_base_image');
653
+ }
654
+ break;
655
+ case ('image_2'):
656
+ case ('image_3'):
657
+ case ('image_4'):
658
+ case ('image_5'):
659
+ if (!$product->hasData('media_gallery_images')) {
660
+ $product->setData('media_gallery_images', $_prod->getMediaGalleryImages());
661
+ }
662
+ $i = 0;
663
+ foreach ($product->getMediaGalleryImages() as $_image) {
664
+ $i++;
665
+ if (('image_' . $i) == $col->attribute_value) {
666
+ if ($image_width || $image_height) {
667
+ $value = (string) Mage::helper('catalog/image')->init($product, 'image', $_image->getFile())->resize($image_width, $image_height);
668
+ } else {
669
+ $value = $_image['url'];
670
+ }
671
+ }
672
+ }
673
+ break;
674
+ case ('url'):
675
+ $value = $product->getProductUrl($product, $baseUrl);
676
+ // $value = $product->getProductUrl();
677
+ break;
678
+ case ('qty'):
679
+ $value = ceil((int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty());
680
+ break;
681
+ case ('category'):
682
+ $value = $product->getCategory();
683
+ break;
684
+ case ('product_type'):
685
+ $value = $product->getTypeId();
686
+ break;
687
+ case ('is_in_stock'):
688
+ // $value = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
689
+ $value = $product->getData('is_in_stock');
690
+ // $value = $product->getData('is_salable');
691
+ break;
692
+ default:
693
+ if ($attribute = $attributes->getItemByColumnValue('attribute_code', $col->attribute_value)) {
694
+ if ($attribute->getFrontendInput() == 'select' || $attribute->getFrontendInput() == 'multiselect') {
695
+ $value = implode(', ', (array) $product->getAttributeText($col->attribute_value));
696
+ } else {
697
+ $value = $product->getData($col->attribute_value);
698
+ }
699
+ } else {
700
+ $value = $product->getData($col->attribute_value);
701
+ }
702
+ break;
703
+ }
704
+ } else {
705
+ $value = '';
706
+ }
707
+ $fields[] = $value;
708
+ }
709
+ if ($enclosure != ' ') {
710
+ fputcsv($fp, $fields, $delimiter, $enclosure);
711
+ } else {
712
+ $this->myfputcsv($fp, $fields, $delimiter);
713
+ }
714
+ // only simple can be unset or we will lose the parents
715
+ if ($product->getTypeId() == 'simple') {
716
+ $product->clearInstance();
717
+ }
718
+ }
719
+
720
+ if ($csv_data = @file_get_contents($feed->getTempFilePath())) {
721
+ fwrite($fp, $csv_data);
722
+ }
723
+ if (file_exists($feed->getTempFilePath())) {
724
+ unlink($feed->getTempFilePath());
725
+ }
726
+ fclose($fp);
727
+ }
728
+
729
+ Mage::app()->setCurrentStore($feed->getStoreId());
730
+ $feed->setRestartCron(1);
731
+ $feed->setGeneratedAt(Mage::getSingleton('core/date')->gmtDate());
732
+ $feed->save();
733
+
734
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('core')->__('Your feed is generated. You can download in feed profile.'));
735
+
736
+ }
737
+ catch (Mage_Core_Exception $e) {
738
+
739
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
740
+
741
+ }
742
+ catch (Exception $e) {
743
+
744
+ if (!ini_get('allow_url_fopen')) {
745
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('core')->__('Check the "allow_url_fopen" option.
746
+ Check that the "allow_url_fopen" option it enabled.
747
+ This option enables the URL-aware fopen wrappers that enable accessing URL object like files.
748
+ Learn more at <a target="_blank" href="http://php.net/manual/en/filesystem.configuration.php">http://php.net/manual/en/filesystem.configuration.php</a>'));
749
+ } elseif (strpos(strtolower($e->getMessage()), 'permission')) {
750
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('core')->__('Check the Permission for the "Media" directory.
751
+ Check that the "media" directory of your Magento has permission equal to 777 or 0777.'));
752
+ } else {
753
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('core')->__('Can\'t generate feed file'));
754
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('core')->__('If "Time out" error.
755
+ Please ask your server administrator to increase script run times. Learn more at <a target="_blank" href="http://php.net/manual/en/function.set-time-limit.php">http://php.net/manual/en/function.set-time-limit.php</a>'));
756
+ }
757
+ }
758
+
759
+ return $this->_redirect('*/*/');
760
+
761
+ }
762
+
763
+ return $this->_redirect('*/*/index');
764
+
765
+ }
766
+
767
+ public function getattributevaluefieldAction()
768
+ {
769
+
770
+ if ($code = $this->getRequest()->getParam('attribute_code')) {
771
+
772
+ $name = $this->getRequest()->getParam('element_name');
773
+ $store_id = $this->getRequest()->getParam('store_id');
774
+ $iterator = $this->getRequest()->getParam('iterator');
775
+
776
+ if ($code == 'product_type') {
777
+ $condition = Cp_Feed_Block_Adminhtml_Items_Edit_Tab_Filter::getConditionSelectLight($iterator);
778
+ } else {
779
+ $condition = Cp_Feed_Block_Adminhtml_Items_Edit_Tab_Filter::getConditionSelect($iterator);
780
+ }
781
+
782
+ $this->getResponse()->setBody(Zend_Json::encode(array(
783
+ 'attributevalue' => Cp_Feed_Block_Adminhtml_Items_Edit_Tab_Filter::getAttributeValueField($code, $name, null, $store_id),
784
+ 'condition' => $condition,
785
+ 'iterator' => $iterator
786
+ )));
787
+ }
788
+
789
+ }
790
+
791
+ }
app/code/community/CP/Feed/controllers/IndexController.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class Cp_Feed_IndexController extends Mage_Core_Controller_Front_Action
23
+ {
24
+
25
+ public function indexAction()
26
+ {
27
+
28
+ $response = array(
29
+ 'result' => 0
30
+ );
31
+
32
+ if ($feed_id = $this->getRequest()->getParam('id')) {
33
+
34
+ $feed = Mage::getModel('cp_feed/item')->load($feed_id);
35
+ $start = intval($this->getRequest()->getParam('start'));
36
+ $length = intval($this->getRequest()->getParam('length'));
37
+
38
+
39
+ if ($start >= 0 && $length >= 0) {
40
+
41
+ if ($feed->getType() == 'csv') {
42
+
43
+ $feed->writeTempFile($start, $length);
44
+
45
+ } else {
46
+
47
+ Mage::getModel('cp_feed/item_block_product', array(
48
+ 'feed' => $feed,
49
+ 'content' => ''
50
+ ))->writeTempFile($start, $length);
51
+
52
+ }
53
+
54
+ $response['result'] = 1;
55
+
56
+ }
57
+ }
58
+
59
+ $this->getResponse()->setBody(Zend_Json::encode($response));
60
+
61
+ }
62
+
63
+ }
app/code/community/CP/Feed/etc/adminhtml.xml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Commerce Pundit Technologies
17
+ * @package CP_Feed
18
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
19
+ * @author <<Niranjan Gondaliya>>
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+
24
+ <config>
25
+ <menu>
26
+ <cp_feed>
27
+ <title>Product Feeds</title>
28
+ <action>cp_feed/adminhtml_items</action>
29
+ <sort_order>10</sort_order>
30
+ </cp_feed>
31
+ </menu>
32
+ <acl>
33
+ <resources>
34
+ <admin>
35
+ <children>
36
+ <system>
37
+ <children>
38
+ <config>
39
+ <children>
40
+ <cp_feedpro>
41
+ <title>Product Feeds</title>
42
+ </cp_feedpro>
43
+ </children>
44
+ </config>
45
+ </children>
46
+ </system>
47
+ </children>
48
+ </admin>
49
+ </resources>
50
+ </acl>
51
+ <acl>
52
+ <resources>
53
+ <admin>
54
+ <children>
55
+ <catalog>
56
+ <children>
57
+ <cp_feed translate="title">
58
+ <title>Product Feeds</title>
59
+ </cp_feed>
60
+ </children>
61
+ </catalog>
62
+ </children>
63
+ </admin>
64
+ </resources>
65
+ </acl>
66
+ <acl>
67
+ <resources>
68
+ <admin>
69
+ <children>
70
+ <system>
71
+ <children>
72
+ <config>
73
+ <children>
74
+ <cp_feedpro>
75
+ <title>Product Feed</title>
76
+ </cp_feedpro>
77
+ </children>
78
+ </config>
79
+ </children>
80
+ </system>
81
+ </children>
82
+ </admin>
83
+ </resources>
84
+ </acl>
85
+ </config>
app/code/community/CP/Feed/etc/config.xml ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Commerce Pundit Technologies
17
+ * @package CP_Feed
18
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
19
+ * @author <<Niranjan Gondaliya>>
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+
24
+ <config>
25
+ <modules>
26
+ <Cp_Feed>
27
+ <version>2.2.8</version>
28
+ </Cp_Feed>
29
+ </modules>
30
+ <frontend>
31
+ <routers>
32
+ <cp_feed>
33
+ <use>standard</use>
34
+ <args>
35
+ <module>Cp_Feed</module>
36
+ <frontName>feed</frontName>
37
+ </args>
38
+ </cp_feed>
39
+ </routers>
40
+
41
+ <!-- <events>
42
+ <checkout_cart_product_add_after>
43
+ <observers>
44
+ <Cp_Feed_Model_Observer>
45
+ <type>singleton</type>
46
+ <class>Cp_Feed_Model_Observer</class>
47
+ <method>proccessFeeds</method>
48
+ </Cp_Feed_Model_Observer>
49
+ </observers>
50
+ </checkout_cart_product_add_after>
51
+ </events> -->
52
+
53
+
54
+
55
+ </frontend>
56
+ <admin>
57
+ <routers>
58
+ <cp_feed>
59
+ <use>admin</use>
60
+ <args>
61
+ <module>Cp_Feed</module>
62
+ <frontName>cp_feed</frontName>
63
+ </args>
64
+ </cp_feed>
65
+ </routers>
66
+ </admin>
67
+ <adminhtml>
68
+
69
+ <layout>
70
+ <updates>
71
+ <cp_feed>
72
+ <file>cp-feed.xml</file>
73
+ </cp_feed>
74
+ </updates>
75
+ </layout>
76
+ </adminhtml>
77
+ <global>
78
+ <models>
79
+ <cp_feed>
80
+ <class>Cp_Feed_Model</class>
81
+ <resourceModel>cp_feed_mysql4</resourceModel>
82
+ </cp_feed>
83
+ <cp_feed_mysql4>
84
+ <class>Cp_Feed_Model_Mysql4</class>
85
+ <entities>
86
+ <item>
87
+ <table>cp_feed_entity</table>
88
+ </item>
89
+ </entities>
90
+ </cp_feed_mysql4>
91
+
92
+ <cron>
93
+ <rewrite>
94
+ <observer>Cp_Feed_Model_Observer</observer>
95
+ </rewrite>
96
+ </cron>
97
+ </models>
98
+ <blocks>
99
+ <cp_feed>
100
+ <class>Cp_Feed_Block</class>
101
+ </cp_feed>
102
+ </blocks>
103
+ <resources>
104
+ <cp_feed_setup>
105
+ <setup>
106
+ <module>Cp_Feed</module>
107
+ </setup>
108
+ <connection>
109
+ <use>core_setup</use>
110
+ </connection>
111
+ </cp_feed_setup>
112
+ <cp_feed_write>
113
+ <connection>
114
+ <use>core_write</use>
115
+ </connection>
116
+ </cp_feed_write>
117
+ <cp_feed_read>
118
+ <connection>
119
+ <use>core_read</use>
120
+ </connection>
121
+ </cp_feed_read>
122
+ </resources>
123
+ <helpers>
124
+ <cp_feed>
125
+ <class>Cp_Feed_Helper</class>
126
+ </cp_feed>
127
+ </helpers>
128
+ </global>
129
+ <!-- <crontab>
130
+ <jobs>
131
+ <cp_feed_generate_all>
132
+ <schedule>
133
+ <cron_expr>*/5 * * * *</cron_expr>
134
+ </schedule>
135
+ <run>
136
+ <model>cp_feed/observer::proccessFeeds</model>
137
+ </run>
138
+ </cp_feed_generate_all>
139
+ </jobs>
140
+ </crontab> -->
141
+
142
+ <crontab>
143
+ <jobs>
144
+ <cp_feed_generate_all>
145
+ <schedule>
146
+ <cron_expr>* * * * *</cron_expr>
147
+ </schedule>
148
+ <run>
149
+ <model>cp_feed/observer::proccessFeeds</model>
150
+ </run>
151
+ </cp_feed_generate_all>
152
+ </jobs>
153
+ </crontab>
154
+ </config>
app/code/community/CP/Feed/sql/cp_feed_setup/mysql4-install-1.0.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ $installer = $this;
23
+
24
+ $installer->startSetup();
25
+
26
+ $installer->run("
27
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('cp_feed_entity')}` (
28
+ `id` smallint(6) NOT NULL auto_increment,
29
+ `name` varchar(255) NOT NULL,
30
+ `store_id` smallint(6) NOT NULL,
31
+ `type` smallint(1) NOT NULL,
32
+ `status` smallint(1) NOT NULL,
33
+ `filename` varchar(255) NOT NULL,
34
+ `content` text NOT NULL,
35
+ `filter` text,
36
+ `generated_at` datetime NOT NULL default '0000-00-00 00:00:00',
37
+ PRIMARY KEY (`id`)
38
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Cp Catalog Feed' AUTO_INCREMENT=1;
39
+ ");
40
+
41
+ $installer->endSetup();
app/code/community/CP/Feed/sql/cp_feed_setup/mysql4-install-1.3.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ $installer = $this;
23
+
24
+ $installer->startSetup();
25
+
26
+ $installer->run("
27
+ CREATE TABLE `{$this->getTable('cp_feed_entity')}` (
28
+ `id` smallint(6) NOT NULL auto_increment,
29
+ `name` varchar(255) NOT NULL,
30
+ `store_id` smallint(6) NOT NULL,
31
+ `type` varchar(32) NOT NULL,
32
+ `status` smallint(1) NOT NULL,
33
+ `filename` varchar(255) NOT NULL,
34
+ `content` text NOT NULL,
35
+ `filter` text,
36
+ `generated_at` datetime NOT NULL default '0000-00-00 00:00:00',
37
+ `show_headers` tinyint(1) default NULL,
38
+ `enclosure` varchar(32) default NULL,
39
+ `delimiter` varchar(32) default NULL,
40
+ `remove_lb` tinyint(1) DEFAULT '0',
41
+ PRIMARY KEY (`id`)
42
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Cp Catalog Feed' AUTO_INCREMENT=1;
43
+ ");
44
+
45
+ $installer->endSetup();
app/code/community/CP/Feed/sql/cp_feed_setup/mysql4-install-1.4.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ $installer = $this;
23
+
24
+ $installer->startSetup();
25
+
26
+ $installer->run("
27
+ CREATE TABLE `{$this->getTable('cp_feed_entity')}` (
28
+ `id` smallint(6) NOT NULL auto_increment,
29
+ `name` varchar(255) NOT NULL,
30
+ `store_id` smallint(6) NOT NULL,
31
+ `type` varchar(32) NOT NULL,
32
+ `status` smallint(1) NOT NULL,
33
+ `filename` varchar(255) NOT NULL,
34
+ `content` text NOT NULL,
35
+ `filter` text,
36
+ `generated_at` datetime NOT NULL default '0000-00-00 00:00:00',
37
+ `cron_started_at` datetime NOT NULL default '0000-00-00 00:00:00',
38
+ `uploaded_at` datetime NOT NULL default '0000-00-00 00:00:00',
39
+ `show_headers` tinyint(1) default NULL,
40
+ `enclosure` varchar(32) default NULL,
41
+ `delimiter` varchar(32) default NULL,
42
+ `remove_lb` tinyint(1) DEFAULT '0',
43
+ `iteration_limit` int(32) default '0',
44
+ `use_layer` tinyint(1) NOT NULL default '1',
45
+ PRIMARY KEY (`id`)
46
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Cp Catalog Feed' AUTO_INCREMENT=1;
47
+ ");
48
+ $installer->endSetup();
app/code/community/CP/Feed/sql/cp_feed_setup/mysql4-install-2.0.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ $installer = $this;
23
+
24
+ $installer->startSetup();
25
+
26
+ $installer->run("
27
+ CREATE TABLE `{$this->getTable('cp_feed_entity')}` (
28
+ `id` smallint(6) NOT NULL auto_increment,
29
+ `name` varchar(255) NOT NULL,
30
+ `store_id` smallint(6) NOT NULL,
31
+ `type` varchar(32) NOT NULL,
32
+ `status` smallint(1) NOT NULL,
33
+ `filename` varchar(255) NOT NULL,
34
+ `content` text NOT NULL,
35
+ `filter` text,
36
+ `generated_at` datetime NOT NULL default '0000-00-00 00:00:00',
37
+ `cron_started_at` datetime NOT NULL default '0000-00-00 00:00:00',
38
+ `show_headers` tinyint(1) default NULL,
39
+ `enclosure` varchar(32) default NULL,
40
+ `delimiter` varchar(32) default NULL,
41
+ `remove_lb` tinyint(1) DEFAULT '0',
42
+ `iteration_limit` int(32) default '0',
43
+ `upload_day` varchar(32) default NULL,
44
+ `product_categories` varchar(255) NOT NULL,
45
+ `product_visibility` varchar(255) NOT NULL,
46
+ `upload_hour` smallint(6) default NULL,
47
+ `upload_hour_to` smallint(6) default NULL,
48
+ `upload_interval` smallint(6) default NULL,
49
+ `use_layer` tinyint(1) NOT NULL default '1',
50
+ `restart_cron` smallint(6) default NULL,
51
+ PRIMARY KEY (`id`)
52
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Cp Catalog Feed' AUTO_INCREMENT=1;
53
+ ");
54
+ $installer->endSetup();
app/code/community/CP/Feed/sql/cp_feed_setup/mysql4-upgrade-1.3-1.4.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ $installer = $this;
23
+
24
+ $installer->startSetup();
25
+
26
+ $installer->run("
27
+ ALTER TABLE `{$this->getTable('cp_feed_entity')}`
28
+ ADD COLUMN `iteration_limit` int(32) default '0';
29
+ ");
30
+ $installer->run("
31
+ ALTER TABLE `{$this->getTable('cp_feed_entity')}`
32
+ ADD COLUMN `use_layer` tinyint(1) NOT NULL default '1';
33
+ ");
34
+
35
+
36
+ $installer->endSetup();
app/code/community/CP/Feed/sql/cp_feed_setup/mysql4-upgrade-1.4-2.0.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ $installer = $this;
23
+
24
+ $installer->startSetup();
25
+
26
+ $installer->run("
27
+ ALTER TABLE `{$this->getTable('cp_feed_entity')}`
28
+ ADD COLUMN `use_disabled` tinyint(1) NOT NULL default '1';
29
+ ");
30
+
31
+
32
+ $installer->endSetup();
app/code/community/CP/Feed/sql/cp_feed_setup/mysql4-upgrade-2.0-2.1.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Commerce Pundit Technologies
16
+ * @package CP_Feed
17
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
18
+ * @author <<Niranjan Gondaliya>>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ $installer = $this;
23
+
24
+ $installer->startSetup();
25
+
26
+ $installer->run("
27
+ ALTER TABLE `{$this->getTable('cp_feed_entity')}`
28
+ ADD COLUMN `use_disabled` tinyint(1) NOT NULL default '1';
29
+ ");
30
+
31
+
32
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/cp-feed.xml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Commerce Pundit Technologies
17
+ * @package CP_Feed
18
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
19
+ * @author <<Niranjan Gondaliya>>
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+
24
+ <layout version="1.0">
25
+ <cp_feed_adminhtml_items_index>
26
+ <reference name="content">
27
+ <block type="cp_feed/adminhtml_items" name="cp_feed.admin.items" />
28
+ </reference>
29
+ </cp_feed_adminhtml_items_index>
30
+ <cp_feed_adminhtml_attributes_index>
31
+ <reference name="content">
32
+ <block type="cp_feed/adminhtml_attributes" name="cp_feed.admin.attributes" />
33
+ </reference>
34
+ </cp_feed_adminhtml_attributes_index>
35
+ <cp_feed_adminhtml_attributes_edit>
36
+ <reference name="head">
37
+ <action method="addItem"><type>skin_css</type><name>cp/feed.css</name><params>media="screen, projection"</params></action>
38
+ </reference>
39
+ </cp_feed_adminhtml_attributes_edit>
40
+ <cp_feed_adminhtml_attributes_new>
41
+ <reference name="head">
42
+ <action method="addItem"><type>skin_css</type><name>cp/feed.css</name><params>media="screen, projection"</params></action>
43
+ </reference>
44
+ </cp_feed_adminhtml_attributes_new>
45
+ <cp_feed_adminhtml_items_edit>
46
+ <reference name="head">
47
+ <action method="addJs"><script>lib/flex.js</script></action>
48
+ <action method="addJs"><script>lib/FABridge.js</script></action>
49
+ <action method="addJs"><script>mage/adminhtml/flexuploader.js</script></action>
50
+ <action method="addJs"><script>mage/adminhtml/uploader.js</script></action>
51
+ <action method="addJs"><script>cpfeed/jquery-1.8.2.min.js</script></action>
52
+ <action method="addItem"><type>skin_css</type><name>cp/cpfeed.css</name><params/></action>
53
+ </reference>
54
+ </cp_feed_adminhtml_items_edit>
55
+ <cp_feed_adminhtml_items_new>
56
+ <reference name="head">
57
+ <action method="addJs"><script>lib/flex.js</script></action>
58
+ <action method="addJs"><script>lib/FABridge.js</script></action>
59
+ <action method="addJs"><script>mage/adminhtml/flexuploader.js</script></action>
60
+ <action method="addJs"><script>mage/adminhtml/uploader.js</script></action>
61
+ <action method="addJs"><script>cpfeed/jquery-1.8.2.min.js</script></action>
62
+ <action method="addItem"><type>skin_css</type><name>cp/cpfeed.css</name><params/></action>
63
+ </reference>
64
+ </cp_feed_adminhtml_items_new>
65
+ </layout>
app/design/adminhtml/default/default/template/cp/feed/item/edit/category_product.phtml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div style="" id="cp_feed_tabs_content_section_content"><div class="entry-edit">
2
+ <div class="entry-edit-head">
3
+ <h4 class="icon-head head-edit-form fieldset-legend">Product Category</h4>
4
+ </div>
5
+ <div class="fieldset " id="content_fieldset">
6
+ <div style="clear:both" class="grid">
7
+ <?php
8
+ $product_categories = Mage::getModel('cp_feed/item')->load($this->getRequest()->getParam('id'));
9
+ $categoryids = $myArray = explode(',', $product_categories->getProductCategories());
10
+
11
+ $rootcatId = Mage::app()->getStore("default")->getRootCategoryId();
12
+ $categories = Mage::getModel('catalog/category')->getCategories($rootcatId);
13
+ function get_categories($categories)
14
+ {
15
+ $array = '<ul class="none" id="outer_ul">';
16
+ foreach ($categories as $category) {
17
+ $cat = Mage::getModel('catalog/category')->load($category->getId());
18
+ if ($category->hasChildren()) {
19
+
20
+ $array .= '<li>' . '<input type="checkbox" id="' . $category->getId() . '" name="product_categories[]" class="categorychkbx" value="' . $category->getId() . '"><label class="sub_element">' . $category->getName() . "</label> <em id='parent'></em>";
21
+
22
+ } else {
23
+
24
+ $array .= '<li>' . '<input type="checkbox" id="' . $category->getId() . '" name="product_categories[]" class="categorychkbx" value="' . $category->getId() . '"><label class="sub_element">' . $category->getName() . "</label> <em id='child'></em>";
25
+
26
+ }
27
+
28
+
29
+ if ($category->hasChildren()) {
30
+ $children = Mage::getModel('catalog/category')->getCategories($category->getId());
31
+ $array .= get_categories($children);
32
+ }
33
+
34
+ $array .= '</li>';
35
+ }
36
+ return $array . '</ul>';
37
+ }
38
+ echo get_categories($categories);
39
+ ?>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ </div>
44
+ <script>
45
+ <?php foreach ($categoryids as $catval) { ?>
46
+ jQuery("#<?php echo $catval; ?>").attr ( "checked" ,"checked" );
47
+ <?php } ?>
48
+ </script>
49
+
50
+ <script>
51
+ jQuery(document).ready(function(){
52
+ jQuery('#outer_ul ul').css("display","none");
53
+ jQuery("#parent").live("click",function(event){
54
+ jQuery(".block").removeAttr("style");
55
+ jQuery(".block").removeAttr("style");
56
+ jQuery(".col-left").removeAttr("style");
57
+ if(false == jQuery(this).next().is(':visible')) {
58
+ jQuery(".block").removeAttr("style");
59
+ jQuery(".block").removeAttr("style");
60
+ jQuery(".col-left").removeAttr("style");
61
+ jQuery(this).closest('ul').find('ul').slideUp(300);
62
+ jQuery(this).removeAttr("class");
63
+ jQuery(this).closest('ul').find('em').css("background-position",'0 9px');
64
+ }
65
+ jQuery(this).toggleClass('expanded');
66
+ jQuery(this).next().slideToggle(300);
67
+ if(jQuery(this).attr("class") == "expanded") {
68
+ jQuery(this).css("background-position",'0 -11px');
69
+ } else {
70
+ jQuery(this).css("background-position",'0 9px');
71
+ }
72
+
73
+ });
74
+
75
+ jQuery(".current").show();
76
+ jQuery(".current").prev().addClass("expanded");
77
+ jQuery('.current').prev().css("background-position",'0 -11px');
78
+ });
79
+ </script>
app/design/adminhtml/default/default/template/cp/feed/item/edit/content.phtml ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $feed = $this->getFeed();
4
+
5
+ $type=$this->getRequest()->getParam('type');
6
+
7
+ if($data = $this->getFeed()->getContent()){
8
+
9
+ $data = json_decode($data, true);
10
+
11
+ }else if($type == 'amazon'){
12
+
13
+ $data = Mage::helper('cp_feed')->getAmazonContentJson();
14
+ $data=json_decode($data, true);
15
+
16
+ }else if($type == 'google'){
17
+
18
+ $data = Mage::helper('cp_feed')->getGoogleContentJson();
19
+ $data=json_decode($data, true);
20
+
21
+ }else{
22
+
23
+ $data = array();
24
+
25
+ }
26
+
27
+ ?>
28
+ <div class="entry-edit">
29
+
30
+ <div class="entry-edit-head">
31
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Fields Mapping')?></h4>
32
+ </div>
33
+ <div id="content_fieldset" class="fieldset ">
34
+
35
+ <div class="left">
36
+ <p style="clear:both;padding-bottom:5px;overflow:hidden;">
37
+ <input type='hidden' name='show_headers' value='1' />
38
+
39
+ <label style="float:left;margin-right:20px; "><span style="float:left;margin-right:10px;"><?php echo $this->__('Delimiter')?></span>
40
+ <select style="width:100px;" name="delimiter">
41
+
42
+ <option value="comma" <?php if(($feed->getDelimiter()) == 'comma' || !$feed->getDelimiter()):?> selected="selected" <?php endif;?>><?php echo $this->__('Comma');?></option>
43
+ <option value="tab" <?php if(($feed->getDelimiter()) == 'tab' ):?> selected="selected" <?php endif;?>><?php echo $this->__('Tab');?></option>
44
+ <option value="colon" <?php if(($feed->getDelimiter()) == 'colon' ):?> selected="selected" <?php endif;?>><?php echo $this->__('Colon');?></option>
45
+ <option value="space" <?php if(($feed->getDelimiter()) == 'space' ):?> selected="selected" <?php endif;?>><?php echo $this->__('Space');?></option>
46
+ <option value="vertical pipe" <?php if(($feed->getDelimiter()) == 'vertical pipe' || ($type == 'amazon' && !$feed->getDelimiter())):?> selected="selected" <?php endif;?>><?php echo $this->__('Vertical pipe');?></option>
47
+ <option value="semi-colon" <?php if(($feed->getDelimiter()) == 'semi-colon' ):?> selected="selected" <?php endif;?>><?php echo $this->__('Semi-colon');?></option>
48
+
49
+ </select>
50
+ </label>
51
+
52
+ <?php if($type == 'amazon' || $feed->getType() == 'amazon' ) { ?>
53
+
54
+ <input type='hidden' name='enclosure' value='3' />
55
+
56
+ <?php } else { ?>
57
+
58
+ <input type='hidden' name='enclosure' value='2' />
59
+
60
+ <?php } ?>
61
+
62
+
63
+ <!--
64
+ Enclosure are
65
+ value 2 is for Double quote (")
66
+ value 1 is for Double quote (')
67
+ value 3 is for Blank ()
68
+ -->
69
+ </p>
70
+ <!--
71
+ Remove line break symbols
72
+ You can use this option for shopzilla.com if your uploaded feed file doesn't work correctly.
73
+
74
+ <p style="clear:both">
75
+ <label><span style="float:left; width: 170px;"><?php echo $this->__('Remove line break symbols')?></span>
76
+ <select style="width:50px;" name="remove_lb">
77
+ <option value="1" <?php if(intval($feed->getRemoveLb()) == 1 ):?> selected="selected" <?php endif;?>><?php echo $this->__('Yes');?></option>
78
+ <option value="0" <?php if(intval($feed->getRemoveLb()) == 0 ):?> selected="selected" <?php endif;?>><?php echo $this->__('No');?></option>
79
+ </select>
80
+ </label><br/>
81
+ <small><?php echo $this->__('This is the specific option that allows to remove line break symbols from a data feed.')?></small>
82
+ </p>
83
+ -->
84
+ </div>
85
+ <div class="grid" style="clear:both">
86
+ <style>
87
+ .grid table td {vertical-align:middle;text-align: center;}
88
+ </style>
89
+ <table cellspacing="0" cellpadding="0" class="data" style="width:100%;">
90
+ <thead>
91
+ <tr class="headings">
92
+ <th width="20"><?php echo $this->__('Order')?></th>
93
+ <th style="width:160px;"><?php echo $this->__('Field Name')?></th>
94
+ <th width="40%"><?php echo $this->__('Value')?></th>
95
+ <th style="width:66px;text-align: center;"><?php echo $this->__('Action')?></th>
96
+ </tr>
97
+ </thead>
98
+ <tbody id="mapping-table-body">
99
+ <?php
100
+ if(empty($data)){
101
+ $rows_count = 5;
102
+ }else{
103
+ $rows_count = count($data);
104
+ }
105
+ echo $this->getLayout()->createBlock('adminhtml/template')
106
+ ->setData('feed', $this->getFeed())
107
+ ->setTemplate('cp/feed/item/edit/content/mapping.phtml')->toHtml();
108
+ ?>
109
+ </tbody>
110
+ </table>
111
+ <div class="button-set">
112
+ <script type="text/javascript">
113
+
114
+ var mappingTotalRows = <?php echo $rows_count?>;
115
+
116
+ function removeMappingRow(e){
117
+ e.parentNode.parentNode.parentNode.removeChild(e.parentNode.parentNode);
118
+ }
119
+
120
+ function addColumn(tr, content){
121
+
122
+ td = document.createElement('td');
123
+ td.innerHTML = content;
124
+ tr.appendChild(td);
125
+
126
+ }
127
+
128
+ function addMappingRow(){
129
+
130
+ var i = ++mappingTotalRows;
131
+ var tr = document.createElement('tr');
132
+
133
+ var attribute = '<?php echo addslashes($this->getAttributeSelect("[iterator]"));?>';
134
+
135
+ addColumn(tr, '<div style="padding:0 2px;border-color:#AAAAAA #C8C8C8 #C8C8C8 #AAAAAA;border-style:solid;border-width:1px;"><input style="width:100%;border:0;padding:0;" class="input-text" name="field['+i+'][order]" value="" /></div>');
136
+ addColumn(tr, '<div style="padding:0 2px;border-color:#AAAAAA #C8C8C8 #C8C8C8 #AAAAAA;border-style:solid;border-width:1px;"><input style="width:100%;border:0;padding:0;" type="text" class="input-text" name="field['+i+'][name]" value="" /></div>');
137
+ addColumn(tr, '<input style="width:98%; display:none;" id="mapping-'+i+'-static-value" type="text" class="input-text" name="field['+i+'][static_value]" value="" />'+attribute.replace(/\[iterator\]/g, i));
138
+ addColumn(tr, '<button onclick="removeMappingRow(this);return false;" class="button"><span><span><?php echo $this->__('Remove')?></span></span></button>');
139
+
140
+ $('mapping-table-body').appendChild(tr);
141
+
142
+ }
143
+
144
+ </script>
145
+ <p style="margin-top:10px;"><button onclick="addMappingRow();return false;" class="button"><span><span><?php echo $this->__('Add New Row')?></span></span></button></p>
146
+ </div>
147
+ </div>
148
+ </div>
149
+ </div>
150
+
151
+ <?php if($feed->getId()>0):?>
152
+ <script type="text/javascript">
153
+ //<![CDATA[
154
+
155
+ var maxUploadFileSizeInBytes = <?php echo $this->getDataMaxSizeInBytes() ?>;
156
+ var maxUploadFileSize = '<?php echo $this->getDataMaxSize() ?>';
157
+
158
+ <?php echo $this->getJsObjectName() ?> = new Flex.Uploader('<?php echo $this->getHtmlId() ?>', '<?php echo $this->getUploaderUrl('media/uploader.swf') ?>', <?php echo $this->getConfigJson() ?>);
159
+
160
+ <?php echo $this->getJsObjectName() ?>.onFilesComplete = function(completedFiles){
161
+ completedFiles.each(function(file){
162
+ CpFeedAdmin.submit(0, file.name);
163
+ <?php echo $this->getJsObjectName() ?>.removeFile(file.id);
164
+ });
165
+ $('<?php echo $this->getHtmlId() ?>-flash').setStyle({display:'none'});
166
+ }
167
+
168
+ if ($('<?php echo $this->getHtmlId() ?>-flash') != undefined) {
169
+ $('<?php echo $this->getHtmlId() ?>-flash').setStyle({display:'none'});
170
+ }
171
+
172
+ //]]>
173
+ </script>
174
+ <?php endif; ?>
175
+
176
+
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
app/design/adminhtml/default/default/template/cp/feed/item/edit/content/mapping.phtml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $feed = $this->getFeed();
4
+
5
+ $type=$this->getRequest()->getParam('type');
6
+
7
+ if($data = $this->getFeed()->getContent()){
8
+
9
+ $data = json_decode($data, true);
10
+
11
+ }else if($type == 'amazon'){
12
+
13
+ $data = Mage::helper('cp_feed')->getAmazonContentJson();
14
+ $data =json_decode($data, true);
15
+
16
+ }else if($type == 'google'){
17
+
18
+ $data = Mage::helper('cp_feed')->getGoogleContentJson();
19
+ $data =json_decode($data, true);
20
+
21
+ }else{
22
+
23
+ $data = array();
24
+
25
+ }
26
+
27
+ if(empty($data)){
28
+ $rows_count = 5;
29
+ }else{
30
+ $rows_count = count($data);
31
+ }
32
+
33
+ ?>
34
+ <?php for($i=0;$i<$rows_count;$i++):?>
35
+ <tr>
36
+ <td><div style="padding:0 2px;border-color:#AAAAAA #C8C8C8 #C8C8C8 #AAAAAA;border-style:solid;border-width:1px;"><input style="width:100%;border:0;padding:0;" type="text" class="input-text" name="field[<?php echo $i;?>][order]" value="<?php echo @$data[$i]['order'];?>" /></div></td>
37
+ <td ><div style="padding:0 2px;border-color:#AAAAAA #C8C8C8 #C8C8C8 #AAAAAA;border-style:solid;border-width:1px;"><input style="width:100%;border:0;padding:0;" type="text" class="input-text" name="field[<?php echo $i;?>][name]" value="<?php echo @$data[$i]['name'];?>" /></div></td>
38
+ <td>
39
+ <input style="width:98%;display:<?php echo isset($data[$i]['type']) && $data[$i]['type'] == 'static' ? 'block' : 'none';?>;" id="mapping-<?php echo $i;?>-static-value" type="text" class="input-text" name="field[<?php echo $i;?>][static_value]" value="<?php echo @$data[$i]['static_value'] ?>" />
40
+ <?php echo Cp_Feed_Block_Adminhtml_Items_Edit_Tab_Content_Csv::getAttributeSelect($i, @$data[$i]['attribute_value'], (isset($data[$i]['type']) && $data[$i]['type'] == 'attribute' || !isset($data[$i]['type'])))?>
41
+ </td>
42
+ <td><button onclick="removeMappingRow(this);return false;" class="button"><span><span><?php echo $this->__('Remove')?></span></span></button></td>
43
+ </tr>
44
+ <?php endfor;?>
app/design/adminhtml/default/default/template/cp/feed/item/import/form.phtml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $helper = Mage::helper('cp_feed');
4
+
5
+ ?>
6
+ <div style="" id="cp_feed_tabs_import_section_content"><div class="entry-edit">
7
+ <div class="entry-edit-head">
8
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $helper->__('Import Mapping');?></h4>
9
+ <div class="form-buttons"></div>
10
+ </div>
11
+ <div id="main_fieldset" class="fieldset ">
12
+ <div class="hor-scroll">
13
+ <table cellspacing="0" class="form-list">
14
+ <tbody>
15
+ <tr>
16
+ <td class="label"><label for="mappingfile"><?php echo $helper->__('Mapping File');?><span class="required">*</span></label></td>
17
+ <td class="value" style="width:230px">
18
+ <input type="file" class=" required-entry" title="<?php echo $helper->__('Mapping File');?>" value="" name="mappingfile" id="mappingfile">
19
+ </td>
20
+ <td class="value"><span id="continue_button"><button style="" onclick="editForm.submit();return false;" class="scalable save" type="submit" id="id_944658684ee4dd3285bd2f1c924b3fc9"><span><?php echo $helper->__('Import');?></span></button></span></td>
21
+ </tr>
22
+ </tbody>
23
+ </table>
24
+ </div>
25
+ </div>
26
+ </div>
27
+ </div>
app/etc/modules/Cp_Feed.xml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Commerce Pundit Technologies
17
+ * @package CP_Feed
18
+ * @copyright Copyright (c) 2016 Commerce Pundit Technologies. (http://www.commercepundit.com)
19
+ * @author <<Niranjan Gondaliya>>
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <config>
24
+ <modules>
25
+ <Cp_Feed>
26
+ <active>true</active>
27
+ <codePool>community</codePool>
28
+ </Cp_Feed>
29
+ </modules>
30
+ </config>
js/cpfeed/jquery-1.8.2.min.js ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ (function(z,v){function la(){if(!c.isReady){try{r.documentElement.doScroll("left")}catch(a){setTimeout(la,1);return}c.ready()}}function Ma(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,i){var j=a.length;if(typeof b==="object"){for(var n in b)X(a,n,b[n],f,e,d);return a}if(d!==v){f=!i&&f&&c.isFunction(d);for(n=0;n<j;n++)e(a[n],b,f?d.call(a[n],n,e(a[n],b)):d,i);return a}return j?
3
+ e(a[0],b):null}function J(){return(new Date).getTime()}function Y(){return false}function Z(){return true}function ma(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function na(a){var b,d=[],f=[],e=arguments,i,j,n,o,m,s,x=c.extend({},c.data(this,"events").live);if(!(a.button&&a.type==="click")){for(o in x){j=x[o];if(j.live===a.type||j.altLive&&c.inArray(a.type,j.altLive)>-1){i=j.data;i.beforeFilter&&i.beforeFilter[a.type]&&!i.beforeFilter[a.type](a)||f.push(j.selector)}else delete x[o]}i=c(a.target).closest(f,
4
+ a.currentTarget);m=0;for(s=i.length;m<s;m++)for(o in x){j=x[o];n=i[m].elem;f=null;if(i[m].selector===j.selector){if(j.live==="mouseenter"||j.live==="mouseleave")f=c(a.relatedTarget).closest(j.selector)[0];if(!f||f!==n)d.push({elem:n,fn:j})}}m=0;for(s=d.length;m<s;m++){i=d[m];a.currentTarget=i.elem;a.data=i.fn.data;if(i.fn.apply(i.elem,e)===false){b=false;break}}return b}}function oa(a,b){return"live."+(a?a+".":"")+b.replace(/\./g,"`").replace(/ /g,"&")}function pa(a){return!a||!a.parentNode||a.parentNode.nodeType===
5
+ 11}function qa(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var f=c.data(a[d++]),e=c.data(this,f);if(f=f&&f.events){delete e.handle;e.events={};for(var i in f)for(var j in f[i])c.event.add(this,i,f[i][j],f[i][j].data)}}})}function ra(a,b,d){var f,e,i;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&a[0].indexOf("<option")<0&&(c.support.checkClone||!sa.test(a[0]))){e=true;if(i=c.fragments[a[0]])if(i!==1)f=i}if(!f){b=b&&b[0]?b[0].ownerDocument||b[0]:r;f=b.createDocumentFragment();
6
+ c.clean(a,b,f,d)}if(e)c.fragments[a[0]]=i?f:1;return{fragment:f,cacheable:e}}function K(a,b){var d={};c.each(ta.concat.apply([],ta.slice(0,b)),function(){d[this]=a});return d}function ua(a){return"scrollTo"in a&&a.document?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var c=function(a,b){return new c.fn.init(a,b)},Na=z.jQuery,Oa=z.$,r=z.document,S,Pa=/^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,Qa=/^.[^:#\[\.,]*$/,Ra=/\S/,Sa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Ta=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,O=navigator.userAgent,
7
+ va=false,P=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,Q=Array.prototype.slice,wa=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(typeof a==="string")if((d=Pa.exec(a))&&(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:r;if(a=Ta.exec(a))if(c.isPlainObject(b)){a=[r.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=ra([d[1]],
8
+ [f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}}else{if(b=r.getElementById(d[2])){if(b.id!==d[2])return S.find(a);this.length=1;this[0]=b}this.context=r;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=r;a=r.getElementsByTagName(a)}else return!b||b.jquery?(b||S).find(a):c(b).find(a);else if(c.isFunction(a))return S.ready(a);if(a.selector!==v){this.selector=a.selector;this.context=a.context}return c.isArray(a)?this.setArray(a):c.makeArray(a,
9
+ this)},selector:"",jquery:"1.4.1",length:0,size:function(){return this.length},toArray:function(){return Q.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){a=c(a||null);a.prevObject=this;a.context=this.context;if(b==="find")a.selector=this.selector+(this.selector?" ":"")+d;else if(b)a.selector=this.selector+"."+b+"("+d+")";return a},setArray:function(a){this.length=0;ba.apply(this,a);return this},each:function(a,b){return c.each(this,
10
+ a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(r,c);else P&&P.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(Q.apply(this,arguments),"slice",Q.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this,function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};
11
+ c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,i,j,n;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b<d;b++)if((e=arguments[b])!=null)for(i in e){j=a[i];n=e[i];if(a!==n)if(f&&n&&(c.isPlainObject(n)||c.isArray(n))){j=j&&(c.isPlainObject(j)||c.isArray(j))?j:c.isArray(n)?[]:{};a[i]=c.extend(f,j,n)}else if(n!==v)a[i]=n}return a};c.extend({noConflict:function(a){z.$=
12
+ Oa;if(a)z.jQuery=Na;return c},isReady:false,ready:function(){if(!c.isReady){if(!r.body)return setTimeout(c.ready,13);c.isReady=true;if(P){for(var a,b=0;a=P[b++];)a.call(r,c);P=null}c.fn.triggerHandler&&c(r).triggerHandler("ready")}},bindReady:function(){if(!va){va=true;if(r.readyState==="complete")return c.ready();if(r.addEventListener){r.addEventListener("DOMContentLoaded",L,false);z.addEventListener("load",c.ready,false)}else if(r.attachEvent){r.attachEvent("onreadystatechange",L);z.attachEvent("onload",
13
+ c.ready);var a=false;try{a=z.frameElement==null}catch(b){}r.documentElement.doScroll&&a&&la()}}},isFunction:function(a){return $.call(a)==="[object Function]"},isArray:function(a){return $.call(a)==="[object Array]"},isPlainObject:function(a){if(!a||$.call(a)!=="[object Object]"||a.nodeType||a.setInterval)return false;if(a.constructor&&!aa.call(a,"constructor")&&!aa.call(a.constructor.prototype,"isPrototypeOf"))return false;var b;for(b in a);return b===v||aa.call(a,b)},isEmptyObject:function(a){for(var b in a)return false;
14
+ return true},error:function(a){throw a;},parseJSON:function(a){if(typeof a!=="string"||!a)return null;if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return z.JSON&&z.JSON.parse?z.JSON.parse(a):(new Function("return "+a))();else c.error("Invalid JSON: "+a)},noop:function(){},globalEval:function(a){if(a&&Ra.test(a)){var b=r.getElementsByTagName("head")[0]||
15
+ r.documentElement,d=r.createElement("script");d.type="text/javascript";if(c.support.scriptEval)d.appendChild(r.createTextNode(a));else d.text=a;b.insertBefore(d,b.firstChild);b.removeChild(d)}},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,b,d){var f,e=0,i=a.length,j=i===v||c.isFunction(a);if(d)if(j)for(f in a){if(b.apply(a[f],d)===false)break}else for(;e<i;){if(b.apply(a[e++],d)===false)break}else if(j)for(f in a){if(b.call(a[f],f,a[f])===false)break}else for(d=
16
+ a[0];e<i&&b.call(d,e,d)!==false;d=a[++e]);return a},trim:function(a){return(a||"").replace(Sa,"")},makeArray:function(a,b){b=b||[];if(a!=null)a.length==null||typeof a==="string"||c.isFunction(a)||typeof a!=="function"&&a.setInterval?ba.call(b,a):c.merge(b,a);return b},inArray:function(a,b){if(b.indexOf)return b.indexOf(a);for(var d=0,f=b.length;d<f;d++)if(b[d]===a)return d;return-1},merge:function(a,b){var d=a.length,f=0;if(typeof b.length==="number")for(var e=b.length;f<e;f++)a[d++]=b[f];else for(;b[f]!==
17
+ v;)a[d++]=b[f++];a.length=d;return a},grep:function(a,b,d){for(var f=[],e=0,i=a.length;e<i;e++)!d!==!b(a[e],e)&&f.push(a[e]);return f},map:function(a,b,d){for(var f=[],e,i=0,j=a.length;i<j;i++){e=b(a[i],i,d);if(e!=null)f[f.length]=e}return f.concat.apply([],f)},guid:1,proxy:function(a,b,d){if(arguments.length===2)if(typeof b==="string"){d=a;a=d[b];b=v}else if(b&&!c.isFunction(b)){d=b;b=v}if(!b&&a)b=function(){return a.apply(d||this,arguments)};if(a)b.guid=a.guid=a.guid||b.guid||c.guid++;return b},
18
+ uaMatch:function(a){a=a.toLowerCase();a=/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||!/compatible/.test(a)&&/(mozilla)(?:.*? rv:([\w.]+))?/.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}},browser:{}});O=c.uaMatch(O);if(O.browser){c.browser[O.browser]=true;c.browser.version=O.version}if(c.browser.webkit)c.browser.safari=true;if(wa)c.inArray=function(a,b){return wa.call(b,a)};S=c(r);if(r.addEventListener)L=function(){r.removeEventListener("DOMContentLoaded",
19
+ L,false);c.ready()};else if(r.attachEvent)L=function(){if(r.readyState==="complete"){r.detachEvent("onreadystatechange",L);c.ready()}};(function(){c.support={};var a=r.documentElement,b=r.createElement("script"),d=r.createElement("div"),f="script"+J();d.style.display="none";d.innerHTML=" <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";var e=d.getElementsByTagName("*"),i=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!i)){c.support=
20
+ {leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(i.getAttribute("style")),hrefNormalized:i.getAttribute("href")==="/a",opacity:/^0.55$/.test(i.style.opacity),cssFloat:!!i.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:r.createElement("select").appendChild(r.createElement("option")).selected,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};
21
+ b.type="text/javascript";try{b.appendChild(r.createTextNode("window."+f+"=1;"))}catch(j){}a.insertBefore(b,a.firstChild);if(z[f]){c.support.scriptEval=true;delete z[f]}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function n(){c.support.noCloneEvent=false;d.detachEvent("onclick",n)});d.cloneNode(true).fireEvent("onclick")}d=r.createElement("div");d.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";a=r.createDocumentFragment();a.appendChild(d.firstChild);
22
+ c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var n=r.createElement("div");n.style.width=n.style.paddingLeft="1px";r.body.appendChild(n);c.boxModel=c.support.boxModel=n.offsetWidth===2;r.body.removeChild(n).style.display="none"});a=function(n){var o=r.createElement("div");n="on"+n;var m=n in o;if(!m){o.setAttribute(n,"return;");m=typeof o[n]==="function"}return m};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=i=null}})();c.props=
23
+ {"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ua=0,xa={},Va={};c.extend({cache:{},expando:G,noData:{embed:true,object:true,applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==z?xa:a;var f=a[G],e=c.cache;if(!b&&!f)return null;f||(f=++Ua);if(typeof b==="object"){a[G]=f;e=e[f]=c.extend(true,
24
+ {},b)}else e=e[f]?e[f]:typeof d==="undefined"?Va:(e[f]={});if(d!==v){a[G]=f;e[b]=d}return typeof b==="string"?e[b]:e}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==z?xa:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{try{delete a[G]}catch(i){a.removeAttribute&&a.removeAttribute(G)}delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,
25
+ a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===v){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===v&&this.length)f=c.data(this[0],a);return f===v&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this,a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);
26
+ return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===v)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||
27
+ a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var ya=/[\n\t]/g,ca=/\s+/,Wa=/\r/g,Xa=/href|src|style/,Ya=/(button|input)/i,Za=/(button|input|object|select|textarea)/i,$a=/^(a|area)$/i,za=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(o){var m=
28
+ c(this);m.addClass(a.call(this,o,m.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1)if(e.className)for(var i=" "+e.className+" ",j=0,n=b.length;j<n;j++){if(i.indexOf(" "+b[j]+" ")<0)e.className+=" "+b[j]}else e.className=a}return this},removeClass:function(a){if(c.isFunction(a))return this.each(function(o){var m=c(this);m.removeClass(a.call(this,o,m.attr("class")))});if(a&&typeof a==="string"||a===v)for(var b=(a||"").split(ca),
29
+ d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1&&e.className)if(a){for(var i=(" "+e.className+" ").replace(ya," "),j=0,n=b.length;j<n;j++)i=i.replace(" "+b[j]+" "," ");e.className=i.substring(1,i.length-1)}else e.className=""}return this},toggleClass:function(a,b){var d=typeof a,f=typeof b==="boolean";if(c.isFunction(a))return this.each(function(e){var i=c(this);i.toggleClass(a.call(this,e,i.attr("class"),b),b)});return this.each(function(){if(d==="string")for(var e,i=0,j=c(this),n=b,o=
30
+ a.split(ca);e=o[i++];){n=f?n:!j.hasClass(e);j[n?"addClass":"removeClass"](e)}else if(d==="undefined"||d==="boolean"){this.className&&c.data(this,"__className__",this.className);this.className=this.className||a===false?"":c.data(this,"__className__")||""}})},hasClass:function(a){a=" "+a+" ";for(var b=0,d=this.length;b<d;b++)if((" "+this[b].className+" ").replace(ya," ").indexOf(a)>-1)return true;return false},val:function(a){if(a===v){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||
31
+ {}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var i=b?d:0;for(d=b?d+1:e.length;i<d;i++){var j=e[i];if(j.selected){a=c(j).val();if(b)return a;f.push(a)}}return f}if(za.test(b.type)&&!c.support.checkOn)return b.getAttribute("value")===null?"on":b.value;return(b.value||"").replace(Wa,"")}return v}var n=c.isFunction(a);return this.each(function(o){var m=c(this),s=a;if(this.nodeType===1){if(n)s=a.call(this,o,m.val());
32
+ if(typeof s==="number")s+="";if(c.isArray(s)&&za.test(this.type))this.checked=c.inArray(m.val(),s)>=0;else if(c.nodeName(this,"select")){var x=c.makeArray(s);c("option",this).each(function(){this.selected=c.inArray(c(this).val(),x)>=0});if(!x.length)this.selectedIndex=-1}else this.value=s}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return v;if(f&&b in c.attrFn)return c(a)[b](d);
33
+ f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==v;b=f&&c.props[b]||b;if(a.nodeType===1){var i=Xa.test(b);if(b in a&&f&&!i){if(e){b==="type"&&Ya.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:Za.test(a.nodeName)||$a.test(a.nodeName)&&a.href?0:v;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=
34
+ ""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&i?a.getAttribute(b,2):a.getAttribute(b);return a===null?v:a}return c.style(a,b,d)}});var ab=function(a){return a.replace(/[^\w\s\.\|`]/g,function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==z&&!a.frameElement)a=z;if(!d.guid)d.guid=c.guid++;if(f!==v){d=c.proxy(d);d.data=f}var e=c.data(a,"events")||c.data(a,"events",{}),i=c.data(a,"handle"),j;if(!i){j=
35
+ function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(j.elem,arguments):v};i=c.data(a,"handle",j)}if(i){i.elem=a;b=b.split(/\s+/);for(var n,o=0;n=b[o++];){var m=n.split(".");n=m.shift();if(o>1){d=c.proxy(d);if(f!==v)d.data=f}d.type=m.slice(0).sort().join(".");var s=e[n],x=this.special[n]||{};if(!s){s=e[n]={};if(!x.setup||x.setup.call(a,f,m,d)===false)if(a.addEventListener)a.addEventListener(n,i,false);else a.attachEvent&&a.attachEvent("on"+n,i)}if(x.add)if((m=x.add.call(a,
36
+ d,f,m,s))&&c.isFunction(m)){m.guid=m.guid||d.guid;m.data=m.data||d.data;m.type=m.type||d.type;d=m}s[d.guid]=d;this.global[n]=true}a=null}}},global:{},remove:function(a,b,d){if(!(a.nodeType===3||a.nodeType===8)){var f=c.data(a,"events"),e,i,j;if(f){if(b===v||typeof b==="string"&&b.charAt(0)===".")for(i in f)this.remove(a,i+(b||""));else{if(b.type){d=b.handler;b=b.type}b=b.split(/\s+/);for(var n=0;i=b[n++];){var o=i.split(".");i=o.shift();var m=!o.length,s=c.map(o.slice(0).sort(),ab);s=new RegExp("(^|\\.)"+
37
+ s.join("\\.(?:.*\\.)?")+"(\\.|$)");var x=this.special[i]||{};if(f[i]){if(d){j=f[i][d.guid];delete f[i][d.guid]}else for(var A in f[i])if(m||s.test(f[i][A].type))delete f[i][A];x.remove&&x.remove.call(a,o,j);for(e in f[i])break;if(!e){if(!x.teardown||x.teardown.call(a,o)===false)if(a.removeEventListener)a.removeEventListener(i,c.data(a,"handle"),false);else a.detachEvent&&a.detachEvent("on"+i,c.data(a,"handle"));e=null;delete f[i]}}}}for(e in f)break;if(!e){if(A=c.data(a,"handle"))A.elem=null;c.removeData(a,
38
+ "events");c.removeData(a,"handle")}}}},trigger:function(a,b,d,f){var e=a.type||a;if(!f){a=typeof a==="object"?a[G]?a:c.extend(c.Event(e),a):c.Event(e);if(e.indexOf("!")>=0){a.type=e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();this.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return v;a.result=v;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,
39
+ b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(i){}if(!a.isPropagationStopped()&&f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){d=a.target;var j;if(!(c.nodeName(d,"a")&&e==="click")&&!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()])){try{if(d[e]){if(j=d["on"+e])d["on"+e]=null;this.triggered=true;d[e]()}}catch(n){}if(j)d["on"+e]=j;this.triggered=false}}},handle:function(a){var b,
40
+ d;a=arguments[0]=c.event.fix(a||z.event);a.currentTarget=this;d=a.type.split(".");a.type=d.shift();b=!d.length&&!a.exclusive;var f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)");d=(c.data(this,"events")||{})[a.type];for(var e in d){var i=d[e];if(b||f.test(i.type)){a.handler=i;a.data=i.data;i=i.apply(this,arguments);if(i!==v){a.result=i;if(i===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}return a.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
41
+ fix:function(a){if(a[G])return a;var b=a;a=c.Event(b);for(var d=this.props.length,f;d;){f=this.props[--d];a[f]=b[f]}if(!a.target)a.target=a.srcElement||r;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=r.documentElement;d=r.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||
42
+ d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(!a.which&&(a.charCode||a.charCode===0?a.charCode:a.keyCode))a.which=a.charCode||a.keyCode;if(!a.metaKey&&a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==v)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a,b){c.extend(a,b||{});a.guid+=b.selector+b.live;b.liveProxy=a;c.event.add(this,b.live,na,b)},remove:function(a){if(a.length){var b=
43
+ 0,d=new RegExp("(^|\\.)"+a[0]+"(\\.|$)");c.each(c.data(this,"events").live||{},function(){d.test(this.type)&&b++});b<1&&c.event.remove(this,a[0],na)}},special:{}},beforeunload:{setup:function(a,b,d){if(this.setInterval)this.onbeforeunload=d;return false},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=a;this.type=a.type}else this.type=a;this.timeStamp=J();this[G]=true};
44
+ c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=Z;var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=Z;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Z;this.stopPropagation()},isDefaultPrevented:Y,isPropagationStopped:Y,isImmediatePropagationStopped:Y};var Aa=function(a){for(var b=
45
+ a.relatedTarget;b&&b!==this;)try{b=b.parentNode}catch(d){break}if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}},Ba=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?Ba:Aa,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?Ba:Aa)}}});if(!c.support.submitBubbles)c.event.special.submit={setup:function(a,b,d){if(this.nodeName.toLowerCase()!==
46
+ "form"){c.event.add(this,"click.specialSubmit."+d.guid,function(f){var e=f.target,i=e.type;if((i==="submit"||i==="image")&&c(e).closest("form").length)return ma("submit",this,arguments)});c.event.add(this,"keypress.specialSubmit."+d.guid,function(f){var e=f.target,i=e.type;if((i==="text"||i==="password")&&c(e).closest("form").length&&f.keyCode===13)return ma("submit",this,arguments)})}else return false},remove:function(a,b){c.event.remove(this,"click.specialSubmit"+(b?"."+b.guid:""));c.event.remove(this,
47
+ "keypress.specialSubmit"+(b?"."+b.guid:""))}};if(!c.support.changeBubbles){var da=/textarea|input|select/i;function Ca(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d}function ea(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Ca(d);if(a.type!=="focusout"||
48
+ d.type!=="radio")c.data(d,"_change_data",e);if(!(f===v||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}}c.event.special.change={filters:{focusout:ea,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return ea.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return ea.call(this,a)},beforeactivate:function(a){a=
49
+ a.target;a.nodeName.toLowerCase()==="input"&&a.type==="radio"&&c.data(a,"_change_data",Ca(a))}},setup:function(a,b,d){for(var f in T)c.event.add(this,f+".specialChange."+d.guid,T[f]);return da.test(this.nodeName)},remove:function(a,b){for(var d in T)c.event.remove(this,d+".specialChange"+(b?"."+b.guid:""),T[d]);return da.test(this.nodeName)}};var T=c.event.special.change.filters}r.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,
50
+ f)}c.event.special[b]={setup:function(){this.addEventListener(a,d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var i in d)this[b](i,f,d[i],e);return this}if(c.isFunction(f)){e=f;f=v}var j=b==="one"?c.proxy(e,function(n){c(this).unbind(n,j);return e.apply(this,arguments)}):e;return d==="unload"&&b!=="one"?this.one(d,f,e):this.each(function(){c.event.add(this,d,j,f)})}});c.fn.extend({unbind:function(a,
51
+ b){if(typeof a==="object"&&!a.preventDefault){for(var d in a)this.unbind(d,a[d]);return this}return this.each(function(){c.event.remove(this,a,b)})},trigger:function(a,b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){a=c.Event(a);a.preventDefault();a.stopPropagation();c.event.trigger(a,b,this[0]);return a.result}},toggle:function(a){for(var b=arguments,d=1;d<b.length;)c.proxy(a,b[d++]);return this.click(c.proxy(a,function(f){var e=(c.data(this,"lastToggle"+
52
+ a.guid)||0)%d;c.data(this,"lastToggle"+a.guid,e+1);f.preventDefault();return b[e].apply(this,arguments)||false}))},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});c.each(["live","die"],function(a,b){c.fn[b]=function(d,f,e){var i,j=0;if(c.isFunction(f)){e=f;f=v}for(d=(d||"").split(/\s+/);(i=d[j++])!=null;){i=i==="focus"?"focusin":i==="blur"?"focusout":i==="hover"?d.push("mouseleave")&&"mouseenter":i;b==="live"?c(this.context).bind(oa(i,this.selector),{data:f,selector:this.selector,
53
+ live:i},e):c(this.context).unbind(oa(i,this.selector),e?{guid:e.guid+this.selector+i}:null)}return this}});c.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),function(a,b){c.fn[b]=function(d){return d?this.bind(b,d):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});z.attachEvent&&!z.addEventListener&&z.attachEvent("onunload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}});
54
+ (function(){function a(g){for(var h="",k,l=0;g[l];l++){k=g[l];if(k.nodeType===3||k.nodeType===4)h+=k.nodeValue;else if(k.nodeType!==8)h+=a(k.childNodes)}return h}function b(g,h,k,l,q,p){q=0;for(var u=l.length;q<u;q++){var t=l[q];if(t){t=t[g];for(var y=false;t;){if(t.sizcache===k){y=l[t.sizset];break}if(t.nodeType===1&&!p){t.sizcache=k;t.sizset=q}if(t.nodeName.toLowerCase()===h){y=t;break}t=t[g]}l[q]=y}}}function d(g,h,k,l,q,p){q=0;for(var u=l.length;q<u;q++){var t=l[q];if(t){t=t[g];for(var y=false;t;){if(t.sizcache===
55
+ k){y=l[t.sizset];break}if(t.nodeType===1){if(!p){t.sizcache=k;t.sizset=q}if(typeof h!=="string"){if(t===h){y=true;break}}else if(o.filter(h,[t]).length>0){y=t;break}}t=t[g]}l[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,i=Object.prototype.toString,j=false,n=true;[0,0].sort(function(){n=false;return 0});var o=function(g,h,k,l){k=k||[];var q=h=h||r;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||
56
+ typeof g!=="string")return k;for(var p=[],u,t,y,R,H=true,M=w(h),I=g;(f.exec(""),u=f.exec(I))!==null;){I=u[3];p.push(u[1]);if(u[2]){R=u[3];break}}if(p.length>1&&s.exec(g))if(p.length===2&&m.relative[p[0]])t=fa(p[0]+p[1],h);else for(t=m.relative[p[0]]?[h]:o(p.shift(),h);p.length;){g=p.shift();if(m.relative[g])g+=p.shift();t=fa(g,t)}else{if(!l&&p.length>1&&h.nodeType===9&&!M&&m.match.ID.test(p[0])&&!m.match.ID.test(p[p.length-1])){u=o.find(p.shift(),h,M);h=u.expr?o.filter(u.expr,u.set)[0]:u.set[0]}if(h){u=
57
+ l?{expr:p.pop(),set:A(l)}:o.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=u.expr?o.filter(u.expr,u.set):u.set;if(p.length>0)y=A(t);else H=false;for(;p.length;){var D=p.pop();u=D;if(m.relative[D])u=p.pop();else D="";if(u==null)u=h;m.relative[D](y,u,M)}}else y=[]}y||(y=t);y||o.error(D||g);if(i.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))k.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&
58
+ y[g].nodeType===1&&k.push(t[g]);else k.push.apply(k,y);else A(y,k);if(R){o(R,q,k,l);o.uniqueSort(k)}return k};o.uniqueSort=function(g){if(C){j=n;g.sort(C);if(j)for(var h=1;h<g.length;h++)g[h]===g[h-1]&&g.splice(h--,1)}return g};o.matches=function(g,h){return o(g,null,null,h)};o.find=function(g,h,k){var l,q;if(!g)return[];for(var p=0,u=m.order.length;p<u;p++){var t=m.order[p];if(q=m.leftMatch[t].exec(g)){var y=q[1];q.splice(1,1);if(y.substr(y.length-1)!=="\\"){q[1]=(q[1]||"").replace(/\\/g,"");l=m.find[t](q,
59
+ h,k);if(l!=null){g=g.replace(m.match[t],"");break}}}}l||(l=h.getElementsByTagName("*"));return{set:l,expr:g}};o.filter=function(g,h,k,l){for(var q=g,p=[],u=h,t,y,R=h&&h[0]&&w(h[0]);g&&h.length;){for(var H in m.filter)if((t=m.leftMatch[H].exec(g))!=null&&t[2]){var M=m.filter[H],I,D;D=t[1];y=false;t.splice(1,1);if(D.substr(D.length-1)!=="\\"){if(u===p)p=[];if(m.preFilter[H])if(t=m.preFilter[H](t,u,k,p,l,R)){if(t===true)continue}else y=I=true;if(t)for(var U=0;(D=u[U])!=null;U++)if(D){I=M(D,t,U,u);var Da=
60
+ l^!!I;if(k&&I!=null)if(Da)y=true;else u[U]=false;else if(Da){p.push(D);y=true}}if(I!==v){k||(u=p);g=g.replace(m.match[H],"");if(!y)return[];break}}}if(g===q)if(y==null)o.error(g);else break;q=g}return u};o.error=function(g){throw"Syntax error, unrecognized expression: "+g;};var m=o.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
61
+ TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(g){return g.getAttribute("href")}},relative:{"+":function(g,h){var k=typeof h==="string",l=k&&!/\W/.test(h);k=k&&!l;if(l)h=h.toLowerCase();l=0;for(var q=g.length,
62
+ p;l<q;l++)if(p=g[l]){for(;(p=p.previousSibling)&&p.nodeType!==1;);g[l]=k||p&&p.nodeName.toLowerCase()===h?p||false:p===h}k&&o.filter(h,g,true)},">":function(g,h){var k=typeof h==="string";if(k&&!/\W/.test(h)){h=h.toLowerCase();for(var l=0,q=g.length;l<q;l++){var p=g[l];if(p){k=p.parentNode;g[l]=k.nodeName.toLowerCase()===h?k:false}}}else{l=0;for(q=g.length;l<q;l++)if(p=g[l])g[l]=k?p.parentNode:p.parentNode===h;k&&o.filter(h,g,true)}},"":function(g,h,k){var l=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=
63
+ h=h.toLowerCase();q=b}q("parentNode",h,l,g,p,k)},"~":function(g,h,k){var l=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("previousSibling",h,l,g,p,k)}},find:{ID:function(g,h,k){if(typeof h.getElementById!=="undefined"&&!k)return(g=h.getElementById(g[1]))?[g]:[]},NAME:function(g,h){if(typeof h.getElementsByName!=="undefined"){var k=[];h=h.getElementsByName(g[1]);for(var l=0,q=h.length;l<q;l++)h[l].getAttribute("name")===g[1]&&k.push(h[l]);return k.length===0?null:k}},
64
+ TAG:function(g,h){return h.getElementsByTagName(g[1])}},preFilter:{CLASS:function(g,h,k,l,q,p){g=" "+g[1].replace(/\\/g,"")+" ";if(p)return g;p=0;for(var u;(u=h[p])!=null;p++)if(u)if(q^(u.className&&(" "+u.className+" ").replace(/[\t\n]/g," ").indexOf(g)>=0))k||l.push(u);else if(k)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&
65
+ "2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,k,l,q,p){h=g[1].replace(/\\/g,"");if(!p&&m.attrMap[h])g[1]=m.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,k,l,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=o(g[3],null,null,h);else{g=o.filter(g[3],h,k,true^q);k||l.push.apply(l,g);return false}else if(m.match.POS.test(g[0])||m.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);
66
+ return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,k){return!!o(k[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===
67
+ g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},setFilters:{first:function(g,h){return h===0},last:function(g,h,k,l){return h===l.length-1},even:function(g,h){return h%2===
68
+ 0},odd:function(g,h){return h%2===1},lt:function(g,h,k){return h<k[3]-0},gt:function(g,h,k){return h>k[3]-0},nth:function(g,h,k){return k[3]-0===h},eq:function(g,h,k){return k[3]-0===h}},filter:{PSEUDO:function(g,h,k,l){var q=h[1],p=m.filters[q];if(p)return p(g,k,h,l);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h=h[3];k=0;for(l=h.length;k<l;k++)if(h[k]===g)return false;return true}else o.error("Syntax error, unrecognized expression: "+
69
+ q)},CHILD:function(g,h){var k=h[1],l=g;switch(k){case "only":case "first":for(;l=l.previousSibling;)if(l.nodeType===1)return false;if(k==="first")return true;l=g;case "last":for(;l=l.nextSibling;)if(l.nodeType===1)return false;return true;case "nth":k=h[2];var q=h[3];if(k===1&&q===0)return true;h=h[0];var p=g.parentNode;if(p&&(p.sizcache!==h||!g.nodeIndex)){var u=0;for(l=p.firstChild;l;l=l.nextSibling)if(l.nodeType===1)l.nodeIndex=++u;p.sizcache=h}g=g.nodeIndex-q;return k===0?g===0:g%k===0&&g/k>=
70
+ 0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var k=h[1];g=m.attrHandle[k]?m.attrHandle[k](g):g[k]!=null?g[k]:g.getAttribute(k);k=g+"";var l=h[2];h=h[4];return g==null?l==="!=":l==="="?k===h:l==="*="?k.indexOf(h)>=0:l==="~="?(" "+k+" ").indexOf(h)>=0:!h?k&&g!==false:l==="!="?k!==h:l==="^="?
71
+ k.indexOf(h)===0:l==="$="?k.substr(k.length-h.length)===h:l==="|="?k===h||k.substr(0,h.length+1)===h+"-":false},POS:function(g,h,k,l){var q=m.setFilters[h[2]];if(q)return q(g,k,h,l)}}},s=m.match.POS;for(var x in m.match){m.match[x]=new RegExp(m.match[x].source+/(?![^\[]*\])(?![^\(]*\))/.source);m.leftMatch[x]=new RegExp(/(^(?:.|\r|\n)*?)/.source+m.match[x].source.replace(/\\(\d+)/g,function(g,h){return"\\"+(h-0+1)}))}var A=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};
72
+ try{Array.prototype.slice.call(r.documentElement.childNodes,0)}catch(B){A=function(g,h){h=h||[];if(i.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var k=0,l=g.length;k<l;k++)h.push(g[k]);else for(k=0;g[k];k++)h.push(g[k]);return h}}var C;if(r.documentElement.compareDocumentPosition)C=function(g,h){if(!g.compareDocumentPosition||!h.compareDocumentPosition){if(g==h)j=true;return g.compareDocumentPosition?-1:1}g=g.compareDocumentPosition(h)&4?-1:g===
73
+ h?0:1;if(g===0)j=true;return g};else if("sourceIndex"in r.documentElement)C=function(g,h){if(!g.sourceIndex||!h.sourceIndex){if(g==h)j=true;return g.sourceIndex?-1:1}g=g.sourceIndex-h.sourceIndex;if(g===0)j=true;return g};else if(r.createRange)C=function(g,h){if(!g.ownerDocument||!h.ownerDocument){if(g==h)j=true;return g.ownerDocument?-1:1}var k=g.ownerDocument.createRange(),l=h.ownerDocument.createRange();k.setStart(g,0);k.setEnd(g,0);l.setStart(h,0);l.setEnd(h,0);g=k.compareBoundaryPoints(Range.START_TO_END,
74
+ l);if(g===0)j=true;return g};(function(){var g=r.createElement("div"),h="script"+(new Date).getTime();g.innerHTML="<a name='"+h+"'/>";var k=r.documentElement;k.insertBefore(g,k.firstChild);if(r.getElementById(h)){m.find.ID=function(l,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(l[1]))?q.id===l[1]||typeof q.getAttributeNode!=="undefined"&&q.getAttributeNode("id").nodeValue===l[1]?[q]:v:[]};m.filter.ID=function(l,q){var p=typeof l.getAttributeNode!=="undefined"&&l.getAttributeNode("id");
75
+ return l.nodeType===1&&p&&p.nodeValue===q}}k.removeChild(g);k=g=null})();(function(){var g=r.createElement("div");g.appendChild(r.createComment(""));if(g.getElementsByTagName("*").length>0)m.find.TAG=function(h,k){k=k.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var l=0;k[l];l++)k[l].nodeType===1&&h.push(k[l]);k=h}return k};g.innerHTML="<a href='#'></a>";if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")m.attrHandle.href=function(h){return h.getAttribute("href",
76
+ 2)};g=null})();r.querySelectorAll&&function(){var g=o,h=r.createElement("div");h.innerHTML="<p class='TEST'></p>";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){o=function(l,q,p,u){q=q||r;if(!u&&q.nodeType===9&&!w(q))try{return A(q.querySelectorAll(l),p)}catch(t){}return g(l,q,p,u)};for(var k in g)o[k]=g[k];h=null}}();(function(){var g=r.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===
77
+ 0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){m.order.splice(1,0,"CLASS");m.find.CLASS=function(h,k,l){if(typeof k.getElementsByClassName!=="undefined"&&!l)return k.getElementsByClassName(h[1])};g=null}}})();var E=r.compareDocumentPosition?function(g,h){return g.compareDocumentPosition(h)&16}:function(g,h){return g!==h&&(g.contains?g.contains(h):true)},w=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},fa=function(g,h){var k=[],
78
+ l="",q;for(h=h.nodeType?[h]:h;q=m.match.PSEUDO.exec(g);){l+=q[0];g=g.replace(m.match.PSEUDO,"")}g=m.relative[g]?g+"*":g;q=0;for(var p=h.length;q<p;q++)o(g,h[q],k);return o.filter(l,k)};c.find=o;c.expr=o.selectors;c.expr[":"]=c.expr.filters;c.unique=o.uniqueSort;c.getText=a;c.isXMLDoc=w;c.contains=E})();var bb=/Until$/,cb=/^(?:parents|prevUntil|prevAll)/,db=/,/;Q=Array.prototype.slice;var Ea=function(a,b,d){if(c.isFunction(b))return c.grep(a,function(e,i){return!!b.call(e,i,e)===d});else if(b.nodeType)return c.grep(a,
79
+ function(e){return e===b===d});else if(typeof b==="string"){var f=c.grep(a,function(e){return e.nodeType===1});if(Qa.test(b))return c.filter(b,f,!d);else b=c.filter(b,f)}return c.grep(a,function(e){return c.inArray(e,b)>=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f<e;f++){d=b.length;c.find(a,this[f],b);if(f>0)for(var i=d;i<b.length;i++)for(var j=0;j<d;j++)if(b[j]===b[i]){b.splice(i--,1);break}}return b},has:function(a){var b=c(a);return this.filter(function(){for(var d=
80
+ 0,f=b.length;d<f;d++)if(c.contains(this,b[d]))return true})},not:function(a){return this.pushStack(Ea(this,a,false),"not",a)},filter:function(a){return this.pushStack(Ea(this,a,true),"filter",a)},is:function(a){return!!a&&c.filter(a,this).length>0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,i={},j;if(f&&a.length){e=0;for(var n=a.length;e<n;e++){j=a[e];i[j]||(i[j]=c.expr.match.POS.test(j)?c(j,b||this.context):j)}for(;f&&f.ownerDocument&&f!==b;){for(j in i){e=i[j];if(e.jquery?e.index(f)>
81
+ -1:c(f).is(e)){d.push({selector:j,elem:f});delete i[j]}}f=f.parentNode}}return d}var o=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(m,s){for(;s&&s.ownerDocument&&s!==b;){if(o?o.index(s)>-1:c(s).is(a))return s;s=s.parentNode}return null})},index:function(a){if(!a||typeof a==="string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),
82
+ a);return this.pushStack(pa(a[0])||pa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},
83
+ nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);bb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):
84
+ e;if((this.length>1||db.test(f))&&cb.test(a))e=e.reverse();return this.pushStack(e,a,Q.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===v||a.nodeType!==1||!c(a).is(d));){a.nodeType===1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==
85
+ b&&d.push(a);return d}});var Fa=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ga=/(<([\w:]+)[^>]*?)\/>/g,eb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,Ha=/<([\w:]+)/,fb=/<tbody/i,gb=/<|&\w+;/,sa=/checked\s*(?:[^=]|=\s*.checked.)/i,Ia=function(a,b,d){return eb.test(d)?a:b+"></"+d+">"},F={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],
86
+ col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div<div>","</div>"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==v)return this.empty().append((this[0]&&this[0].ownerDocument||r).createTextNode(a));return c.getText(this)},
87
+ wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?
88
+ d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,
89
+ false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&
90
+ !c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Fa,"").replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){qa(this,b);qa(this.find("*"),b.find("*"))}return b},html:function(a){if(a===v)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Fa,""):null;else if(typeof a==="string"&&!/<script/i.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(Ha.exec(a)||
91
+ ["",""])[1].toLowerCase()]){a=a.replace(Ga,Ia);try{for(var b=0,d=this.length;b<d;b++)if(this[b].nodeType===1){c.cleanData(this[b].getElementsByTagName("*"));this[b].innerHTML=a}}catch(f){this.empty().append(a)}}else c.isFunction(a)?this.each(function(e){var i=c(this),j=i.html();i.empty().append(function(){return a.call(this,e,j)})}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(c.isFunction(a))return this.each(function(b){var d=c(this),f=d.html();d.replaceWith(a.call(this,
92
+ b,f))});else a=c(a).detach();return this.each(function(){var b=this.nextSibling,d=this.parentNode;c(this).remove();b?c(b).before(a):c(d).append(a)})}else return this.pushStack(c(c.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,b,d){function f(s){return c.nodeName(s,"table")?s.getElementsByTagName("tbody")[0]||s.appendChild(s.ownerDocument.createElement("tbody")):s}var e,i,j=a[0],n=[];if(!c.support.checkClone&&arguments.length===3&&typeof j===
93
+ "string"&&sa.test(j))return this.each(function(){c(this).domManip(a,b,d,true)});if(c.isFunction(j))return this.each(function(s){var x=c(this);a[0]=j.call(this,s,b?x.html():v);x.domManip(a,b,d)});if(this[0]){e=a[0]&&a[0].parentNode&&a[0].parentNode.nodeType===11?{fragment:a[0].parentNode}:ra(a,this,n);if(i=e.fragment.firstChild){b=b&&c.nodeName(i,"tr");for(var o=0,m=this.length;o<m;o++)d.call(b?f(this[o],i):this[o],e.cacheable||this.length>1||o>0?e.fragment.cloneNode(true):e.fragment)}n&&c.each(n,
94
+ Ma)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);for(var e=0,i=d.length;e<i;e++){var j=(e>0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),j);f=f.concat(j)}return this.pushStack(f,a,d.selector)}});c.each({remove:function(a,b){if(!a||c.filter(a,[this]).length){if(!b&&this.nodeType===1){c.cleanData(this.getElementsByTagName("*"));c.cleanData([this])}this.parentNode&&
95
+ this.parentNode.removeChild(this)}},empty:function(){for(this.nodeType===1&&c.cleanData(this.getElementsByTagName("*"));this.firstChild;)this.removeChild(this.firstChild)}},function(a,b){c.fn[a]=function(){return this.each(b,arguments)}});c.extend({clean:function(a,b,d,f){b=b||r;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||r;var e=[];c.each(a,function(i,j){if(typeof j==="number")j+="";if(j){if(typeof j==="string"&&!gb.test(j))j=b.createTextNode(j);else if(typeof j===
96
+ "string"){j=j.replace(Ga,Ia);var n=(Ha.exec(j)||["",""])[1].toLowerCase(),o=F[n]||F._default,m=o[0];i=b.createElement("div");for(i.innerHTML=o[1]+j+o[2];m--;)i=i.lastChild;if(!c.support.tbody){m=fb.test(j);n=n==="table"&&!m?i.firstChild&&i.firstChild.childNodes:o[1]==="<table>"&&!m?i.childNodes:[];for(o=n.length-1;o>=0;--o)c.nodeName(n[o],"tbody")&&!n[o].childNodes.length&&n[o].parentNode.removeChild(n[o])}!c.support.leadingWhitespace&&V.test(j)&&i.insertBefore(b.createTextNode(V.exec(j)[0]),i.firstChild);
97
+ j=c.makeArray(i.childNodes)}if(j.nodeType)e.push(j);else e=c.merge(e,j)}});if(d)for(a=0;e[a];a++)if(f&&c.nodeName(e[a],"script")&&(!e[a].type||e[a].type.toLowerCase()==="text/javascript"))f.push(e[a].parentNode?e[a].parentNode.removeChild(e[a]):e[a]);else{e[a].nodeType===1&&e.splice.apply(e,[a+1,0].concat(c.makeArray(e[a].getElementsByTagName("script"))));d.appendChild(e[a])}return e},cleanData:function(a){for(var b=0,d;(d=a[b])!=null;b++){c.event.remove(d);c.removeData(d)}}});var hb=/z-?index|font-?weight|opacity|zoom|line-?height/i,
98
+ Ja=/alpha\([^)]*\)/,Ka=/opacity=([^)]*)/,ga=/float/i,ha=/-([a-z])/ig,ib=/([A-Z])/g,jb=/^-?\d+(?:px)?$/i,kb=/^-?\d/,lb={position:"absolute",visibility:"hidden",display:"block"},mb=["Left","Right"],nb=["Top","Bottom"],ob=r.defaultView&&r.defaultView.getComputedStyle,La=c.support.cssFloat?"cssFloat":"styleFloat",ia=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===v)return c.curCSS(d,f);if(typeof e==="number"&&!hb.test(f))e+="px";c.style(d,f,e)})};
99
+ c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return v;if((b==="width"||b==="height")&&parseFloat(d)<0)d=v;var f=a.style||a,e=d!==v;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter=Ja.test(a)?a.replace(Ja,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Ka.exec(f.filter)[1])/100+"":""}if(ga.test(b))b=La;b=b.replace(ha,ia);if(e)f[b]=d;return f[b]},css:function(a,
100
+ b,d,f){if(b==="width"||b==="height"){var e,i=b==="width"?mb:nb;function j(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(i,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a,"border"+this+"Width",true))||0})}a.offsetWidth!==0?j():c.swap(a,lb,j);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&
101
+ a.currentStyle){f=Ka.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ga.test(b))b=La;if(!d&&e&&e[b])f=e[b];else if(ob){if(ga.test(b))b="float";b=b.replace(ib,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f=a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ha,ia);f=a.currentStyle[b]||a.currentStyle[d];if(!jb.test(f)&&kb.test(f)){b=e.left;var i=a.runtimeStyle.left;a.runtimeStyle.left=
102
+ a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=i}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var pb=
103
+ J(),qb=/<script(.|\s)*?\/script>/gi,rb=/select|textarea/i,sb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,N=/=\?(&|$)/,ja=/\?/,tb=/(\?|&)_=.*?(&|$)/,ub=/^(\w+:)?\/\/([^\/?#]+)/,vb=/%20/g;c.fn.extend({_load:c.fn.load,load:function(a,b,d){if(typeof a!=="string")return this._load(a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=
104
+ c.param(b,c.ajaxSettings.traditional);f="POST"}var i=this;c.ajax({url:a,type:f,dataType:"html",data:b,complete:function(j,n){if(n==="success"||n==="notmodified")i.html(e?c("<div />").append(j.responseText.replace(qb,"")).find(e):j.responseText);d&&i.each(d,[j.responseText,n,j])}});return this},serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&
105
+ (this.checked||rb.test(this.nodeName)||sb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,
106
+ b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:z.XMLHttpRequest&&(z.location.protocol!=="file:"||!z.ActiveXObject)?function(){return new z.XMLHttpRequest}:
107
+ function(){try{return new z.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&&e.success.call(o,n,j,w);e.global&&f("ajaxSuccess",[w,e])}function d(){e.complete&&e.complete.call(o,w,j);e.global&&f("ajaxComplete",[w,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}
108
+ function f(q,p){(e.context?c(e.context):c.event).trigger(q,p)}var e=c.extend(true,{},c.ajaxSettings,a),i,j,n,o=a&&a.context||e,m=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,e.traditional);if(e.dataType==="jsonp"){if(m==="GET")N.test(e.url)||(e.url+=(ja.test(e.url)?"&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!N.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&N.test(e.data)||
109
+ N.test(e.url))){i=e.jsonpCallback||"jsonp"+pb++;if(e.data)e.data=(e.data+"").replace(N,"="+i+"$1");e.url=e.url.replace(N,"="+i+"$1");e.dataType="script";z[i]=z[i]||function(q){n=q;b();d();z[i]=v;try{delete z[i]}catch(p){}A&&A.removeChild(B)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache===false&&m==="GET"){var s=J(),x=e.url.replace(tb,"$1_="+s+"$2");e.url=x+(x===e.url?(ja.test(e.url)?"&":"?")+"_="+s:"")}if(e.data&&m==="GET")e.url+=(ja.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&
110
+ c.event.trigger("ajaxStart");s=(s=ub.exec(e.url))&&(s[1]&&s[1]!==location.protocol||s[2]!==location.host);if(e.dataType==="script"&&m==="GET"&&s){var A=r.getElementsByTagName("head")[0]||r.documentElement,B=r.createElement("script");B.src=e.url;if(e.scriptCharset)B.charset=e.scriptCharset;if(!i){var C=false;B.onload=B.onreadystatechange=function(){if(!C&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){C=true;b();d();B.onload=B.onreadystatechange=null;A&&B.parentNode&&
111
+ A.removeChild(B)}}}A.insertBefore(B,A.firstChild);return v}var E=false,w=e.xhr();if(w){e.username?w.open(m,e.url,e.async,e.username,e.password):w.open(m,e.url,e.async);try{if(e.data||a&&a.contentType)w.setRequestHeader("Content-Type",e.contentType);if(e.ifModified){c.lastModified[e.url]&&w.setRequestHeader("If-Modified-Since",c.lastModified[e.url]);c.etag[e.url]&&w.setRequestHeader("If-None-Match",c.etag[e.url])}s||w.setRequestHeader("X-Requested-With","XMLHttpRequest");w.setRequestHeader("Accept",
112
+ e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(fa){}if(e.beforeSend&&e.beforeSend.call(o,w,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");w.abort();return false}e.global&&f("ajaxSend",[w,e]);var g=w.onreadystatechange=function(q){if(!w||w.readyState===0||q==="abort"){E||d();E=true;if(w)w.onreadystatechange=c.noop}else if(!E&&w&&(w.readyState===4||q==="timeout")){E=true;w.onreadystatechange=c.noop;j=q==="timeout"?"timeout":!c.httpSuccess(w)?
113
+ "error":e.ifModified&&c.httpNotModified(w,e.url)?"notmodified":"success";var p;if(j==="success")try{n=c.httpData(w,e.dataType,e)}catch(u){j="parsererror";p=u}if(j==="success"||j==="notmodified")i||b();else c.handleError(e,w,j,p);d();q==="timeout"&&w.abort();if(e.async)w=null}};try{var h=w.abort;w.abort=function(){w&&h.call(w);g("abort")}}catch(k){}e.async&&e.timeout>0&&setTimeout(function(){w&&!E&&g("timeout")},e.timeout);try{w.send(m==="POST"||m==="PUT"||m==="DELETE"?e.data:null)}catch(l){c.handleError(e,
114
+ w,null,l);d()}e.async||g();return w}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||a,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=
115
+ f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;e&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b==="json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(j,n){if(c.isArray(n))c.each(n,
116
+ function(o,m){b?f(j,m):d(j+"["+(typeof m==="object"||c.isArray(m)?o:"")+"]",m)});else!b&&n!=null&&typeof n==="object"?c.each(n,function(o,m){d(j+"["+o+"]",m)}):f(j,n)}function f(j,n){n=c.isFunction(n)?n():n;e[e.length]=encodeURIComponent(j)+"="+encodeURIComponent(n)}var e=[];if(b===v)b=c.ajaxSettings.traditional;if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var i in a)d(i,a[i]);return e.join("&").replace(vb,"+")}});var ka={},wb=/toggle|show|hide/,xb=/^([+-]=)?([\d+-.]+)(.*)$/,
117
+ W,ta=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a||a===0)return this.animate(K("show",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");this[a].style.display=d||"";if(c.css(this[a],"display")==="none"){d=this[a].nodeName;var f;if(ka[d])f=ka[d];else{var e=c("<"+d+" />").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();
118
+ ka[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a<b;a++)this[a].style.display=c.data(this[a],"olddisplay")||"";return this}},hide:function(a,b){if(a||a===0)return this.animate(K("hide",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");!d&&d!=="none"&&c.data(this[a],"olddisplay",c.css(this[a],"display"))}a=0;for(b=this.length;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b){var d=typeof a==="boolean";if(c.isFunction(a)&&
119
+ c.isFunction(b))this._toggle.apply(this,arguments);else a==null||d?this.each(function(){var f=d?a:c(this).is(":hidden");c(this)[f?"show":"hide"]()}):this.animate(K("toggle",3),a,b);return this},fadeTo:function(a,b,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,d)},animate:function(a,b,d,f){var e=c.speed(b,d,f);if(c.isEmptyObject(a))return this.each(e.complete);return this[e.queue===false?"each":"queue"](function(){var i=c.extend({},e),j,n=this.nodeType===1&&c(this).is(":hidden"),
120
+ o=this;for(j in a){var m=j.replace(ha,ia);if(j!==m){a[m]=a[j];delete a[j];j=m}if(a[j]==="hide"&&n||a[j]==="show"&&!n)return i.complete.call(this);if((j==="height"||j==="width")&&this.style){i.display=c.css(this,"display");i.overflow=this.style.overflow}if(c.isArray(a[j])){(i.specialEasing=i.specialEasing||{})[j]=a[j][1];a[j]=a[j][0]}}if(i.overflow!=null)this.style.overflow="hidden";i.curAnim=c.extend({},a);c.each(a,function(s,x){var A=new c.fx(o,i,s);if(wb.test(x))A[x==="toggle"?n?"show":"hide":x](a);
121
+ else{var B=xb.exec(x),C=A.cur(true)||0;if(B){x=parseFloat(B[2]);var E=B[3]||"px";if(E!=="px"){o.style[s]=(x||1)+E;C=(x||1)/A.cur(true)*C;o.style[s]=C+E}if(B[1])x=(B[1]==="-="?-1:1)*x+C;A.custom(C,x,E)}else A.custom(C,x,"")}});return true})},stop:function(a,b){var d=c.timers;a&&this.queue([]);this.each(function(){for(var f=d.length-1;f>=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:K("show",1),slideUp:K("hide",1),slideToggle:K("toggle",
122
+ 1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration==="number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,
123
+ b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==
124
+ null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(i){return e.step(i)}this.startTime=J();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!W)W=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop===
125
+ "width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=J(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=
126
+ this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem,e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=
127
+ c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b<a.length;b++)a[b]()||a.splice(b--,1);a.length||c.fx.stop()},stop:function(){clearInterval(W);W=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){c.style(a.elem,"opacity",a.now)},_default:function(a){if(a.elem.style&&a.elem.style[a.prop]!=
128
+ null)a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit;else a.elem[a.prop]=a.now}}});if(c.expr&&c.expr.filters)c.expr.filters.animated=function(a){return c.grep(c.timers,function(b){return a===b.elem}).length};c.fn.offset="getBoundingClientRect"in r.documentElement?function(a){var b=this[0];if(a)return this.each(function(e){c.offset.setOffset(this,a,e)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);var d=b.getBoundingClientRect(),
129
+ f=b.ownerDocument;b=f.body;f=f.documentElement;return{top:d.top+(self.pageYOffset||c.support.boxModel&&f.scrollTop||b.scrollTop)-(f.clientTop||b.clientTop||0),left:d.left+(self.pageXOffset||c.support.boxModel&&f.scrollLeft||b.scrollLeft)-(f.clientLeft||b.clientLeft||0)}}:function(a){var b=this[0];if(a)return this.each(function(s){c.offset.setOffset(this,a,s)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);c.offset.initialize();var d=b.offsetParent,f=
130
+ b,e=b.ownerDocument,i,j=e.documentElement,n=e.body;f=(e=e.defaultView)?e.getComputedStyle(b,null):b.currentStyle;for(var o=b.offsetTop,m=b.offsetLeft;(b=b.parentNode)&&b!==n&&b!==j;){if(c.offset.supportsFixedPosition&&f.position==="fixed")break;i=e?e.getComputedStyle(b,null):b.currentStyle;o-=b.scrollTop;m-=b.scrollLeft;if(b===d){o+=b.offsetTop;m+=b.offsetLeft;if(c.offset.doesNotAddBorder&&!(c.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(b.nodeName))){o+=parseFloat(i.borderTopWidth)||
131
+ 0;m+=parseFloat(i.borderLeftWidth)||0}f=d;d=b.offsetParent}if(c.offset.subtractsBorderForOverflowNotVisible&&i.overflow!=="visible"){o+=parseFloat(i.borderTopWidth)||0;m+=parseFloat(i.borderLeftWidth)||0}f=i}if(f.position==="relative"||f.position==="static"){o+=n.offsetTop;m+=n.offsetLeft}if(c.offset.supportsFixedPosition&&f.position==="fixed"){o+=Math.max(j.scrollTop,n.scrollTop);m+=Math.max(j.scrollLeft,n.scrollLeft)}return{top:o,left:m}};c.offset={initialize:function(){var a=r.body,b=r.createElement("div"),
132
+ d,f,e,i=parseFloat(c.curCSS(a,"marginTop",true))||0;c.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"});b.innerHTML="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";a.insertBefore(b,a.firstChild);
133
+ d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i;a.removeChild(b);c.offset.initialize=c.noop},
134
+ bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),i=parseInt(c.curCSS(a,"top",true),10)||0,j=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a,d,e);d={top:b.top-e.top+i,left:b.left-
135
+ e.left+j};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top-f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=
136
+ this.offsetParent||r.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],i;if(!e)return null;if(f!==v)return this.each(function(){if(i=ua(this))i.scrollTo(!a?f:c(i).scrollLeft(),a?f:c(i).scrollTop());else this[d]=f});else return(i=ua(e))?"pageXOffset"in i?i[a?"pageYOffset":"pageXOffset"]:c.support.boxModel&&i.document.documentElement[d]||i.document.body[d]:e[d]}});
137
+ c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;if(c.isFunction(f))return this.each(function(i){var j=c(this);j[d](f.call(this,i,j[d]()))});return"scrollTo"in e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||
138
+ e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===v?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});z.jQuery=z.$=c})(window);
139
+ jQuery.noConflict();
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>CP_Feed</name>
4
+ <version>2.2.8</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Google feed extension by Commerce Pundit will help you export your products in few minutes. </summary>
10
+ <description>Google feed extension allow you to export your complete catalog of products in few minutes in valid and well-structured data feed from your Magento website.</description>
11
+ <notes>CP Google Feed</notes>
12
+ <authors><author><name>Commerce Pundit</name><user>CPExtensions</user><email>support@commercepundit.com</email></author></authors>
13
+ <date>2016-01-21</date>
14
+ <time>13:03:32</time>
15
+ <contents><target name="magecommunity"><dir name="CP"><dir name="Feed"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Form"><dir name="Renderer"><file name="Website.php" hash="8ee185252df625733cee9589723e6b03"/></dir></dir></dir><dir name="Items"><dir name="Edit"><file name="Form.php" hash="281c54bcf18d4a37730ec8982f5cbade"/><dir name="Tab"><file name="Advanced.php" hash="4d4ca3969e5b7f4dc3bde279c106f78d"/><dir name="Content"><file name="Csv.php" hash="ca94c4ad9fea8fcac828b534c283adf2"/><file name="Productcategory.php" hash="9df976ee04aaccde4f294ad6b6f43f6a"/></dir><file name="Main.php" hash="22a83880c9546fe4e3a19fb4f0ef3aa1"/><file name="Type.php" hash="89d615e629c2936ad11703e0d778161e"/></dir><file name="Tabs.php" hash="a822029bd8e3943acb3d44dd9ba3ca8b"/></dir><file name="Edit.php" hash="98f3d0ba65b27a665e6cb64e3e3dc401"/><dir name="Grid"><dir name="Renderer"><file name="AccessUrl.php" hash="477ad8bad326cc50c176c02a3c4e945d"/><file name="Datetime.php" hash="f28d161d591290a16ebb16c5f2e7a8c7"/></dir></dir><file name="Grid.php" hash="8b0d7ad8d9b32d75da4eabd064f85ca8"/></dir><file name="Items.php" hash="b44445c74522f0d22560da4cfedce047"/></dir></dir><dir name="Helper"><file name="Data.php" hash="1952f2635385489992ce7b7769b7d6c9"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><file name="Store.php" hash="a8f33dce239fa9a86a045c9ad321fb34"/></dir></dir></dir></dir><dir name="Custom"><file name="Attribute.php" hash="c1002e5546c8cfce0d7665f5d4fd0a5a"/></dir><dir name="Item"><dir name="Block"><file name="Category.php" hash="30d27291cb1cfcb998db3fc0612ef031"/><file name="Product.php" hash="4d5c21b1621c7920e8d9927be2ad9eb4"/></dir><file name="Block.php" hash="019c21f70b028c51098f120ae49a0c20"/></dir><file name="Item.php" hash="686380ca1496db758e1d0229e9f09a56"/><dir name="Mysql4"><dir name="Custom"><dir name="Attribute"><file name="Collection.php" hash="413b008ae2b572412af58b2154e334fa"/></dir><file name="Attribute.php" hash="8a9317659acab03832c6ee9ab237f9f0"/></dir><dir name="Item"><file name="Collection.php" hash="df92d9db9e738df81f5567ff457989cf"/></dir><file name="Item.php" hash="e509fdbc21d1e968ea8c5650b68be6a0"/></dir><file name="Observer.php" hash="e605fe5db75c580d21b9dc25d05c0ac2"/><dir name="Option"><file name="Productcategories.php" hash="4183a32582d81e397eff37abd1823e4b"/></dir><dir name="Product"><file name="Collection.php" hash="cc1cdc385b59779d5ccc565ec5b1ee8f"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ItemsController.php" hash="0a460cf7830813714309bdd3f1eed431"/></dir><file name="IndexController.php" hash="61443343d3087490d5c1d6b9e91401f4"/></dir><dir name="etc"><file name="adminhtml.xml" hash="d50ae37670f8aafeee19a85c8267ae85"/><file name="config.xml" hash="b542715ff73cd1159bcfad35a496fcdf"/></dir><dir name="sql"><dir name="cp_feed_setup"><file name="mysql4-install-1.0.php" hash="d89290d5086b4b8d86c9ae906bc93244"/><file name="mysql4-install-1.3.php" hash="7637cb018768a1d5a7183d1c3f4d77f3"/><file name="mysql4-install-1.4.php" hash="56ee38873193871b85f9a6f16526381c"/><file name="mysql4-install-2.0.php" hash="4119236b6e800963487174aad30695a0"/><file name="mysql4-upgrade-1.3-1.4.php" hash="019cebb501c16d44efdc087459762219"/><file name="mysql4-upgrade-1.4-2.0.php" hash="74a04a9eb5376614243bfcf68709b35d"/><file name="mysql4-upgrade-2.0-2.1.php" hash="74a04a9eb5376614243bfcf68709b35d"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cp_Feed.xml" hash="34cbc733aa9abb4bfa47f85200c6c14e"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="cp"><dir name="feed"><dir name="item"><dir name="edit"><file name="category_product.phtml" hash="1a45b139a03c4326a57bbced1f6cd929"/><dir name="content"><file name="mapping.phtml" hash="2f374a206c7bc711dc180793728d23e2"/></dir><file name="content.phtml" hash="7190e12f781a0de32b8938b7c45baa1b"/></dir><dir name="import"><file name="form.phtml" hash="7c4a78614fae251bd880851be1cb03f6"/></dir></dir></dir></dir></dir><dir name="layout"><file name="cp-feed.xml" hash="07aaef5eddd2b3093394c1f707d254d5"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="cp"><file name="cpfeed.css" hash="5ac5a8ca52d54587cde21b4a983d52d1"/><file name="feed.css" hash="86821964292d3cb55f88cda5e6df8f36"/><dir name="images"><file name="plus.png" hash="cd0f0894958340185caff13f43810973"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="cpfeed"><file name="jquery-1.8.2.min.js" hash="0c336c9d7e661b0efbaae288939a7607"/></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/adminhtml/default/default/cp/cpfeed.css ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #parent {
2
+ background:url('images/plus.png') no-repeat scroll 0 9px;
3
+ float: right;
4
+ height: 21px;
5
+ width: 19px;
6
+ }
7
+ #outer_ul {
8
+ padding-left:6px;
9
+ width: auto;
10
+ }
11
+ #outer_ul li {
12
+ margin: 0 0 0 3px;
13
+ padding: 0 0 0 13px;
14
+ line-height: 25px;
15
+ background: url("../images/arrow_item.gif") 0 12px no-repeat;
16
+ border-bottom: 1px solid #E0E0E0;
17
+ }
18
+ .categorychkbx{
19
+ margin-right: 5px;
20
+ }
skin/adminhtml/default/default/cp/feed.css ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .grid .condition-grid,
2
+ .grid .condition-grid td{
3
+ border:0;
4
+ line-height:17px;
5
+ }
6
+ .grid .condition-grid td{
7
+ padding:1px 1px 1px 0 !important;
8
+ }
9
+ td.result-column,
10
+ td.type-column,
11
+ td.action-column{
12
+ padding-top:5px;
13
+ }
14
+ .condition-value-wraper{
15
+ width:140px;
16
+ /*padding:0 2px;
17
+ border-color:#AAAAAA #C8C8C8 #C8C8C8 #AAAAAA;
18
+ border-style:solid;
19
+ border-width:1px;*/
20
+ clear:both;
21
+ overflow:hidden;
22
+ zoom:1;
23
+ }
24
+ .condition-value-wraper input,
25
+ .condition-value-wraper select{
26
+ float:left;
27
+ }
28
+ .condition-value-wraper input,
29
+ .condition-value-wraper select{
30
+ padding:1px !important;
31
+ width:136px !important;
32
+ border-color:#AAAAAA #C8C8C8 #C8C8C8 #AAAAAA !important;
33
+ border-style:solid !important;
34
+ border-width:1px !important;
35
+ }
36
+ .condition-value-wraper select{
37
+ padding:0 !important;
38
+ width:136px !important;
39
+ }
40
+ .condition-actions .delete span{
41
+ padding-left:15px;
42
+ }
43
+ .type-field-wrapper{
44
+ float:left;
45
+ }
46
+ .grid td.result-column input.input-text{
47
+ width:99%;
48
+ float:left;
49
+ height:16px;
50
+ padding:0;
51
+ }
52
+ .grid table td.feed-row-first{
53
+ width:466px;
54
+ }
55
+ .grid table td.type-column{
56
+ width:140px;
57
+ }
58
+ .grid table td.action-column{
59
+ width:191px;
60
+ }
61
+ .type-attribute-field-wrapper{
62
+ float:left;
63
+ margin:3px 0 0;
64
+ display:none;
65
+ }
66
+ .type-attribute-field-wrapper select,
67
+ .grid table td.type-column .type-field-wrapper select{
68
+ width:140px !important;
69
+ }
70
+ .grid table td.action-column .button{
71
+ width:94px;
72
+ }
73
+ .grid table td.action-column .delete{
74
+ width:94px;
75
+ }
76
+ .value-field-wrapper{
77
+ padding:0 2px;
78
+ border-color:#AAAAAA #C8C8C8 #C8C8C8 #AAAAAA;
79
+ border-style:solid;
80
+ border-width:1px;
81
+ clear:both;
82
+ overflow:hidden;
83
+ zoom:1;
84
+ }
85
+ .value-field-wrapper input{
86
+ width:99%;
87
+ float:left;
88
+ height:16px;
89
+ border:0;
90
+ padding:0;
91
+ }
92
+ .result-wrapper{
93
+ padding:0 2px;
94
+ border-color:#AAAAAA #C8C8C8 #C8C8C8 #AAAAAA;
95
+ border-style:solid;
96
+ border-width:1px;
97
+ clear:both;
98
+ overflow:hidden;
99
+ zoom:1;
100
+ }
101
+ .result-wrapper input{
102
+ width:100%;
103
+ border:0;
104
+ padding:0;
105
+ }
skin/adminhtml/default/default/cp/images/plus.png ADDED
Binary file