visual-merchandising-product-listing-campaign-creator - Version 1.1.0

Version Notes

Any questions or concerns, please email cs@tagalys.com and we will get back to you in less than 24 hours.

Download this release

Release Info

Developer Palani
Extension visual-merchandising-product-listing-campaign-creator
Version 1.1.0
Comparing to
See all releases


Code changes from version 1.0.1 to 1.1.0

Files changed (172) hide show
  1. app/code/community/Tagalys/Core/.DS_Store +0 -0
  2. app/code/community/Tagalys/Core/Block/.DS_Store +0 -0
  3. app/code/{local/Tagalys/MerchandisingPage → community/Tagalys/Core/Block/Adminhtml}/.DS_Store +0 -0
  4. app/code/{local/Tagalys/Tsearch/Block → community/Tagalys/Core/Block/Adminhtml/Tagalys}/.DS_Store +0 -0
  5. app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit.php +42 -0
  6. app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/.DS_Store +0 -0
  7. app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Form.php +20 -0
  8. app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/.DS_Store +0 -0
  9. app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Apicredentials.php +97 -0
  10. app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Mpages.php +83 -0
  11. app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Search.php +87 -0
  12. app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Searchsuggestions.php +89 -0
  13. app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Support.php +157 -0
  14. app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Sync.php +166 -0
  15. app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Syncsettings.php +103 -0
  16. app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tabs.php +78 -0
  17. app/code/community/Tagalys/Core/Helper/Data.php +75 -0
  18. app/code/community/Tagalys/Core/Helper/Service.php +157 -0
  19. app/code/community/Tagalys/Core/Helper/SyncFile.php +461 -0
  20. app/code/community/Tagalys/Core/Model/.DS_Store +0 -0
  21. app/code/community/Tagalys/Core/Model/Client.php +111 -0
  22. app/code/community/Tagalys/Core/Model/Config.php +81 -0
  23. app/code/{local/Tagalys/Tsearch → community/Tagalys/Core/Model/Mysql4}/.DS_Store +0 -0
  24. app/code/community/Tagalys/Core/Model/Mysql4/Config.php +9 -0
  25. app/code/{local → community}/Tagalys/Core/Model/Mysql4/Config/Collection.php +5 -7
  26. app/code/community/Tagalys/Core/Model/Mysql4/Queue.php +15 -0
  27. app/code/community/Tagalys/Core/Model/Mysql4/Queue/Collection.php +6 -0
  28. app/code/community/Tagalys/Core/Model/Observer.php +57 -0
  29. app/code/community/Tagalys/Core/Model/ProductDetails.php +154 -0
  30. app/code/community/Tagalys/Core/Model/Queue.php +97 -0
  31. app/code/community/Tagalys/Core/controllers/.DS_Store +0 -0
  32. app/code/community/Tagalys/Core/controllers/Adminhtml/TagalysController.php +122 -0
  33. app/code/community/Tagalys/Core/controllers/SyncfilesController.php +31 -0
  34. app/code/community/Tagalys/Core/etc/config.xml +209 -0
  35. app/code/community/Tagalys/Core/sql/.DS_Store +0 -0
  36. app/code/community/Tagalys/Core/sql/tagalys_core_setup/mysql4-install-0.3.0.php +48 -0
  37. app/code/community/Tagalys/Core/sql/tagalys_core_setup/mysql4-upgrade-0.1.0-0.3.0.php +48 -0
  38. app/code/community/Tagalys/Core/sql/tagalys_core_setup/mysql4-upgrade-0.2.0-0.3.0.php +48 -0
  39. app/code/{local/Tagalys/Tsearch/Model → community/Tagalys/Mpages}/.DS_Store +0 -0
  40. app/code/community/Tagalys/Mpages/controllers/IndexController.php +48 -0
  41. app/code/community/Tagalys/Mpages/etc/config.xml +32 -0
  42. app/code/{local/Tagalys/MerchandisingPage/Model → community/Tagalys/Search}/.DS_Store +0 -0
  43. app/code/community/Tagalys/Search/controllers/IndexController.php +24 -0
  44. app/code/community/Tagalys/Search/etc/config.xml +22 -0
  45. app/code/community/Tagalys/SearchSuggestions/Helper/Data.php +51 -0
  46. app/code/community/Tagalys/SearchSuggestions/Model/Observer.php +15 -0
  47. app/code/community/Tagalys/SearchSuggestions/etc/config.xml +47 -0
  48. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit.php +0 -41
  49. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Form.php +0 -20
  50. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Credentials.php +0 -119
  51. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Debug.php +0 -87
  52. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Merchandisingpage.php +0 -96
  53. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Setup.php +0 -169
  54. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Signup.php +0 -79
  55. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Similarproducts.php +0 -83
  56. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Sync.php +0 -145
  57. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Tsearch.php +0 -88
  58. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Tsearchsuggestion.php +0 -121
  59. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tabs.php +0 -120
  60. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Notifications.php +0 -17
  61. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Progress.php +0 -31
  62. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/SearchReady.php +0 -29
  63. app/code/local/Tagalys/Core/Helper/Data.php +0 -90
  64. app/code/local/Tagalys/Core/Model/Config.php +0 -10
  65. app/code/local/Tagalys/Core/Model/Mysql4/Config.php +0 -8
  66. app/code/local/Tagalys/Core/Model/Observer.php +0 -144
  67. app/code/local/Tagalys/Core/etc/adminhtml.xml +0 -17
  68. app/code/local/Tagalys/Core/etc/config.xml +0 -160
  69. app/code/local/Tagalys/Core/sql/tagalys_core_setup/mysql4-install-0.2.0.php +0 -18
  70. app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Layer/Filter/Attribute.php +0 -49
  71. app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Layer/Filter/Category.php +0 -34
  72. app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Layer/Filter/Price.php +0 -48
  73. app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Layer/State.php +0 -15
  74. app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Layer/View.php +0 -135
  75. app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Product/List.php +0 -48
  76. app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Product/List/Toolbar.php +0 -95
  77. app/code/local/Tagalys/MerchandisingPage/Block/Catalogsearch/Layer.php +0 -32
  78. app/code/local/Tagalys/MerchandisingPage/Block/Catalogsearch/Layer/Filter/Attribute.php +0 -39
  79. app/code/local/Tagalys/MerchandisingPage/Block/Catalogsearch/Layer/View.php +0 -145
  80. app/code/local/Tagalys/MerchandisingPage/Block/Catalogsearch/Result.php +0 -29
  81. app/code/local/Tagalys/MerchandisingPage/Block/Filter.php +0 -21
  82. app/code/local/Tagalys/MerchandisingPage/Block/Page/Html/Pager.php +0 -156
  83. app/code/local/Tagalys/MerchandisingPage/Helper/Data.php +0 -203
  84. app/code/local/Tagalys/MerchandisingPage/Model/Catalog/Layer.php +0 -62
  85. app/code/local/Tagalys/MerchandisingPage/Model/Catalog/Layer/Filter/Attribute.php +0 -166
  86. app/code/local/Tagalys/MerchandisingPage/Model/Catalog/Layer/Filter/Category.php +0 -103
  87. app/code/local/Tagalys/MerchandisingPage/Model/Catalog/Layer/Filter/Price.php +0 -177
  88. app/code/local/Tagalys/MerchandisingPage/Model/Catalogsearch/Layer.php +0 -59
  89. app/code/local/Tagalys/MerchandisingPage/Model/Client.php +0 -146
  90. app/code/local/Tagalys/MerchandisingPage/controllers/IndexController.php +0 -37
  91. app/code/local/Tagalys/MerchandisingPage/etc/config.xml +0 -94
  92. app/code/local/Tagalys/PopularSearches/Model/Observer.php +0 -86
  93. app/code/local/Tagalys/PopularSearches/etc/config.xml +0 -40
  94. app/code/local/Tagalys/SearchSuggestions/Block/Catalog/Layer.php +0 -24
  95. app/code/local/Tagalys/SearchSuggestions/Block/Catalog/Layer/Filter/Attribute.php +0 -17
  96. app/code/local/Tagalys/SearchSuggestions/Block/Catalog/Layer/Filter/Category.php +0 -17
  97. app/code/local/Tagalys/SearchSuggestions/Helper/Data.php +0 -31
  98. app/code/local/Tagalys/SearchSuggestions/Model/Catalog/Layer/Filter/Attribute.php +0 -33
  99. app/code/local/Tagalys/SearchSuggestions/Model/Catalog/Layer/Filter/Category.php +0 -43
  100. app/code/local/Tagalys/SearchSuggestions/controllers/AutoSuggestController.php +0 -33
  101. app/code/local/Tagalys/SearchSuggestions/etc/config.xml +0 -61
  102. app/code/local/Tagalys/Sync/Helper/Data.php +0 -90
  103. app/code/local/Tagalys/Sync/Helper/Inventory.php +0 -35
  104. app/code/local/Tagalys/Sync/Helper/Service.php +0 -311
  105. app/code/local/Tagalys/Sync/Helper/TagalysFeedFactory.php +0 -463
  106. app/code/local/Tagalys/Sync/Model/Adminhtml/System/Config/Backend/Tagalys/Cron.php +0 -39
  107. app/code/local/Tagalys/Sync/Model/Client.php +0 -141
  108. app/code/local/Tagalys/Sync/Model/Dataflow/Convert/Adapter/Io.php +0 -17
  109. app/code/local/Tagalys/Sync/Model/Mysql4/Queue.php +0 -8
  110. app/code/local/Tagalys/Sync/Model/Mysql4/Queue/Collection.php +0 -10
  111. app/code/local/Tagalys/Sync/Model/Observer.php +0 -172
  112. app/code/local/Tagalys/Sync/Model/ProductDetails.php +0 -239
  113. app/code/local/Tagalys/Sync/Model/Queue.php +0 -12
  114. app/code/local/Tagalys/Sync/controllers/Adminhtml/ImportController.php +0 -51
  115. app/code/local/Tagalys/Sync/controllers/Adminhtml/System/Convert/GuiController.php +0 -29
  116. app/code/local/Tagalys/Sync/controllers/Adminhtml/TagalysController.php +0 -110
  117. app/code/local/Tagalys/Sync/controllers/FeedController.php +0 -124
  118. app/code/local/Tagalys/Sync/etc/config.xml +0 -206
  119. app/code/local/Tagalys/Sync/etc/wsdl.xml +0 -53
  120. app/code/local/Tagalys/Sync/sql/sync_setup/mysql4-install-0.1.0.php +0 -18
  121. app/code/local/Tagalys/Sync/sql/sync_setup/mysql4-install-0.2.0.php +0 -18
  122. app/code/local/Tagalys/Sync/sql/sync_setup/mysql4-upgrade-0.1.0-0.2.0.php +0 -15
  123. app/code/local/Tagalys/Tsearch/Block/Catalog/Layer/Filter/Attribute.php +0 -43
  124. app/code/local/Tagalys/Tsearch/Block/Catalog/Layer/Filter/Category.php +0 -36
  125. app/code/local/Tagalys/Tsearch/Block/Catalog/Layer/Filter/Price.php +0 -66
  126. app/code/local/Tagalys/Tsearch/Block/Catalog/Layer/State.php +0 -15
  127. app/code/local/Tagalys/Tsearch/Block/Catalog/Layer/View.php +0 -119
  128. app/code/local/Tagalys/Tsearch/Block/Catalog/Product/.DS_Store +0 -0
  129. app/code/local/Tagalys/Tsearch/Block/Catalog/Product/List.php +0 -42
  130. app/code/local/Tagalys/Tsearch/Block/Catalog/Product/List/Toolbar.php +0 -92
  131. app/code/local/Tagalys/Tsearch/Block/Catalogsearch/Layer.php +0 -32
  132. app/code/local/Tagalys/Tsearch/Block/Catalogsearch/Layer/Filter/Attribute.php +0 -39
  133. app/code/local/Tagalys/Tsearch/Block/Catalogsearch/Layer/View.php +0 -145
  134. app/code/local/Tagalys/Tsearch/Block/Catalogsearch/Result.php +0 -29
  135. app/code/local/Tagalys/Tsearch/Block/Page/.DS_Store +0 -0
  136. app/code/local/Tagalys/Tsearch/Block/Page/Html/Pager.php +0 -155
  137. app/code/local/Tagalys/Tsearch/Helper/Data.php +0 -120
  138. app/code/local/Tagalys/Tsearch/Model/Catalog/Layer.php +0 -37
  139. app/code/local/Tagalys/Tsearch/Model/Catalog/Layer/Filter/Attribute.php +0 -157
  140. app/code/local/Tagalys/Tsearch/Model/Catalog/Layer/Filter/Category.php +0 -100
  141. app/code/local/Tagalys/Tsearch/Model/Catalog/Layer/Filter/Price.php +0 -175
  142. app/code/local/Tagalys/Tsearch/Model/Catalog/Product/List.php +0 -8
  143. app/code/local/Tagalys/Tsearch/Model/Catalogsearch/Layer.php +0 -59
  144. app/code/local/Tagalys/Tsearch/Model/Client/Connector.php +0 -251
  145. app/code/local/Tagalys/Tsearch/Model/Engine.php +0 -96
  146. app/code/local/Tagalys/Tsearch/Model/Observer.php +0 -10
  147. app/code/local/Tagalys/Tsearch/Model/Resource/Catalog/Product/Collection.php +0 -368
  148. app/code/local/Tagalys/Tsearch/Model/Resource/Catalog/Product/testCollection.php +0 -368
  149. app/code/local/Tagalys/Tsearch/etc/config.xml +0 -98
  150. app/design/adminhtml/default/default/layout/Tagalys_core.xml +0 -22
  151. app/design/adminhtml/default/default/layout/tagalys_core.xml +16 -0
  152. app/design/adminhtml/default/default/template/tagalys/progressbar.phtml +0 -159
  153. app/design/frontend/base/default/layout/tagalys/ss.xml +0 -7
  154. app/design/frontend/base/default/layout/tagalys_merchandising.xml +0 -79
  155. app/design/frontend/base/default/layout/tagalys_search_suggestions.xml +8 -0
  156. app/design/frontend/base/default/template/tagalys/tagalys_ss.phtml +0 -128
  157. app/design/frontend/base/default/template/tagalys_merchandising_page/mp_template.phtml +0 -20
  158. app/design/frontend/base/default/template/tagalys_mpages/index.phtml +23 -0
  159. app/design/frontend/base/default/template/tagalys_search/index.phtml +22 -0
  160. app/design/frontend/base/default/template/tagalys_search_suggestions/search_suggestions.phtml +82 -0
  161. app/etc/modules/Tagalys_Core.xml +11 -0
  162. app/etc/modules/Tagalys_MerchandisingPage.xml +0 -14
  163. app/etc/modules/Tagalys_Mpages.xml +11 -0
  164. app/etc/modules/Tagalys_Search.xml +11 -0
  165. app/etc/modules/Tagalys_SearchSuggestions.xml +11 -26
  166. app/etc/modules/Tagalys_Tsearch.xml +0 -10
  167. js/tagalys-configuration.js +8 -0
  168. js/tagalys/tagalys-core.js +0 -9
  169. package.xml +6 -6
  170. skin/adminhtml/default/default/css/{tagalys-core.css → tagalys/tagalys-configuration.css} +40 -35
  171. skin/adminhtml/default/default/images/logo-tagalys.png +0 -0
  172. skin/adminhtml/default/default/images/tagalys/tagalys-logo.png +0 -0
app/code/community/Tagalys/Core/.DS_Store ADDED
Binary file
app/code/community/Tagalys/Core/Block/.DS_Store ADDED
Binary file
app/code/{local/Tagalys/MerchandisingPage → community/Tagalys/Core/Block/Adminhtml}/.DS_Store RENAMED
Binary file
app/code/{local/Tagalys/Tsearch/Block → community/Tagalys/Core/Block/Adminhtml/Tagalys}/.DS_Store RENAMED
Binary file
app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tagalys_Core_Block_Adminhtml_Tagalys_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct() {
6
+
7
+ $this->_objectId = 'id';
8
+ $this->_controller = 'adminhtml_tagalys';
9
+ $this->_blockGroup = 'tagalys_core';
10
+ parent::__construct();
11
+
12
+ $this->_removeButton('save');
13
+ $this->_removeButton('back');
14
+ $this->_removeButton('reset');
15
+
16
+ }
17
+
18
+ /**
19
+ * Get header text
20
+ *
21
+ * @return string
22
+ */
23
+ public function getHeaderText() {
24
+
25
+ $setup_status = Mage::getModel('tagalys_core/config')->getTagalysConfig('setup_status');
26
+ if ($setup_status == 'completed') {
27
+ return $this->__('Configuration');
28
+ } else {
29
+ return $this->__('Setup');
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Check permission for passed action
35
+ *
36
+ * @param string $action
37
+ * @return bool
38
+ */
39
+ protected function _isAllowedAction($action) {
40
+ return true;
41
+ }
42
+ }
app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/.DS_Store ADDED
Binary file
app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Form.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+
6
+ protected function _prepareForm()
7
+ {
8
+ /** @var $form Varien_Data_Form */
9
+ $form = new Varien_Data_Form(array(
10
+ 'id' => 'edit_form',
11
+ 'action' => $this->getUrl('*/tagalys/save/', array('id' => $this->getRequest()->getParam('id'))),
12
+ 'method' => 'post'
13
+ ));
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+
18
+ return parent::_prepareForm();
19
+ }
20
+ }
app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/.DS_Store ADDED
Binary file
app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Apicredentials.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tab_Apicredentials extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ }
8
+
9
+ protected function _prepareForm() {
10
+ $this->_helper = Mage::helper('tagalys_core');
11
+
12
+ $form = Mage::getModel('varien/data_form', array(
13
+ 'id' => 'edit_form',
14
+ 'action' => $this->getUrl('*/tagalys', array('_current' => true)),
15
+ 'method' => 'post'
16
+ ));
17
+
18
+ $form->setHtmlIdPrefix('admin_tagalys_core_');
19
+ $htmlIdPrefix = $form->getHtmlIdPrefix();
20
+
21
+ $tagalys_dashboard_fieldset = $form->addFieldset('tagalys_dashboard_fieldset', array('legend' => $this->__('Tagalys Dashboard')));
22
+
23
+ $tagalys_dashboard_fieldset->addField('note', 'note', array(
24
+ 'label' => $this->__('Your Tagalys account'),
25
+ 'text' => '<img src='. $this->getSkinUrl("images/tagalys/tagalys-logo.png") .' alt="" width="125" />'.'<br>',
26
+ ));
27
+ $setup_status = Mage::getModel('tagalys_core/config')->getTagalysConfig('setup_status');
28
+ if ($setup_status == 'api_credentials') {
29
+ $tagalys_dashboard_fieldset->addField('note_dashboard', 'note', array(
30
+ 'text' => '<a href="https://next.tagalys.com/signup" target="_blank" class="tagalys-btn">Sign up for a Tagalys account</a>'
31
+ ));
32
+ } else {
33
+ $tagalys_dashboard_fieldset->addField('note_dashboard', 'note', array(
34
+ 'text' => '<a href="https://next.tagalys.com" target="_blank" class="tagalys-btn">Access your Tagalys Dashboard</a>'
35
+ ));
36
+ }
37
+
38
+ $fieldset = $form->addFieldset('tagalys_core_fieldset', array('legend' => $this->__('API Credentials')));
39
+
40
+ $fieldset->addField('api_credentials', 'textarea', array(
41
+ 'name' => 'api_credentials',
42
+ 'label' => $this->__('Paste API Credentials'),
43
+ 'required' => true,
44
+ 'value' => Mage::getModel('tagalys_core/config')->getTagalysConfig('api_credentials'),
45
+ 'style' => "width:100%; height: 100px;",
46
+ 'after_element_html' => '<small>You can find your API Credentials in the Integration section of your <a href="https://next.tagalys.com" target="_blank">Tagalys Dashboard</a></small>',
47
+ 'tabindex' => 1
48
+ ));
49
+
50
+ $fieldset->addField('submit', 'submit', array(
51
+ 'name' => 'tagalys_submit_action',
52
+ 'value' => 'Save API Credentials',
53
+ 'class'=> "tagalys-btn",
54
+ 'tabindex' => 1
55
+ ));
56
+
57
+ $this->setForm($form);
58
+ return parent::_prepareForm();
59
+ }
60
+
61
+ /**
62
+ * Tab label getter
63
+ *
64
+ * @return string
65
+ */
66
+ public function getTabLabel() {
67
+ return $this->__('API Credentials');
68
+ }
69
+
70
+ /**
71
+ * Tab title getter
72
+ *
73
+ * @return string
74
+ */
75
+ public function getTabTitle() {
76
+ return $this->__('API Credentials');
77
+ }
78
+
79
+ /**
80
+ * Check if tab can be shown
81
+ *
82
+ * @return bool
83
+ */
84
+ public function canShowTab() {
85
+ return true;
86
+ }
87
+
88
+ /**
89
+ * Check if tab hidden
90
+ *
91
+ * @return bool
92
+ */
93
+ public function isHidden() {
94
+ return false;
95
+ }
96
+
97
+ }
app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Mpages.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tab_Mpages extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ }
8
+
9
+ protected function _prepareForm() {
10
+ $this->_helper = Mage::helper('tagalys_core');
11
+
12
+ $form = Mage::getModel('varien/data_form', array(
13
+ 'id' => 'edit_form',
14
+ 'action' => $this->getUrl('*/tagalys', array('_current' => true)),
15
+ 'method' => 'post'
16
+ ));
17
+
18
+ $form->setHtmlIdPrefix('admin_tagalys_core_');
19
+ $htmlIdPrefix = $form->getHtmlIdPrefix();
20
+
21
+ $fieldset = $form->addFieldset('tagalys_mpages_fieldset', array('legend' => $this->__('Merchandising Pages')));
22
+
23
+ $fieldset->addField('enable_mpages', 'select', array(
24
+ 'name' => 'enable_mpages',
25
+ 'label' => 'Enable',
26
+ 'title' => 'Enable',
27
+ 'options' => array(
28
+ '0' => $this->__('No'),
29
+ '1' => $this->__('Yes'),
30
+ ),
31
+ 'required' => true,
32
+ 'style' => 'width:100%',
33
+ 'value' => Mage::getModel('tagalys_core/config')->getTagalysConfig("module:mpages:enabled")
34
+ ));
35
+
36
+ $fieldset->addField('submit', 'submit', array(
37
+ 'name' => 'tagalys_submit_action',
38
+ 'value' => 'Save Merchandising Pages Settings',
39
+ 'class'=> "tagalys-btn",
40
+ 'tabindex' => 1
41
+ ));
42
+
43
+ $this->setForm($form);
44
+ return parent::_prepareForm();
45
+ }
46
+
47
+ /**
48
+ * Tab label getter
49
+ *
50
+ * @return string
51
+ */
52
+ public function getTabLabel() {
53
+ return $this->__('Merchandising Pages');
54
+ }
55
+
56
+ /**
57
+ * Tab title getter
58
+ *
59
+ * @return string
60
+ */
61
+ public function getTabTitle() {
62
+ return $this->__('Merchandising Pages');
63
+ }
64
+
65
+ /**
66
+ * Check if tab can be shown
67
+ *
68
+ * @return bool
69
+ */
70
+ public function canShowTab() {
71
+ return true;
72
+ }
73
+
74
+ /**
75
+ * Check if tab hidden
76
+ *
77
+ * @return bool
78
+ */
79
+ public function isHidden() {
80
+ return false;
81
+ }
82
+
83
+ }
app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Search.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tab_Search extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ }
8
+
9
+ protected function _prepareForm() {
10
+ $this->_helper = Mage::helper('tagalys_core');
11
+
12
+ $form = Mage::getModel('varien/data_form', array(
13
+ 'id' => 'edit_form',
14
+ 'action' => $this->getUrl('*/tagalys', array('_current' => true)),
15
+ 'method' => 'post'
16
+ ));
17
+
18
+ $form->setHtmlIdPrefix('admin_tagalys_core_');
19
+ $htmlIdPrefix = $form->getHtmlIdPrefix();
20
+
21
+ $fieldset = $form->addFieldset('tagalys_search_fieldset', array('legend' => $this->__('Search')));
22
+
23
+ $search_enabled = Mage::getModel('tagalys_core/config')->getTagalysConfig("module:search:enabled");
24
+ $search_suggestions_enabled = Mage::getModel('tagalys_core/config')->getTagalysConfig('module:search_suggestions:enabled');
25
+
26
+ $fieldset->addField('enable_search', 'select', array(
27
+ 'name' => 'enable_search',
28
+ 'label' => 'Enable',
29
+ 'title' => 'Enable',
30
+ 'options' => array(
31
+ '0' => $this->__('No'),
32
+ '1' => $this->__('Yes'),
33
+ ),
34
+ 'required' => true,
35
+ 'after_element_html' => ((!$search_suggestions_enabled && !$search_enabled) ? '<small>Choosing \'Yes\' will automatically enable Search Suggestions.</small>' : ''),
36
+ 'style' => 'width:100%',
37
+ 'value' => Mage::getModel('tagalys_core/config')->getTagalysConfig("module:search:enabled")
38
+ ));
39
+
40
+ $fieldset->addField('submit', 'submit', array(
41
+ 'name' => 'tagalys_submit_action',
42
+ 'value' => 'Save Search Settings',
43
+ 'class'=> "tagalys-btn",
44
+ 'tabindex' => 1
45
+ ));
46
+
47
+ $this->setForm($form);
48
+ return parent::_prepareForm();
49
+ }
50
+
51
+ /**
52
+ * Tab label getter
53
+ *
54
+ * @return string
55
+ */
56
+ public function getTabLabel() {
57
+ return $this->__('Search');
58
+ }
59
+
60
+ /**
61
+ * Tab title getter
62
+ *
63
+ * @return string
64
+ */
65
+ public function getTabTitle() {
66
+ return $this->__('Search');
67
+ }
68
+
69
+ /**
70
+ * Check if tab can be shown
71
+ *
72
+ * @return bool
73
+ */
74
+ public function canShowTab() {
75
+ return true;
76
+ }
77
+
78
+ /**
79
+ * Check if tab hidden
80
+ *
81
+ * @return bool
82
+ */
83
+ public function isHidden() {
84
+ return false;
85
+ }
86
+
87
+ }
app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Searchsuggestions.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tab_Searchsuggestions extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ }
8
+
9
+ protected function _prepareForm() {
10
+ $this->_helper = Mage::helper('tagalys_core');
11
+
12
+ $form = Mage::getModel('varien/data_form', array(
13
+ 'id' => 'edit_form',
14
+ 'action' => $this->getUrl('*/tagalys', array('_current' => true)),
15
+ 'method' => 'post'
16
+ ));
17
+
18
+ $form->setHtmlIdPrefix('admin_tagalys_core_');
19
+ $htmlIdPrefix = $form->getHtmlIdPrefix();
20
+
21
+ $fieldset = $form->addFieldset('tagalys_searchsuggestions_fieldset', array('legend' => $this->__('Search Suggestions')));
22
+
23
+ $search_enabled = Mage::getModel('tagalys_core/config')->getTagalysConfig('module:search:enabled');
24
+
25
+ $fieldset->addField('enable_searchsuggestions', 'select', array(
26
+ 'name' => 'enable_searchsuggestions',
27
+ 'label' => 'Enable',
28
+ 'title' => 'Enable',
29
+ 'options' => array(
30
+ '0' => $this->__('No'),
31
+ '1' => $this->__('Yes'),
32
+ ),
33
+ 'required' => true,
34
+ 'disabled' => $search_enabled,
35
+ 'after_element_html' => ($search_enabled ? '<small>Required for Search</small>' : ''),
36
+ 'style' => 'width:100%',
37
+ 'value' => Mage::getModel('tagalys_core/config')->getTagalysConfig("module:search_suggestions:enabled")
38
+ ));
39
+
40
+ if (!$search_enabled) {
41
+ $fieldset->addField('submit', 'submit', array(
42
+ 'name' => 'tagalys_submit_action',
43
+ 'value' => 'Save Search Suggestions Settings',
44
+ 'class'=> "tagalys-btn",
45
+ 'tabindex' => 1
46
+ ));
47
+ }
48
+
49
+ $this->setForm($form);
50
+ return parent::_prepareForm();
51
+ }
52
+
53
+ /**
54
+ * Tab label getter
55
+ *
56
+ * @return string
57
+ */
58
+ public function getTabLabel() {
59
+ return $this->__('Search Suggestions');
60
+ }
61
+
62
+ /**
63
+ * Tab title getter
64
+ *
65
+ * @return string
66
+ */
67
+ public function getTabTitle() {
68
+ return $this->__('Search Suggestions');
69
+ }
70
+
71
+ /**
72
+ * Check if tab can be shown
73
+ *
74
+ * @return bool
75
+ */
76
+ public function canShowTab() {
77
+ return true;
78
+ }
79
+
80
+ /**
81
+ * Check if tab hidden
82
+ *
83
+ * @return bool
84
+ */
85
+ public function isHidden() {
86
+ return false;
87
+ }
88
+
89
+ }
app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Support.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tab_Support extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ }
8
+
9
+ protected function _prepareForm() {
10
+ $this->_helper = Mage::helper('tagalys_core');
11
+
12
+ $form = Mage::getModel('varien/data_form', array(
13
+ 'id' => 'edit_form',
14
+ 'action' => $this->getUrl('*/tagalys', array('_current' => true)),
15
+ 'method' => 'post'
16
+ ));
17
+
18
+ $form->setHtmlIdPrefix('admin_tagalys_core_');
19
+ $htmlIdPrefix = $form->getHtmlIdPrefix();
20
+
21
+ $tagalys_support_fieldset = $form->addFieldset('tagalys_support_fieldset', array('legend' => $this->__('Support')));
22
+
23
+ $tagalys_support_fieldset->addField('support_email', 'note', array(
24
+ 'label' => $this->__('Email'),
25
+ 'text' => '<a href="mailto:cs@tagalys.com">cs@tagalys.com</a>',
26
+ ));
27
+
28
+ $tagalys_support_fieldset->addField('support_home', 'note', array(
29
+ 'label' => $this->__('Documentation & FAQs'),
30
+ 'text' => '<a href="http://support.tagalys.com" target="_blank">http://support.tagalys.com</a>',
31
+ ));
32
+
33
+ $tagalys_support_fieldset->addField('support_ticket', 'note', array(
34
+ 'label' => $this->__('Support Tickets'),
35
+ 'text' => '<a href="http://support.tagalys.com/support/tickets/new" target="_blank">Submit a new Ticket</a><br><a href="http://support.tagalys.com/support/tickets" target="_blank">Check status</a>',
36
+ ));
37
+
38
+ $troubleshooting_info_fieldset = $form->addFieldset("troubleshooting_info_fieldset", array('legend' => $this->__("Troubleshooting Info")));
39
+
40
+ $info = array('config' => array(), 'files_in_media_folder' => array());
41
+ $config_collection = Mage::getResourceModel('tagalys_core/config_collection');
42
+ foreach($config_collection as $i) {
43
+ $info['config'][$i->getData('path')] = $i->getData('value');
44
+ }
45
+ $media_directory = Mage::getBaseDir('media'). DS .'tagalys';
46
+ $files_in_media_directory = scandir($media_directory);
47
+ foreach ($files_in_media_directory as $key => $value) {
48
+ if (!is_dir($media_directory . DS . $value)) {
49
+ if (!preg_match("/^\./", $value)) {
50
+ $info['files_in_media_folder'][] = $value;
51
+ }
52
+ }
53
+ }
54
+
55
+ $troubleshooting_info_fieldset->addField('troubleshooting_info', 'textarea', array(
56
+ 'name' => 'troubleshooting_info',
57
+ 'label' => $this->__('Troubleshooting Info'),
58
+ 'readonly' => true,
59
+ 'value' => json_encode($info),
60
+ 'style' => "width:100%; height: 100px;",
61
+ 'after_element_html' => 'Please copy and send the above content to <a href="mailto:cs@tagalys.com">cs@tagalys.com</a> to help us troubleshoot issues.',
62
+ 'tabindex' => 1
63
+ ));
64
+
65
+ $setup_status = Mage::getModel('tagalys_core/config')->getTagalysConfig('setup_status');
66
+ if (in_array($setup_status, array('sync', 'completed'))) {
67
+ $tagalys_full_resync_fieldset = $form->addFieldset('tagalys_full_resync_fieldset', array('legend' => $this->__('Full Products Resync')));
68
+
69
+ $tagalys_full_resync_fieldset->addField('note_resync', 'note', array(
70
+ 'text' => $this->__('This will trigger a full resync of your products to Tagalys. Do this only with direction from Tagalys Support. Please note that this will cause high CPU usage on your server. We recommend that you do this at low traffic hours.')
71
+ ));
72
+
73
+ $tagalys_full_resync_fieldset->addField('submit_resync', 'submit', array(
74
+ 'label' => '',
75
+ 'name' => 'tagalys_submit_action',
76
+ 'value' => 'Trigger full products resync now',
77
+ 'onclick' => 'if (this.classList.contains(\'clicked\')) { return false; } else { this.className += \' clicked\'; var that = this; setTimeout(function(){ that.value=\'Please wait…\'; that.disabled=true; }, 50); return true; }',
78
+ 'class'=> "tagalys-btn",
79
+ 'tabindex' => 1
80
+ ));
81
+
82
+ $tagalys_full_resync_fieldset->addField('note_cron', 'note', array(
83
+ 'text' => $this->__('<small><b>NOTE: Please make sure Cron is setup and running. <a target=_blank href="http://devdocs.magento.com/guides/m1x/install/installing_install.html#install-cron">Cron Documentation</a></b></small>'),
84
+ ));
85
+
86
+ $tagalys_sync_config_fieldset = $form->addFieldset('tagalys_sync_config_fieldset', array('legend' => $this->__('Configuration Resync')));
87
+
88
+ $tagalys_sync_config_fieldset->addField('note_resync_config', 'note', array(
89
+ 'text' => $this->__('This will trigger a resync of your configuration to Tagalys. Do this only with direction from Tagalys Support.')
90
+ ));
91
+
92
+ $tagalys_sync_config_fieldset->addField('submit_resync_config', 'submit', array(
93
+ 'label' => '',
94
+ 'name' => 'tagalys_submit_action',
95
+ 'value' => 'Trigger configuration resync now',
96
+ 'onclick' => 'if (this.classList.contains(\'clicked\')) { return false; } else { this.className += \' clicked\'; var that = this; setTimeout(function(){ that.value=\'Please wait…\'; that.disabled=true; }, 50); return true; }',
97
+ 'class'=> "tagalys-btn",
98
+ 'tabindex' => 1
99
+ ));
100
+ }
101
+
102
+ $tagalys_restart_setup_fieldset = $form->addFieldset('tagalys_restart_setup_fieldset', array('legend' => $this->__('Restart Tagalys Setup')));
103
+
104
+ $tagalys_restart_setup_fieldset->addField('note_restart_setup', 'note', array(
105
+ 'text' => $this->__('<span class="error"><b>Caution:</b> This will disable Tagalys features and remove all Tagalys configuration from your Magento installation. To continue using Tagalys, you\'ll have to configure and sync products again. There is no undo.</span>')
106
+ ));
107
+
108
+ $tagalys_restart_setup_fieldset->addField('submit_restart_setup', 'submit', array(
109
+ 'label' => '',
110
+ 'name' => 'tagalys_submit_action',
111
+ 'value' => 'Restart Tagalys Setup',
112
+ 'onclick' => 'if (confirm(\'Are you sure? This will disable Tagalys from your installation and you will have to start over. There is no undo.\')) { if (this.classList.contains(\'clicked\')) { return false; } else { this.className += \' clicked\'; var that = this; setTimeout(function(){ that.value=\'Please wait…\'; that.disabled=true; }, 50); return true; } } else { return false; }',
113
+ 'class'=> "tagalys-btn",
114
+ 'tabindex' => 1
115
+ ));
116
+
117
+ $this->setForm($form);
118
+ return parent::_prepareForm();
119
+ }
120
+
121
+ /**
122
+ * Tab label getter
123
+ *
124
+ * @return string
125
+ */
126
+ public function getTabLabel() {
127
+ return $this->__('Support & Troubleshooting');
128
+ }
129
+
130
+ /**
131
+ * Tab title getter
132
+ *
133
+ * @return string
134
+ */
135
+ public function getTabTitle() {
136
+ return $this->__('Support & Troubleshooting');
137
+ }
138
+
139
+ /**
140
+ * Check if tab can be shown
141
+ *
142
+ * @return bool
143
+ */
144
+ public function canShowTab() {
145
+ return true;
146
+ }
147
+
148
+ /**
149
+ * Check if tab hidden
150
+ *
151
+ * @return bool
152
+ */
153
+ public function isHidden() {
154
+ return false;
155
+ }
156
+
157
+ }
app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Sync.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tab_Sync extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ }
8
+
9
+ protected function _prepareForm() {
10
+ $form = Mage::getModel('varien/data_form', array(
11
+ 'id' => 'edit_form',
12
+ 'action' => $this->getUrl('*/tagalys', array('_current' => true)),
13
+ 'method' => 'post'
14
+ ));
15
+
16
+ $form->setHtmlIdPrefix('admin_tagalys_core_');
17
+ $htmlIdPrefix = $form->getHtmlIdPrefix();
18
+
19
+ $setup_status = Mage::getModel('tagalys_core/config')->getTagalysConfig('setup_status');
20
+ $setup_complete = ($setup_status == 'completed');
21
+ if ($setup_complete == false) {
22
+ $init_email = $form->addFieldset('tagalys_email_fieldset', array(
23
+ 'style' => "width:100%",
24
+ ));
25
+ $init_email->addField('email_note', 'note', array(
26
+ 'after_element_html' =>'<b>You can close this screen now. Once setup is complete for all selected stores, you will be notified by email and Tagalys features will be enabled automatically.<br><br>If you have any issues, please <a href="mailto:cs@tagalys.com">email us</a></b>'
27
+ ));
28
+ }
29
+
30
+ foreach (Mage::helper('tagalys_core')->getStoresForTagalys() as $key => $store_id) {
31
+ $store_sync_fieldset = $form->addFieldset("store_{$store_id}_fieldset", array('legend' => $this->__("Store: " . Mage::getModel('core/store')->load($store_id)->getName())));
32
+ $store_setup_complete = Mage::getModel('tagalys_core/config')->getTagalysConfig("store:$store_id:setup_complete");
33
+ $store_sync_fieldset->addField("store_{$store_id}_setup_complete", 'note', array(
34
+ 'label' => 'Setup complete',
35
+ 'text' => (($store_setup_complete == '1') ? 'Yes' : 'No')
36
+ ));
37
+ $store_feed_status = Mage::getModel('tagalys_core/config')->getTagalysConfig("store:$store_id:feed_status", true);
38
+ if ($store_feed_status != null) {
39
+ $status_for_client = '';
40
+ switch($store_feed_status['status']) {
41
+ case 'pending':
42
+ $status_for_client = 'Waiting for Cron';
43
+ break;
44
+ case 'processing':
45
+ $status_for_client = 'Processing';
46
+ break;
47
+ case 'generated_file':
48
+ $status_for_client = 'Generated file. Sending to Tagalys.';
49
+ break;
50
+ case 'sent_to_tagalys':
51
+ $status_for_client = 'Waiting for Tagalys';
52
+ break;
53
+ case 'finished':
54
+ $status_for_client = 'Finished';
55
+ break;
56
+ }
57
+ $store_resync_required = Mage::getModel('tagalys_core/config')->getTagalysConfig("store:$store_id:resync_required");
58
+ if ($store_resync_required == '1' && $status_for_client == 'Finished') {
59
+ $status_for_client = 'Scheduled';
60
+ }
61
+ if ($status_for_client == 'Waiting for Cron' && $store_feed_status['completed_count'] > 0) {
62
+ $status_for_client = 'In progress. Waiting for Cron.';
63
+ }
64
+ $store_sync_fieldset->addField("store_{$store_id}_feed_status", 'note', array(
65
+ 'label' => 'Feed status',
66
+ 'text' => $status_for_client
67
+ ));
68
+ $updated_at = new DateTime((string)$store_feed_status['updated_at']);
69
+ $updated_at->setTimeZone(new DateTimeZone(Mage::getStoreConfig('general/locale/timezone')));
70
+ $store_sync_fieldset->addField("store_{$store_id}_feed_updated_at", 'note', array(
71
+ 'label' => 'Feed status last changed at',
72
+ 'text' => $updated_at->format("F j, Y, g:i a")
73
+ ));
74
+ }
75
+ if ($store_setup_complete == '1') {
76
+ $store_updates_status = Mage::getModel('tagalys_core/config')->getTagalysConfig("store:$store_id:updates_status", true);
77
+ $remaining_updates = Mage::getModel('tagalys_core/queue')->getCollection()->count();
78
+ if ($store_updates_status != null) {
79
+ $status_for_client = '';
80
+ switch($store_updates_status['status']) {
81
+ case 'pending':
82
+ $status_for_client = 'Waiting for Cron';
83
+ break;
84
+ case 'processing':
85
+ $status_for_client = 'Processing';
86
+ break;
87
+ case 'generated_file':
88
+ $status_for_client = 'Generated file. Sending to Tagalys.';
89
+ break;
90
+ case 'sent_to_tagalys':
91
+ $status_for_client = 'Waiting for Tagalys';
92
+ break;
93
+ case 'finished':
94
+ $status_for_client = 'Finished';
95
+ break;
96
+ }
97
+ if (in_array($status_for_client, array('Finished')) && $remaining_updates > 0) {
98
+ $status_for_client = 'Waiting for Cron';
99
+ }
100
+ $store_sync_fieldset->addField("store_{$store_id}_updates_status", 'note', array(
101
+ 'label' => 'Updates status',
102
+ 'text' => $status_for_client
103
+ ));
104
+ $updated_at = new DateTime((string)$store_updates_status['updated_at']);
105
+ $updated_at->setTimeZone(new DateTimeZone(Mage::getStoreConfig('general/locale/timezone')));
106
+ $store_sync_fieldset->addField("store_{$store_id}_updates_updated_at", 'note', array(
107
+ 'label' => 'Updates status last changed at',
108
+ 'text' => $updated_at->format("F j, Y, g:i a")
109
+ ));
110
+ } else {
111
+ if ($remaining_updates == 0) {
112
+ $status_for_client = 'Finished';
113
+ } else {
114
+ $status_for_client = 'Waiting for Cron';
115
+ }
116
+ $store_sync_fieldset->addField("store_{$store_id}_updates_status", 'note', array(
117
+ 'label' => 'Updates Status',
118
+ 'text' => $status_for_client
119
+ ));
120
+ }
121
+ }
122
+ $store_sync_fieldset->addField("store_{$store_id}_refresh_status", 'note', array(
123
+ 'text' => '<a href="#" class="tagalys-btn" onclick="location.reload(); return false;">Refresh Status</a>'
124
+ ));
125
+ }
126
+
127
+ $this->setForm($form);
128
+ return parent::_prepareForm();
129
+ }
130
+
131
+ /**
132
+ * Tab label getter
133
+ *
134
+ * @return string
135
+ */
136
+ public function getTabLabel() {
137
+ return $this->__('API Credentials');
138
+ }
139
+
140
+ /**
141
+ * Tab title getter
142
+ *
143
+ * @return string
144
+ */
145
+ public function getTabTitle() {
146
+ return $this->__('API Credentials');
147
+ }
148
+
149
+ /**
150
+ * Check if tab can be shown
151
+ *
152
+ * @return bool
153
+ */
154
+ public function canShowTab() {
155
+ return true;
156
+ }
157
+
158
+ /**
159
+ * Check if tab hidden
160
+ *
161
+ * @return bool
162
+ */
163
+ public function isHidden() {
164
+ return false;
165
+ }
166
+ }
app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Syncsettings.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tab_Syncsettings extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ }
8
+
9
+ protected function _prepareForm() {
10
+ $this->_helper = Mage::helper('tagalys_core');
11
+
12
+ $form = Mage::getModel('varien/data_form', array(
13
+ 'id' => 'edit_form',
14
+ 'action' => $this->getUrl('*/tagalys', array('_current' => true)),
15
+ 'method' => 'post'
16
+ ));
17
+
18
+ $form->setHtmlIdPrefix('tagalys_admin_core_');
19
+ $htmlIdPrefix = $form->getHtmlIdPrefix();
20
+
21
+ $fieldset = $form->addFieldset('tagalys_sync_fieldset', array('legend' => $this->__('Sync Settings')));
22
+
23
+ $fieldset->addField('stores_for_tagalys', 'multiselect', array(
24
+ 'label' => $this->__('Choose stores for which you want to enable Tagalys features'),
25
+ // 'class' => 'required-entry',
26
+ // 'required' => true,
27
+ 'name' => 'stores_for_tagalys',
28
+ 'style' => "width:100%; height: 125px;",
29
+ 'onclick' => "return false;",
30
+ 'onchange' => "return false;",
31
+ 'value' => $this->_helper->getStoresForTagalys(),
32
+ 'values' => $this->_helper->getAllWebsiteStores(),
33
+ 'disabled' => false,
34
+ 'readonly' => false,
35
+ 'after_element_html' => '<small>Products and configuration for these stores will be synced to Tagalys</small>',
36
+ 'tabindex' => 1
37
+ ));
38
+
39
+ $setup_status = Mage::getModel('tagalys_core/config')->getTagalysConfig('setup_status');
40
+ if ($setup_status == 'complete') {
41
+ } else {
42
+ $fieldset->addField('note_cron', 'note', array(
43
+ 'text' => $this->__('<small><b>NOTE: Please make sure Cron is setup and running. <a target=_blank href="http://devdocs.magento.com/guides/m1x/install/installing_install.html#install-cron">Cron Documentation</a></b></small>'),
44
+ ));
45
+
46
+ $fieldset->addField('agree_start_sync', 'checkbox', array(
47
+ 'name' => 'Checkbox',
48
+ 'checked' => false,
49
+ 'onclick' => 'this.value = this.checked ? 1 : 0;',
50
+ 'disabled' => false,
51
+ 'after_element_html' => '<small>I agree to start syncing the selected stores.<br><em>We recommend you to do this at low traffic hours.</em><br><em>Please enable the checkbox to save and start syncing.</em></small>',
52
+ 'tabindex' => 1
53
+ ));
54
+
55
+ $fieldset->addField('submit', 'submit', array(
56
+ 'name' => 'tagalys_submit_action',
57
+ 'value' => 'Save & Start Sync',
58
+ 'class'=> "tagalys-btn",
59
+ 'disabled' => true,
60
+ 'style' => "width:100%",
61
+ 'onclick' => 'if(this.classList.contains(\'clicked\')) { return false; } else { this.className += \' clicked\'; var that = this; setTimeout(function(){ that.value=\'Please wait…\'; that.disabled=true; }, 50); return true; }',
62
+ 'after_element_html' => '<small><em></em></small>',
63
+ 'tabindex' => 1
64
+ ));
65
+
66
+ }
67
+
68
+ $this->setForm($form);
69
+ return parent::_prepareForm();
70
+ }
71
+
72
+
73
+ public function getTabLabel() {
74
+ return $this->__('Sync Settings');
75
+ }
76
+
77
+ /**
78
+ * Tab title getter
79
+ *
80
+ * @return string
81
+ */
82
+ public function getTabTitle() {
83
+ return $this->__('Sync Settings');
84
+ }
85
+
86
+ /**
87
+ * Check if tab can be shown
88
+ *
89
+ * @return bool
90
+ */
91
+ public function canShowTab() {
92
+ return true;
93
+ }
94
+
95
+ /**
96
+ * Check if tab hidden
97
+ *
98
+ * @return bool
99
+ */
100
+ public function isHidden() {
101
+ return false;
102
+ }
103
+ }
app/code/community/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tabs.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
4
+ public function __construct() {
5
+ parent::__construct();
6
+ $this->setId('tagalys');
7
+ $this->setDestElementId('edit_form');
8
+ $this->setTitle($this->__('Tagalys'));
9
+ $this->_helper = Mage::helper('tagalys_core');
10
+ }
11
+ protected function _beforeToHtml() {
12
+ $setup_status = Mage::getModel('tagalys_core/config')->getTagalysConfig('setup_status');
13
+ /*
14
+ api_credentials
15
+ sync_settings
16
+ sync
17
+ completed
18
+ */
19
+ if ($setup_status != 'completed') {
20
+ // go to current status tab
21
+ $this->setActiveTab($setup_status);
22
+ } else {
23
+ $tab_param = Mage::app()->getRequest()->getParam('tab', null);
24
+ if ($tab_param != null) {
25
+ $this->setActiveTab($tab_param);
26
+ }
27
+ }
28
+
29
+ return parent::_beforeToHtml();
30
+ }
31
+ /**
32
+ * Preparing global layout
33
+ *
34
+ * @return Mage_Core_Block_Abstract
35
+ */
36
+ protected function _prepareLayout() {
37
+ $setup_status = Mage::getModel('tagalys_core/config')->getTagalysConfig('setup_status');
38
+ $setup_complete = ($setup_status == 'completed');
39
+ $this->addTab('api_credentials', array(
40
+ 'label' => $setup_complete ? $this->__('Dashboard & API Credentials') : $this->__('Step 1: API Credentials'),
41
+ 'content' => $this->getLayout()->createBlock('tagalys_core/adminhtml_tagalys_edit_tab_apicredentials')->toHtml(),
42
+ ));
43
+
44
+ if (in_array($setup_status, array('sync_settings', 'sync', 'completed'))) {
45
+ $this->addTab('sync_settings', array(
46
+ 'label' => $setup_complete ? $this->__('Sync Settings') : $this->__('Step 2: Sync Settings'),
47
+ 'content' => $this->getLayout()->createBlock('tagalys_core/adminhtml_tagalys_edit_tab_syncsettings')->toHtml(),
48
+ ));
49
+ }
50
+
51
+ if (in_array($setup_status, array('sync', 'completed'))) {
52
+ $this->addTab('sync', array(
53
+ 'label' => $setup_complete ? $this->__('Sync Status') : $this->__('Step 3: Sync Status'),
54
+ 'content' => $this->getLayout()->createBlock('tagalys_core/adminhtml_tagalys_edit_tab_sync')->toHtml(),
55
+ ));
56
+ }
57
+
58
+ if ($setup_status == 'completed') {
59
+ $this->addTab('search_suggestions', array(
60
+ 'label' => 'Search Suggestions',
61
+ 'content' => $this->getLayout()->createBlock('tagalys_core/adminhtml_tagalys_edit_tab_searchsuggestions')->toHtml(),
62
+ ));
63
+ $this->addTab('search', array(
64
+ 'label' => 'Search',
65
+ 'content' => $this->getLayout()->createBlock('tagalys_core/adminhtml_tagalys_edit_tab_search')->toHtml(),
66
+ ));
67
+ $this->addTab('mpages', array(
68
+ 'label' => 'Merchandising Pages',
69
+ 'content' => $this->getLayout()->createBlock('tagalys_core/adminhtml_tagalys_edit_tab_mpages')->toHtml(),
70
+ ));
71
+ }
72
+
73
+ $this->addTab('support', array(
74
+ 'label' => $this->__('Support & Troubleshooting'),
75
+ 'content' => $this->getLayout()->createBlock('tagalys_core/adminhtml_tagalys_edit_tab_support')->toHtml(),
76
+ ));
77
+ }
78
+ }
app/code/community/Tagalys/Core/Helper/Data.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tagalys_Core_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+ public function isTagalysModuleEnabled($module) {
6
+ $store_id = Mage::app()->getStore()->getId();
7
+ $setup_status = Mage::getModel('tagalys_core/config')->getTagalysConfig('setup_status');
8
+ if ($setup_status == 'completed') {
9
+ $store_setup_completed = Mage::getModel('tagalys_core/config')->getTagalysConfig("store:$store_id:setup_complete");
10
+ if ($store_setup_completed == '1') {
11
+ $module_enabled = Mage::getModel('tagalys_core/config')->getTagalysConfig("module:$module:enabled");
12
+ if ($module_enabled == '1') {
13
+ return true;
14
+ }
15
+ }
16
+ }
17
+ return false;
18
+ }
19
+
20
+ public function getProductCategories($id) {
21
+ $clist = "";
22
+ $temp = array();
23
+ $productObj = Mage::getModel('catalog/product')->load($id);
24
+ $categoryIds = $productObj->getCategoryIds();
25
+ $catId = array();
26
+ foreach ($categoryIds as $key => $value) {
27
+ $category = Mage::getModel('catalog/category')->load($value);
28
+ if ($category->getIsActive()) {
29
+ $catId[] = $value;
30
+ }
31
+ }
32
+ foreach ($catId as $key => $value) {
33
+ $m = Mage::getModel('catalog/category')
34
+ ->load($value)
35
+ ->getParentCategory();
36
+
37
+ $tempval = explode("1/2",$m->getPath());
38
+ if (!empty($tempval[1])) {
39
+ $path = $tempval[1]."/".$value;
40
+ $category = explode("/", $path);
41
+ foreach ($category as $category_id) {
42
+ $categoryList = array();
43
+ if ($category_id != 1 && $category_id != 2) {
44
+ $_cat = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($category_id);
45
+ $sub_categories = array("id" => $_cat->getId() , "label" => $_cat->getName());
46
+ $categoryList[] = array("id" => $m->getId() , "label" => $m->getName(), "items" => array($sub_categories));
47
+ }
48
+ }
49
+ $temp[] = $categoryList[0];
50
+ }
51
+ }
52
+ return $temp;
53
+ }
54
+ public function getStoresForTagalys() {
55
+ $config_stores = Mage::getModel('tagalys_core/config')->getTagalysConfig("stores");
56
+
57
+ if ($config_stores) {
58
+ $stores_for_tagalys = json_decode($config_stores, true);
59
+ return $stores_for_tagalys;
60
+ }
61
+ return array();
62
+ }
63
+ public function getAllWebsiteStores() {
64
+ foreach (Mage::app()->getWebsites() as $website) {
65
+ foreach ($website->getGroups() as $group) {
66
+ $stores = $group->getStores();
67
+ foreach ($stores as $store) {
68
+ $website_stores[] = array("value" => $store->getId(), "label" => $website->getName()." / ".$group->getName(). " / ".$store->getName());
69
+ }
70
+ }
71
+ }
72
+ return $website_stores;
73
+ }
74
+
75
+ }
app/code/community/Tagalys/Core/Helper/Service.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagalys_Core_Helper_Service extends Mage_Core_Helper_Abstract {
3
+ protected $_storeId;
4
+
5
+ public function getProductPayload($product_id, $store_id, $admin = false) {
6
+ $core_helper = Mage::helper('tagalys_core');
7
+ $details_model = Mage::getModel("tagalys_core/productDetails");
8
+
9
+ $product_data = new stdClass();
10
+ $utc_now = new DateTime("now", new DateTimeZone('UTC'));
11
+ $time_now = $utc_now->format(DateTime::ATOM);
12
+ $attr_data = array();
13
+ $attributes = $details_model->getProductAttributes($product_id, $store_id, array_keys((array) $product_data));
14
+ $product_data = $details_model->getProductFields($product_id, $store_id);
15
+ $product_data->synced_at = $time_now;
16
+ $product_data->__tags = $attributes;
17
+
18
+ return $product_data;
19
+ }
20
+
21
+ public function syncClientConfiguration($stores = false) {
22
+ $api_client = Mage::getSingleton('tagalys_core/client');
23
+ $client_config = $this->getClientConfiguration($stores);
24
+
25
+ $tagalys_response = $api_client->clientApiCall('/v1/configuration', $client_config);
26
+
27
+ if ($tagalys_response === false) {
28
+ return false;
29
+ }
30
+
31
+ if ($tagalys_response['result'] == true) {
32
+ if (!empty($tagalys_response['product_sync_required'])) {
33
+ foreach ($tagalys_response['product_sync_required'] as $store_id => $required) {
34
+ Mage::getModel('tagalys_core/config')->setTagalysConfig("store:{$store_id}:resync_required", (int)$required);
35
+ }
36
+ }
37
+ }
38
+
39
+ return $tagalys_response;
40
+ }
41
+
42
+ public function getClientConfiguration($stores = false) {
43
+ if ($stores == false) {
44
+ $stores = Mage::helper("tagalys_core")->getStoresForTagalys();
45
+ }
46
+ if (empty($stores)) {
47
+ return false;
48
+ }
49
+ $client_configuration = array('stores' => array());
50
+ foreach ($stores as $index => $store_id) {
51
+ $locale = Mage::getStoreConfig('general/locale/code', $store_id);
52
+ $tag_sets_and_custom_fields = $this->getTagSetsAndCustomFields($store_id);
53
+ $client_configuration['stores'][] = array(
54
+ 'id' => $store_id,
55
+ 'label' => Mage::getModel('core/store')->load($store_id)->getName(),
56
+ 'locale' => $locale,
57
+ 'multi_currency_mode' => 'exchange_rate',
58
+ 'currencies' => $this->getCurrencies($store_id),
59
+ 'fields' => $tag_sets_and_custom_fields['custom_fields'],
60
+ 'tag_sets' => $tag_sets_and_custom_fields['tag_sets'],
61
+ 'sort_options' => $this->getSortOptions(),
62
+ 'timezone' => Mage::getStoreConfig('general/locale/timezone', $store_id),
63
+ 'products_count' => Mage::helper('tagalys_core/SyncFile')->getFeedCount($store_id, true)
64
+ );
65
+ }
66
+ return $client_configuration;
67
+ }
68
+
69
+ public function getTagSetsAndCustomFields($store_id) {
70
+ $tagalys_core_fields = array("__id", "name", "sku", "link", "sale_price", "image_url", "introduced_at", "in_stock");
71
+ $attributes = Mage::getResourceModel('catalog/product_attribute_collection')->getItems();
72
+ $tag_sets = array();
73
+ $tag_sets[] = array("id" =>"__categories", "label" => "Categories", "filters" => true, "search" => true);
74
+ $custom_fields = array();
75
+ $magento_tagalys_type_mapping = array(
76
+ 'text' => 'string',
77
+ 'textarea' => 'string',
78
+ 'date' => 'datetime',
79
+ 'boolean' => 'boolean',
80
+ 'multiselect' => 'string',
81
+ 'select' => 'string',
82
+ 'price' => 'float'
83
+ );
84
+ foreach ($attributes as $attribute){
85
+ if ($attribute->getIsFilterable() || $attribute->getIsSearchable()) {
86
+ if ($attribute->getFrontendInput() == "select" || $attribute->getFrontendInput() == "multiselect") {
87
+ $tag_sets[] = array(
88
+ 'id' => $attribute->getAttributecode(),
89
+ 'label' => $attribute->getStoreLabel($store_id),
90
+ 'filters' => (bool)$attribute->getIsFilterable(),
91
+ 'search' => (bool)$attribute->getIsSearchable()
92
+ );
93
+ } else if (!in_array($attribute->getAttributecode(), $tagalys_core_fields)) {
94
+ // custom field
95
+ $is_price_field = ($attribute->getFrontendInput() == "price" );
96
+ if (array_key_exists($attribute->getFrontendInput(), $magento_tagalys_type_mapping)) {
97
+ $type = $magento_tagalys_type_mapping[$attribute->getFrontendInput()];
98
+ } else {
99
+ $type = 'string';
100
+ }
101
+ $custom_fields[] = array(
102
+ 'name' => $attribute->getAttributecode(),
103
+ 'label' => $attribute->getStoreLabel($store_id),
104
+ 'type' => $type,
105
+ 'currency' => $is_price_field,
106
+ 'display' => $is_price_field,
107
+ 'filters' => (bool)$attribute->getIsFilterable(),
108
+ 'search' => (bool)$attribute->getIsSearchable()
109
+ );
110
+ }
111
+ }
112
+ }
113
+ return compact('tag_sets', 'custom_fields');
114
+ }
115
+
116
+ public function getCurrencies($store_id) {
117
+ $currencies = array();
118
+ $codes = Mage::app()->getStore($store_id)->getAvailableCurrencyCodes();
119
+ $rates = Mage::getModel('directory/currency')->getCurrencyRates(
120
+ Mage::app()->getStore($store_id)->getBaseCurrency(),
121
+ $codes
122
+ );
123
+ $baseCurrencyCode = Mage::app()->getStore($store_id)->getBaseCurrencyCode();
124
+ if (empty($rates[$baseCurrencyCode])) {
125
+ $rates[$baseCurrencyCode] = array($baseCurrencyCode => '1.0000');
126
+ }
127
+ foreach ($codes as $code) {
128
+ if (isset($rates[$code])) {
129
+ $defaultCurrency = ($baseCurrencyCode == $code ? true : false);
130
+ $label = Mage::app()->getLocale()->currency($code)->getSymbol();
131
+ if (empty($label)) {
132
+ $label = $code;
133
+ }
134
+ $currencies[] = array(
135
+ 'id' => $code,
136
+ 'label' => $label,
137
+ 'exchange_rate' => $rates[$code],
138
+ 'rounding_mode' => 'round',
139
+ 'fractional_digits' => 2,
140
+ 'default' => $defaultCurrency
141
+ );
142
+ }
143
+ }
144
+ return $currencies;
145
+ }
146
+
147
+ public function getSortOptions() {
148
+ $sort_options = array();
149
+ foreach (Mage::getResourceModel('catalog/config')->getAttributesUsedForSortBy() as $key => $value) {
150
+ $sort_options[] = array(
151
+ 'field' => $value["attribute_code"],
152
+ 'label' => $value["store_label"]
153
+ );
154
+ }
155
+ return $sort_options;
156
+ }
157
+ }
app/code/community/Tagalys/Core/Helper/SyncFile.php ADDED
@@ -0,0 +1,461 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ statuses:
4
+ pending
5
+ processing
6
+ generated_file
7
+ sent_to_tagalys
8
+ finished
9
+ */
10
+
11
+ class Tagalys_Core_Helper_SyncFile extends Varien_Io_File {
12
+ private $_sync_files_folder_with_path;
13
+ private $_sync_files_path;
14
+
15
+ public function __construct() {
16
+ $this->_sync_files_folder_with_path = Mage::getBaseDir('media'). DS .'tagalys';
17
+ $this->checkAndCreateFolder($this->_sync_files_folder_with_path);
18
+ $this->_sync_files_path = $this->_sync_files_folder_with_path . DS;
19
+ $this->per_page = 100;
20
+ $this->cron_instance_max_products = 1000;
21
+ // parent::__construct();
22
+ }
23
+
24
+ public function triggerFeedForStore($store_id) {
25
+ $feed_status = Mage::getModel('tagalys_core/config')->getTagalysConfig("store:$store_id:feed_status", true);
26
+ if ($feed_status == NULL || in_array($feed_status['status'], array('finished'))) {
27
+ $utc_now = new DateTime("now", new DateTimeZone('UTC'));
28
+ $time_now = $utc_now->format(DateTime::ATOM);
29
+ $products_count = $this->getFeedCount($store_id);
30
+ $feed_status = Mage::getModel('tagalys_core/config')->setTagalysConfig("store:$store_id:feed_status", json_encode(array(
31
+ 'status' => 'pending',
32
+ 'filename' => $this->_getNewSyncFileName($store_id, 'feed'),
33
+ 'products_count' => $products_count,
34
+ 'completed_count' => 0,
35
+ 'updated_at' => $time_now,
36
+ 'triggered_at' => $time_now
37
+ )));
38
+ Mage::getModel('tagalys_core/config')->setTagalysConfig("store:$store_id:resync_required", '0');
39
+ } else {
40
+
41
+ }
42
+ }
43
+
44
+ public function resyncCron() {
45
+ $utc_now = new DateTime("now", new DateTimeZone('UTC'));
46
+ $time_now = $utc_now->format(DateTime::ATOM);
47
+ Mage::getModel('tagalys_core/config')->setTagalysConfig("heartbeat:resyncCron", $time_now);
48
+ $stores = Mage::getModel('tagalys_core/config')->getTagalysConfig("stores", true);
49
+ if ($stores != NULL) {
50
+ foreach ($stores as $i => $store_id) {
51
+ $resync_required = Mage::getModel('tagalys_core/config')->getTagalysConfig("store:$store_id:resync_required");
52
+ if ($resync_required == '1') {
53
+ $this->triggerFeedForStore($store_id);
54
+ Mage::getModel('tagalys_core/config')->setTagalysConfig("store:$store_id:resync_required", '0');
55
+ }
56
+ }
57
+ }
58
+ }
59
+
60
+ public function cron() {
61
+ $utc_now = new DateTime("now", new DateTimeZone('UTC'));
62
+ $time_now = $utc_now->format(DateTime::ATOM);
63
+ Mage::getModel('tagalys_core/config')->setTagalysConfig("heartbeat:cron", $time_now);
64
+ $stores = Mage::getModel('tagalys_core/config')->getTagalysConfig("stores", true);
65
+ if ($stores != NULL) {
66
+ $this->_checkAndSyncConfig();
67
+ // get product ids from update queue to be processed in this cron instance
68
+ $product_ids_from_updates_queue_for_cron_instance = $this->_productIdsFromUpdatesQueueForCronInstance();
69
+ // products from obervers are added to queue without any checks. so add related configurable products if necessary
70
+ foreach($product_ids_from_updates_queue_for_cron_instance as $product_id) {
71
+ Mage::getModel('tagalys_core/queue')->queuePrimaryProductIdFor($product_id);
72
+ }
73
+ $updates_performed = array();
74
+ foreach($stores as $i => $store_id) {
75
+ $updates_performed[$store_id] = $this->_cronForStore($store_id, $product_ids_from_updates_queue_for_cron_instance);
76
+ }
77
+ $updates_performed_for_all_stores = true;
78
+ foreach ($stores as $i => $store_id) {
79
+ if ($updates_performed[$store_id] == false) {
80
+ $updates_performed_for_all_stores = false;
81
+ break;
82
+ }
83
+ }
84
+ if ($updates_performed_for_all_stores) {
85
+ $this->_deleteProductIdsFromUpdatesQueueForCronInstance($product_ids_from_updates_queue_for_cron_instance);
86
+ Mage::getResourceModel('tagalys_core/queue')->truncateIfEmpty();
87
+ }
88
+ }
89
+ return true;
90
+ }
91
+
92
+ public function tagalysCallback($store_id, $filename) {
93
+ $type = null;
94
+ if (strpos($filename, '-feed-') !== false) {
95
+ $type = 'feed';
96
+ } elseif (strpos($filename, '-updates-') !== false) {
97
+ $type = 'updates';
98
+ }
99
+ $config_model = Mage::getModel('tagalys_core/config');
100
+ $sync_file_status = $config_model->getTagalysConfig("store:$store_id:{$type}_status", true);
101
+ if ($sync_file_status != null) {
102
+ if ($sync_file_status['status'] == 'sent_to_tagalys') {
103
+ if ($sync_file_status['filename'] == $filename) {
104
+ if (!unlink($this->_sync_files_path . $filename)) {
105
+ Mage::getSingleton('tagalys_core/client')->log('warn', 'Unable to delete file in tagalysCallback', array('sync_file_status' => $sync_file_status, 'filename' => $filename));
106
+ }
107
+ $sync_file_status['status'] = 'finished';
108
+ $utc_now = new DateTime("now", new DateTimeZone('UTC'));
109
+ $time_now = $utc_now->format(DateTime::ATOM);
110
+ $sync_file_status['updated_at'] = $time_now;
111
+ $config_model->setTagalysConfig("store:$store_id:{$type}_status", $sync_file_status, true);
112
+ if ($type == 'feed') {
113
+ $config_model->setTagalysConfig("store:$store_id:setup_complete", '1');
114
+ Mage::getSingleton('tagalys_core/client')->log('info', 'Feed sync completed.', array('store_id' => $store_id));
115
+ $config_model->checkStatusCompleted();
116
+ } else {
117
+ Mage::getSingleton('tagalys_core/client')->log('info', 'Updates sync completed.', array('store_id' => $store_id));
118
+ }
119
+ } else {
120
+ Mage::getSingleton('tagalys_core/client')->log('warn', 'Unexpected filename in tagalysCallback', array('sync_file_status' => $sync_file_status, 'filename' => $filename));
121
+ }
122
+ } else {
123
+ Mage::getSingleton('tagalys_core/client')->log('warn', 'Unexpected tagalysCallback trigger', array('sync_file_status' => $sync_file_status, 'filename' => $filename));
124
+ }
125
+ } else {
126
+ // TODO handle error
127
+ }
128
+ }
129
+
130
+ public function getFeedCount($store_id) {
131
+ $sync_collection = $this->_getCollection($store_id, 'feed');
132
+ $products_count = $sync_collection->count();
133
+ return $products_count;
134
+ }
135
+
136
+ public function _checkAndSyncConfig() {
137
+ $config_model = Mage::getModel('tagalys_core/config');
138
+ $config_sync_required = $config_model->getTagalysConfig('config_sync_required');
139
+ if ($config_sync_required == '1') {
140
+ Mage::helper("tagalys_core/service")->syncClientConfiguration();
141
+ $config_model->setTagalysConfig('config_sync_required', '0');
142
+ }
143
+ }
144
+
145
+ public function _getDomain() {
146
+ $base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
147
+ $base_url = rtrim($base_url, '/');
148
+ $exploded_1 = explode("://", $base_url);
149
+ $replaced_1 = str_replace("-", "__", $exploded_1[1]);
150
+ return str_replace("/", "___", $replaced_1);
151
+ }
152
+ public function _getNewSyncFileName($store_id, $type) {
153
+ $domain = $this->_getDomain();
154
+ $datetime = date("YmdHis");
155
+ return "syncfile-$domain-$store_id-$type-$datetime.jsonl";
156
+ }
157
+ public function _updateProductsCount($store_id, $type, $collection) {
158
+ $products_count = $collection->count();
159
+ $config_model = Mage::getModel('tagalys_core/config');
160
+ $sync_file_status = $config_model->getTagalysConfig("store:$store_id:{$type}_status", true);
161
+ if ($sync_file_status != NULL) {
162
+ $sync_file_status['products_count'] = $products_count;
163
+ $config_model->setTagalysConfig("store:$store_id:{$type}_status", $sync_file_status, true);
164
+ }
165
+ return $products_count;
166
+ }
167
+ public function _productIdsFromUpdatesQueueForCronInstance() {
168
+ $queue_collection = Mage::getModel('tagalys_core/queue')->getCollection()->setOrder('id', 'ASC')->setPageSize($this->cron_instance_max_products);
169
+ $product_ids_from_updates_queue_for_cron_instance = array();
170
+ foreach ($queue_collection as $i => $queue_item) {
171
+ $product_id = $queue_item->getData('product_id');
172
+ array_push($product_ids_from_updates_queue_for_cron_instance, $product_id);
173
+ }
174
+ return $product_ids_from_updates_queue_for_cron_instance;
175
+ }
176
+ public function _deleteProductIdsFromUpdatesQueueForCronInstance($product_ids_from_updates_queue_for_cron_instance) {
177
+ $collection = Mage::getModel('tagalys_core/queue')
178
+ ->getCollection()
179
+ ->addFieldToFilter('product_id', array( 'in' => $product_ids_from_updates_queue_for_cron_instance));
180
+ foreach($collection as $queue_item) {
181
+ $queue_item->delete();
182
+ }
183
+ }
184
+ public function _getCollection($store_id, $type, $product_ids_from_updates_queue_for_cron_instance = array()) {
185
+ $collection = Mage::getResourceModel('catalog/product_collection')
186
+ ->setStoreId($store_id)
187
+ ->addStoreFilter($store_id)
188
+ ->addAttributeToFilter('status', 1)
189
+ ->addAttributeToFilter('visibility', array("neq" => 1))
190
+ ->addAttributeToSelect('entity_id');
191
+ if ($type == 'updates') {
192
+ $collection = $collection->addAttributeToFilter('entity_id', array('in' => $product_ids_from_updates_queue_for_cron_instance));
193
+ }
194
+ return $collection;
195
+ }
196
+
197
+ public function _cronForStore($store_id, $product_ids_from_updates_queue_for_cron_instance) {
198
+ $updates_performed = false;
199
+ $feed_response = $this->_generateFilePart($store_id, 'feed');
200
+ $sync_file_status = $feed_response['sync_file_status'];
201
+ if (!$this->_isFeedGenerationInProgress($store_id, $sync_file_status)) {
202
+ if (count($product_ids_from_updates_queue_for_cron_instance) > 0) {
203
+ $updates_response = $this->_generateFilePart($store_id, 'updates', $product_ids_from_updates_queue_for_cron_instance);
204
+ if (isset($updates_response['updates_performed']) and $updates_response['updates_performed']) {
205
+ $updates_performed = true;
206
+ }
207
+ }
208
+ }
209
+ return $updates_performed;
210
+ }
211
+
212
+ public function _isFeedGenerationInProgress($store_id, $store_feed_status) {
213
+ if ($store_feed_status == null) {
214
+ return false;
215
+ }
216
+ if (in_array($store_feed_status['status'], array('finished'))) {
217
+ return false;
218
+ }
219
+ return true;
220
+ }
221
+
222
+ public function _checkLock($sync_file_status) {
223
+ if ($sync_file_status['locked_by'] == null) {
224
+ return true;
225
+ } else {
226
+ // some other process has claimed the thread. if a crash occours, check last updated at < 15 minutes ago and try again.
227
+ $locked_at = new DateTime($sync_file_status['updated_at']);
228
+ $now = new DateTime();
229
+ $interval_seconds = $now->getTimestamp() - $locked_at->getTimestamp();
230
+ $min_seconds_for_override = 10 * 60;
231
+ if ($interval_seconds > $min_seconds_for_override) {
232
+ Mage::getSingleton('tagalys_core/client')->log('warn', 'Overriding stale locked process', array('pid' => $sync_file_status['locked_by'], 'locked_seconds_ago' => $interval_seconds));
233
+ return true;
234
+ } else {
235
+ Mage::getSingleton('tagalys_core/client')->log('warn', 'Sync file generation locked by another process', array('pid' => $sync_file_status['locked_by'], 'locked_seconds_ago' => $interval_seconds));
236
+ return false;
237
+ }
238
+ }
239
+ }
240
+
241
+ public function _reinitializeUpdatesConfig($store_id, $product_ids_from_updates_queue_for_cron_instance) {
242
+ $utc_now = new DateTime("now", new DateTimeZone('UTC'));
243
+ $time_now = $utc_now->format(DateTime::ATOM);
244
+ $updates_count = count($product_ids_from_updates_queue_for_cron_instance);
245
+ $sync_file_status = array(
246
+ 'status' => 'pending',
247
+ 'filename' => $this->_getNewSyncFileName($store_id, 'updates'),
248
+ 'products_count' => $updates_count,
249
+ 'completed_count' => 0,
250
+ 'updated_at' => $time_now,
251
+ 'triggered_at' => $time_now
252
+ );
253
+ Mage::getModel('tagalys_core/config')->setTagalysConfig("store:$store_id:updates_status", $sync_file_status, true);
254
+ return $sync_file_status;
255
+ }
256
+
257
+ public function _generateFilePart($store_id, $type, $product_ids_from_updates_queue_for_cron_instance = array()) {
258
+ $pid = Mage::helper('core')->getRandomString(24);
259
+
260
+ Mage::getSingleton('tagalys_core/client')->log('local', '1. Started _generateFilePart', array('pid' => $pid, 'store_id' => $store_id, 'type' => $type));
261
+
262
+ $updates_performed = false;
263
+ $config_model = Mage::getModel('tagalys_core/config');
264
+ $sync_file_status = $config_model->getTagalysConfig("store:$store_id:{$type}_status", true);
265
+ if ($sync_file_status == NULL) {
266
+ if ($type == 'feed') {
267
+ // if feed_status config is missing, generate it.
268
+ $this->triggerFeedForStore($store_id);
269
+ }
270
+ if ($type == 'updates') {
271
+ $this->_reinitializeUpdatesConfig($store_id, $product_ids_from_updates_queue_for_cron_instance);
272
+ }
273
+ }
274
+ $sync_file_status = $config_model->getTagalysConfig("store:$store_id:{$type}_status", true);
275
+
276
+ Mage::getSingleton('tagalys_core/client')->log('local', '2. Read / Initialized sync_file_status', array('pid' => $pid, 'store_id' => $store_id, 'type' => $type, 'sync_file_status' => $sync_file_status));
277
+
278
+ if ($sync_file_status != NULL) {
279
+ if ($type == 'updates' && in_array($sync_file_status['status'], array('finished'))) {
280
+ // if updates are finished, reset config
281
+ $this->_reinitializeUpdatesConfig($store_id, $product_ids_from_updates_queue_for_cron_instance);
282
+ $sync_file_status = $config_model->getTagalysConfig("store:$store_id:{$type}_status", true);
283
+ }
284
+
285
+ if (in_array($sync_file_status['status'], array('pending', 'processing'))) {
286
+ if ($this->_checkLock($sync_file_status) == false) {
287
+ return compact('sync_file_status');
288
+ }
289
+
290
+ Mage::getSingleton('tagalys_core/client')->log('local', '3. Unlocked', array('pid' => $pid, 'store_id' => $store_id, 'type' => $type));
291
+
292
+ $deleted_ids = array();
293
+ if ($type == 'updates') {
294
+ $collection = $this->_getCollection($store_id, $type, $product_ids_from_updates_queue_for_cron_instance);
295
+ $product_ids_in_collection = array();
296
+ $select = $collection->getSelect();
297
+ $products = $select->query();
298
+ foreach($products as $product) {
299
+ array_push($product_ids_in_collection, $product['entity_id']);
300
+ }
301
+ $deleted_ids = array_diff($product_ids_from_updates_queue_for_cron_instance, $product_ids_in_collection);
302
+ } else {
303
+ $collection = $this->_getCollection($store_id, $type);
304
+ }
305
+ $select = $collection->getSelect();
306
+
307
+ // set updated_at as this is used to check for stale processes
308
+ $utc_now = new DateTime("now", new DateTimeZone('UTC'));
309
+ $time_now = $utc_now->format(DateTime::ATOM);
310
+ $sync_file_status['updated_at'] = $time_now;
311
+ // update products count
312
+ $products_count = $this->_updateProductsCount($store_id, $type, $collection);
313
+ if ($products_count == 0 && count($deleted_ids) == 0) {
314
+ if ($type == 'feed') {
315
+ Mage::getSingleton('tagalys_core/client')->log('warn', 'No products for feed generation', array('store_id' => $store_id, 'sync_file_status' => $sync_file_status));
316
+ }
317
+ $sync_file_status['status'] = 'finished';
318
+ $config_model->setTagalysConfig("store:$store_id:{$type}_status", $sync_file_status, true);
319
+ $updates_performed = true;
320
+ return compact('sync_file_status', 'updates_performed');
321
+ } else {
322
+ $sync_file_status['locked_by'] = $pid;
323
+ // set status to processing
324
+ $sync_file_status['status'] = 'processing';
325
+ $config_model->setTagalysConfig("store:$store_id:{$type}_status", $sync_file_status, true);
326
+ }
327
+
328
+ Mage::getSingleton('tagalys_core/client')->log('local', '4. Locked with pid', array('pid' => $pid, 'store_id' => $store_id, 'type' => $type, 'sync_file_status' => $sync_file_status));
329
+
330
+ // setup file
331
+ $this->open(array('path' => $this->_sync_files_path));
332
+ $this->streamOpen($sync_file_status['filename'], 'a');
333
+
334
+ foreach($deleted_ids as $i => $deleted_id) {
335
+ $this->streamWrite(json_encode(array("perform" => "delete", "payload" => array('__id' => $deleted_id))) ."\r\n");
336
+ }
337
+
338
+ $cron_instance_completed_products = 0;
339
+
340
+ $time_start = time();
341
+ if ($products_count == 0) {
342
+ $file_generation_completed = true;
343
+ } else {
344
+ $file_generation_completed = false;
345
+
346
+ if ($type == 'feed') {
347
+ $total_remaining_products = $sync_file_status['products_count'] - $sync_file_status['completed_count'];
348
+ $cron_instance_total_products = min($total_remaining_products, $this->cron_instance_max_products);
349
+ }
350
+ if ($type == 'updates') {
351
+ $cron_instance_total_products = $products_count; // already limited to product_ids_from_updates_queue_for_cron_instance
352
+ }
353
+
354
+ // avoid infinite loops due to undetected bugs / unexpected issues
355
+ // use a circut breaker with limit of 26 (1000 products per cron instance and 50 products per page = 25. so 26 is not expected.)
356
+ $circuit_breaker = 0;
357
+ try {
358
+ while($cron_instance_completed_products < $cron_instance_total_products && $circuit_breaker < 26) {
359
+ $circuit_breaker += 1;
360
+ $products = $select->limit($this->per_page, $sync_file_status['completed_count'])->query();
361
+ foreach($products as $product) {
362
+ $product_details = (array) Mage::helper("tagalys_core/service")->getProductPayload($product['entity_id'], $store_id);
363
+ $this->streamWrite(json_encode(array("perform" => "index", "payload" => $product_details)) ."\r\n");
364
+ $sync_file_status['completed_count'] += 1;
365
+ $cron_instance_completed_products += 1;
366
+ $utc_now = new DateTime("now", new DateTimeZone('UTC'));
367
+ $time_now = $utc_now->format(DateTime::ATOM);
368
+ $sync_file_status['updated_at'] = $time_now;
369
+ $config_model->setTagalysConfig("store:$store_id:{$type}_status", $sync_file_status, true);
370
+ }
371
+ }
372
+ $time_end = time();
373
+ } catch (Exception $e) {
374
+ Mage::getSingleton('tagalys_core/client')->log('error', 'Exception in generateFilePart', array('store_id' => $store_id, 'sync_file_status' => $sync_file_status));
375
+ }
376
+ if ($type == 'feed') {
377
+ $total_remaining_products = $sync_file_status['products_count'] - $sync_file_status['completed_count'];
378
+ // $circuit_breaker of 26 is not expected unless we're counting wrong. in that case, complete
379
+ if ($total_remaining_products <= 0 || $circuit_breaker >= 26) {
380
+ $file_generation_completed = true;
381
+ if ($circuit_breaker >= 26) {
382
+ Mage::getSingleton('tagalys_core/client')->log('error', 'Circuit breaker triggered. Sync file marked as completed.', array('pid' => $pid, 'store_id' => $store_id, 'sync_file_status' => $sync_file_status));
383
+ }
384
+ }
385
+ }
386
+ if ($type == 'updates') {
387
+ $file_generation_completed = true; // updates are sent at every cron instance even if queue is larger
388
+ }
389
+ }
390
+ $updates_performed = true;
391
+ // close file outside of try/catch
392
+ $this->streamClose();
393
+ // remove lock
394
+ $sync_file_status['locked_by'] = null;
395
+ $utc_now = new DateTime("now", new DateTimeZone('UTC'));
396
+ $time_now = $utc_now->format(DateTime::ATOM);
397
+ $sync_file_status['updated_at'] = $time_now;
398
+ $time_end = time();
399
+ $time_elapsed = $time_end - $time_start;
400
+ if ($file_generation_completed) {
401
+ $sync_file_status['status'] = 'generated_file';
402
+ $sync_file_status['completed_count'] += count($deleted_ids);
403
+ Mage::getSingleton('tagalys_core/client')->log('info', 'Completed writing ' . $sync_file_status['completed_count'] . ' products to '. $type .' file. Last batch of ' . $cron_instance_completed_products . ' took ' . $time_elapsed . ' seconds.', array('store_id' => $store_id, 'sync_file_status' => $sync_file_status));
404
+ } else {
405
+ Mage::getSingleton('tagalys_core/client')->log('info', 'Written ' . $sync_file_status['completed_count'] . ' out of ' . $sync_file_status['products_count'] . ' products to '. $type .' file. Last batch of ' . $cron_instance_completed_products . ' took ' . $time_elapsed . ' seconds', array('store_id' => $store_id, 'sync_file_status' => $sync_file_status));
406
+ $sync_file_status['status'] = 'pending';
407
+ }
408
+ $config_model->setTagalysConfig("store:$store_id:{$type}_status", $sync_file_status, true);
409
+ Mage::getSingleton('tagalys_core/client')->log('local', '5. Removed lock', array('pid' => $pid, 'store_id' => $store_id, 'type' => $type, 'sync_file_status' => $sync_file_status));
410
+ if ($file_generation_completed) {
411
+ $this->_sendFileToTagalys($store_id, $type, $sync_file_status);
412
+ }
413
+ } elseif (in_array($sync_file_status['status'], array('generated_file'))) {
414
+ $this->_sendFileToTagalys($store_id, $type, $sync_file_status);
415
+ }
416
+ } else {
417
+ Mage::getSingleton('tagalys_core/client')->log('error', 'Unexpected error in generateFilePart. sync_file_status is NULL', array('store_id' => $store_id));
418
+ }
419
+ return compact('sync_file_status', 'updates_performed');
420
+ }
421
+
422
+ public function _sendFileToTagalys($store_id, $type, $sync_file_status = null) {
423
+ if ($sync_file_status == null) {
424
+ $config_model = Mage::getModel('tagalys_core/config');
425
+ $sync_file_status = $config_model->getTagalysConfig("store:$store_id:{$type}_status", true);
426
+ }
427
+
428
+ if (in_array($sync_file_status['status'], array('generated_file'))) {
429
+ $api_client = Mage::getSingleton("tagalys_core/client");
430
+
431
+ $baseUrl = '';
432
+ $webUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
433
+ $mediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
434
+ if (strpos($mediaUrl, $webUrl) === false) {
435
+ // media url different from website url - probably a CDN. use website url to link to the file we create
436
+ $baseUrl = $webUrl . 'media/';
437
+ } else {
438
+ $baseUrl = $mediaUrl;
439
+ }
440
+ $link_to_file = $baseUrl . "tagalys/" . $sync_file_status['filename'];
441
+
442
+ $config_model = Mage::getModel('tagalys_core/config');
443
+ $sync_file_status = $config_model->getTagalysConfig("store:$store_id:{$type}_status", true);
444
+ $data = array(
445
+ 'link' => $link_to_file,
446
+ 'updates_count' => $sync_file_status['products_count'],
447
+ 'store' => $store_id,
448
+ 'callback_url' => Mage::getUrl('tagalys/syncfiles/callback/')
449
+ );
450
+ $response = $api_client->storeApiCall($store_id, "/v1/products/sync_$type", $data);
451
+ if ($response != false && $response['result']) {
452
+ $sync_file_status['status'] = 'sent_to_tagalys';
453
+ $config_model->setTagalysConfig("store:$store_id:{$type}_status", $sync_file_status, true);
454
+ } else {
455
+ Mage::getSingleton('tagalys_core/client')->log('error', 'Unexpected response in _sendFileToTagalys', array('store_id' => $store_id, 'sync_file_status' => $sync_file_status, 'response' => $response));
456
+ }
457
+ } else {
458
+ Mage::getSingleton('tagalys_core/client')->log('error', 'Error: Called _sendFileToTagalys with sync_file_status ' . $sync_file_status['status'], array('store_id' => $store_id, 'sync_file_status' => $sync_file_status));
459
+ }
460
+ }
461
+ }
app/code/community/Tagalys/Core/Model/.DS_Store ADDED
Binary file
app/code/community/Tagalys/Core/Model/Client.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagalys_Core_Model_Client extends Mage_Core_Model_Abstract {
3
+ protected function _construct(){
4
+ $this->_api_timeout = 60;
5
+ $this->cacheApiCredentials();
6
+ }
7
+ public function cacheApiCredentials() {
8
+ try {
9
+ $api_credentials = json_decode(Mage::getModel('tagalys_core/config')->getTagalysConfig("api_credentials"), true);
10
+ $this->_api_server = $api_credentials['api_server'];
11
+ $this->_client_code = $api_credentials['client_code'];
12
+ $this->_private_api_key = $api_credentials['private_api_key'];
13
+ $this->_public_api_key = $api_credentials['public_api_key'];
14
+ } catch (Exception $e) {
15
+ $this->_api_server = false;
16
+ }
17
+ }
18
+ public function identificationCheck($api_credentials) {
19
+ try {
20
+ $this->_api_server = $api_credentials['api_server'];
21
+ $response = $this->_apiCall('/v1/identification/check', array(
22
+ 'identification' => array(
23
+ 'client_code' => $api_credentials['client_code'],
24
+ 'public_api_key' => $api_credentials['public_api_key'],
25
+ 'private_api_key' => $api_credentials['private_api_key']
26
+ )
27
+ ));
28
+ return $response;
29
+ } catch (Exception $e) {
30
+ Mage::log("Exception in Client.php identificationCheck: {$e->getMessage()}; api_credentials: " . json_encode($api_credentials), null, 'tagalys.log');
31
+ return false;
32
+ }
33
+ }
34
+ public function log($level, $message, $data = null) {
35
+ Mage::log(json_encode(compact('level', 'message', 'data')), null, 'tagalys.log');
36
+ if ($this->_api_server != false && $level != 'local') {
37
+ $log_params = array('log_level' => $level, 'log_message' => $message);
38
+ if ($data != null) {
39
+ if (array_key_exists('store_id', $data)) {
40
+ $log_params['log_store_id'] = $data['store_id'];
41
+ unset($data['store_id']);
42
+ }
43
+ $log_params['log_data'] = $data;
44
+ }
45
+ $this->clientApiCall('/v1/clients/log', $log_params);
46
+ }
47
+ }
48
+ public function clientApiCall($path, $params) {
49
+ $params['identification'] = array(
50
+ 'client_code' => $this->_client_code,
51
+ 'api_key' => $this->_private_api_key
52
+ );
53
+ return $this->_apiCall($path, $params);
54
+ }
55
+ public function storeApiCall($store_id, $path, $params) {
56
+ $params['identification'] = array(
57
+ 'client_code' => $this->_client_code,
58
+ 'api_key' => $this->_private_api_key,
59
+ 'store_id' => $store_id
60
+ );
61
+ return $this->_apiCall($path, $params);
62
+ }
63
+ private function _apiCall($path, $params) {
64
+ try {
65
+ if ($this->_api_server === false) {
66
+ Mage::log("Error in Client.php _apiCall: this->_api_server is false; path: $path; params: " . json_encode($params), null, 'tagalys.log');
67
+ return false;
68
+ }
69
+ if (array_key_exists('identification', $params)) {
70
+ $platform_version_info = Mage::getVersionInfo();
71
+ $params['identification']['api_client'] = array('platform' => 'Magento-' . Mage::getEdition() . '-' . $platform_version_info['major'], 'platform_version' => Mage::getVersion(), 'plugin' => Mage::getStoreConfig('tagalys/package/name'), 'plugin_version' => Mage::getStoreConfig('tagalys/package/version'));
72
+ }
73
+ $url = $this->_api_server . $path;
74
+ $curl_handle = curl_init($url);
75
+ $port = parse_url($url, PHP_URL_PORT);
76
+ if ($port != NULL) {
77
+ curl_setopt($curl_handle, CURLOPT_PORT, $port);
78
+ }
79
+ curl_setopt($curl_handle, CURLOPT_POST, 1);
80
+ curl_setopt($curl_handle, CURLOPT_POSTFIELDS, json_encode($params));
81
+ curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
82
+ curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
83
+ curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
84
+ curl_setopt($curl_handle, CURLOPT_TIMEOUT, $this->_api_timeout);
85
+ $response = curl_exec($curl_handle);
86
+ if (curl_errno($curl_handle)) {
87
+ $http_code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
88
+ Mage::log("Error in Client.php _apiCall: curl error ($http_code); api_server: $this->_api_server; path: $path; params: " . json_encode($params), null, 'tagalys.log');
89
+ return false;
90
+ }
91
+ if (empty($response)) {
92
+ Mage::log("Error in Client.php _apiCall: response is empty; api_server: $this->_api_server; path: $path; params: " . json_encode($params), null, 'tagalys.log');
93
+ return false;
94
+ }
95
+ curl_close($curl_handle);
96
+ $decoded = json_decode($response, true);
97
+ if ($decoded === NULL) {
98
+ Mage::log("Error in Client.php _apiCall: decoded is NULL; api_server: $this->_api_server; path: $path; params: " . json_encode($params), null, 'tagalys.log');
99
+ return false;
100
+ }
101
+ if ($decoded["status"] == "OK") {
102
+ return $decoded;
103
+ } else {
104
+ return false;
105
+ }
106
+ } catch (Exception $e) {
107
+ Mage::log("Exception in Client.php _apiCall: {$e->getMessage()}; api_server: $this->_api_server; path: $path; params: " . json_encode($params), null, 'tagalys.log');
108
+ return false;
109
+ }
110
+ }
111
+ }
app/code/community/Tagalys/Core/Model/Config.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagalys_Core_Model_Config extends Mage_Core_Model_Abstract {
3
+ public function _construct() {
4
+ parent::_construct();
5
+ $this->_init("tagalys_core/config");
6
+ }
7
+
8
+ public function checkStatusCompleted() {
9
+ $setup_status = $this->getTagalysConfig('setup_status');
10
+ if ($setup_status == 'sync') {
11
+ $store_ids = Mage::helper("tagalys_core")->getStoresForTagalys();
12
+ $all_stores_completed = true;
13
+ foreach($store_ids as $store_id) {
14
+ $store_setup_status = $this->getTagalysConfig("store:$store_id:setup_complete");
15
+ if ($store_setup_status != '1') {
16
+ $all_stores_completed = false;
17
+ break;
18
+ }
19
+ }
20
+ if ($all_stores_completed) {
21
+ $this->setTagalysConfig("setup_status", 'completed');
22
+ $package_name = Mage::getStoreConfig('tagalys/package/name');
23
+ $modules_to_activate = array();
24
+ switch($package_name) {
25
+ case 'Search Suggestions':
26
+ $modules_to_activate = array('search_suggestions');
27
+ break;
28
+ case 'Search':
29
+ $modules_to_activate = array('search_suggestions', 'search');
30
+ break;
31
+ case 'Mpages':
32
+ $modules_to_activate = array('mpages');
33
+ break;
34
+ }
35
+ Mage::getSingleton('tagalys_core/client')->log('info', 'All stores synced. Enabling Tagalys features.', array('modules_to_activate' => $modules_to_activate));
36
+ foreach($modules_to_activate as $module_to_activate) {
37
+ $this->setTagalysConfig("module:$module_to_activate:enabled", '1');
38
+ }
39
+ }
40
+ }
41
+ }
42
+
43
+ public function getTagalysConfig($config, $json_decode = false) {
44
+ $configValue = $this->getCollection()->addFieldToFilter('path',$config)->getFirstItem()->getData("value");
45
+ if ($configValue === NULL) {
46
+ $defaultConfigValues = array(
47
+ 'setup_status' => 'api_credentials'
48
+ );
49
+ if (array_key_exists($config, $defaultConfigValues)) {
50
+ $configValue = $defaultConfigValues[$config];
51
+ } else {
52
+ $configValue = NULL;
53
+ }
54
+ }
55
+ if ($configValue !== NULL && $json_decode) {
56
+ return json_decode($configValue, true);
57
+ }
58
+ return $configValue;
59
+ }
60
+
61
+ public function setTagalysConfig($config, $value, $json_encode = false) {
62
+ if ($json_encode) {
63
+ $value = json_encode($value);
64
+ }
65
+ $data = array('path' => $config, 'value' => $value);
66
+
67
+ $collection = $this->getCollection()->addFieldToFilter('path',$config)->getFirstItem();
68
+
69
+ try {
70
+ if ($id = $collection->getId()){
71
+ $model = $this->load($id)->addData($data);
72
+ $model->setId($id)->save();
73
+ } else {
74
+ $model = Mage::getModel("tagalys_core/config")->setData($data);
75
+ $insertId = $model->save()->getId();
76
+ }
77
+ } catch (Exception $e){
78
+ Mage::getSingleton('tagalys_core/client')->log('error', 'Exception in setTagalysConfig', array('exception_message' => $e->getMessage()));
79
+ }
80
+ }
81
+ }
app/code/{local/Tagalys/Tsearch → community/Tagalys/Core/Model/Mysql4}/.DS_Store RENAMED
Binary file
app/code/community/Tagalys/Core/Model/Mysql4/Config.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagalys_Core_Model_Mysql4_Config extends Mage_Core_Model_Mysql4_Abstract {
3
+ protected function _construct() {
4
+ $this->_init("tagalys_core/config", "id");
5
+ }
6
+ public function truncate() {
7
+ $this->_getWriteAdapter()->query('TRUNCATE TABLE '.$this->getMainTable());
8
+ }
9
+ }
app/code/{local → community}/Tagalys/Core/Model/Mysql4/Config/Collection.php RENAMED
@@ -1,8 +1,6 @@
1
- <?php
2
- class Tagalys_Core_Model_Mysql4_Config_collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
- {
4
- protected function _construct()
5
- {
6
- $this->_init("tagalys_core/config");
7
- }
8
  }
1
+ <?php
2
+ class Tagalys_Core_Model_Mysql4_Config_collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
3
+ protected function _construct() {
4
+ $this->_init("tagalys_core/config");
5
+ }
 
 
6
  }
app/code/community/Tagalys/Core/Model/Mysql4/Queue.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagalys_Core_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract {
3
+ protected function _construct() {
4
+ $this->_init("tagalys_core/queue", "id");
5
+ }
6
+ public function truncateIfEmpty() {
7
+ $count = Mage::getModel('tagalys_core/queue')->getCollection()->getSize();
8
+ if ($count == 0) {
9
+ $this->_getWriteAdapter()->query('TRUNCATE TABLE '.$this->getMainTable());
10
+ }
11
+ }
12
+ public function truncate() {
13
+ $this->_getWriteAdapter()->query('TRUNCATE TABLE '.$this->getMainTable());
14
+ }
15
+ }
app/code/community/Tagalys/Core/Model/Mysql4/Queue/Collection.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class Tagalys_Core_Model_Mysql4_Queue_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
3
+ public function _construct() {
4
+ $this->_init("tagalys_core/queue");
5
+ }
6
+ }
app/code/community/Tagalys/Core/Model/Observer.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagalys_Core_Model_Observer extends Varien_Object {
3
+ public function tagalys_distpatch(Varien_Event_Observer $observer) {
4
+ try {
5
+ $params = $observer->getEvent()->getControllerAction()->getRequest()->getParams();
6
+ $tagalys_config_events = array('adminhtml_catalog_product_attribute_delete','adminhtml_catalog_product_attribute_save', 'adminhtml_system_currency_saveRates','adminhtml_system_currencysymbol_save');
7
+ if (in_array ($observer->getEvent()->getControllerAction()->getFullActionName(), $tagalys_config_events)) {
8
+ // sync config
9
+ Mage::getModel('tagalys_core/config')->setTagalysConfig("config_sync_required", '1');
10
+ }
11
+ if (in_array ($observer->getEvent()->getControllerAction()->getFullActionName(), array("adminhtml_catalog_category_save"))) {
12
+ $stores = Mage::helper('tagalys_core')->getStoresForTagalys();
13
+ foreach($stores as $i => $store_id) {
14
+ Mage::helper("tagalys_core/SyncFile")->triggerFeedForStore($store_id);
15
+ }
16
+ }
17
+ if (isset($params) && isset($params['section']) && $params["section"] == "currency") {
18
+ // sync config
19
+ Mage::getModel('tagalys_core/config')->setTagalysConfig("config_sync_required", 1);
20
+ }
21
+ } catch (Exception $e) {
22
+ Mage::log("Error in tagalys_distpatch: ". $e->getMessage(), null, "tagalys.log");
23
+ }
24
+ }
25
+
26
+ public function syncCron() {
27
+ Mage::helper("tagalys_core/SyncFile")->cron();
28
+ }
29
+
30
+ public function resyncCron() {
31
+ Mage::helper("tagalys_core/SyncFile")->resyncCron();
32
+ }
33
+
34
+ // create / update / delete from admin
35
+ public function productChanged(Varien_Event_Observer $observer) {
36
+ try {
37
+ $product = $observer->getEvent()->getProduct();
38
+ $product_id = $product->getId();
39
+ Mage::getModel('tagalys_core/queue')->blindlyAddProduct($product_id);
40
+ } catch (Exception $e) {
41
+ Mage::log("Exception on productChanged: " . $e->getMessage(), null, "tagalys.log");
42
+ }
43
+ }
44
+
45
+ // csv import
46
+ public function productsImported(Varien_Event_Observer $observer) {
47
+ try {
48
+ $adapter = $observer->getEvent()->getAdapter();
49
+ $affectedEntityIds = $adapter->getAffectedEntityIds();
50
+ foreach($affectedEntityIds as $product_id) {
51
+ Mage::getModel('tagalys_core/queue')->blindlyAddProduct($product_id);
52
+ }
53
+ } catch (Exception $e) {
54
+ Mage::log("Exception on productsImported: " . $e->getMessage(), null, "tagalys.log");
55
+ }
56
+ }
57
+ }
app/code/community/Tagalys/Core/Model/ProductDetails.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagalys_Core_Model_ProductDetails extends Mage_Core_Model_Abstract {
3
+
4
+ protected $syncfield;
5
+ protected $inventorySyncField;
6
+
7
+ public function getProductFields($productId, $store = null) {
8
+ try {
9
+ $this->_storeId = $store;
10
+ $core_helper = Mage::helper('tagalys_core');
11
+ $product = Mage::getModel('catalog/product')->load($productId);
12
+ if (is_null($this->_storeId)) {
13
+ $this->_storeId = Mage::app()->getWebsite(true)->getDefaultGroup()->getDefaultStoreId();
14
+ }
15
+ Mage::app()->setCurrentStore($this->_storeId);
16
+ $productFields = new stdClass();
17
+ $productFields->__id = $product->getId();
18
+ $productFields->name = $product->getName();
19
+ $productFields->link = $product->getProductUrl();
20
+ $productFields->sku = $product->getData('sku');
21
+ $attributes = $product->getAttributes();
22
+ foreach ($attributes as $attribute) {
23
+ if ($attribute->getIsFilterable() || $attribute->getIsSearchable()) {
24
+ $attr = $product->getResource()->getAttribute($attribute->getAttributeCode());
25
+ if (!$attr->usesSource()) {
26
+ $field_val = $attribute->getFrontend()->getValue($product);
27
+ if (!is_null($field_val)) {
28
+ $productFields->{$attribute->getAttributeCode()} = $attribute->getFrontend()->getValue($product);
29
+ }
30
+ }
31
+ }
32
+ }
33
+ if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
34
+ $arr = $product->getTypeInstance(true)->getChildrenIds($product->getId(), false);
35
+ foreach($arr[key($arr)] as $k => $v) {
36
+ $price[] = Mage::getModel('catalog/product')->load($v)->getFinalPrice();
37
+ $mrp[] = Mage::getModel('catalog/product')->load($v)->getPrice();
38
+ }
39
+ $productFields->sale_price = min($price);
40
+ $productFields->price = min($mrp);
41
+ } else {
42
+ $productFields->sale_price = $product->getFinalPrice();
43
+ $productFields->price = $product->getPrice();
44
+ }
45
+
46
+ $productFields->image_url = Mage::getModel('catalog/product_media_config')->getMediaUrl( $product->getImage());
47
+ $fields = array('created_at');
48
+ foreach ($fields as $key => $name) {
49
+ $fieldValue = $product->getResource()->getAttribute($name)->getFrontend()->getValue($product);
50
+ $introduced_at = new DateTime((string)$fieldValue);
51
+ $introduced_at->setTimeZone(new DateTimeZone('UTC'));
52
+ $productFields->introduced_at = $introduced_at->format(DateTime::ATOM);
53
+ }
54
+
55
+ // $productFields->parent_id = $this->getProductParent($productId);
56
+ $productFields->in_stock = Mage::getModel('catalog/product')->load($product->getId())->isSaleable();
57
+
58
+ return $productFields;
59
+
60
+ } catch (Exception $e) {
61
+
62
+ }
63
+ }
64
+ public function getProductType($productId) {
65
+ $product = Mage::getModel('catalog/product')->load($productId);
66
+ $productType = $product->getTypeId();
67
+ return $productType;
68
+ }
69
+ public function getProductParent($productId) {
70
+ $tagalys_parent_id = array();
71
+ $product = Mage::getModel('catalog/product')->load($productId);
72
+ $parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($productId);
73
+ if (!$parentIds) {
74
+ $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($productId);
75
+ $parentProducts = Mage::getModel('catalog/product')
76
+ ->getCollection()
77
+ ->addAttributeToSelect('sku')
78
+ ->addAttributeToFilter('entity_id', array('in' => $parentIds))
79
+ ->load();
80
+ $parents = array();
81
+ foreach ($parentProducts as $key => $pro) {
82
+ array_push($parents, $pro->getId());
83
+ }
84
+ if (isset($parents[0])) {
85
+ $tagalys_parent_id = $parents;
86
+ }
87
+ }
88
+ return $tagalys_parent_id;
89
+ }
90
+ public function getProductAttributes($productId, $store_id, $unsyncFields) {
91
+ $product = Mage::getModel('catalog/product')->load($productId);
92
+ $attribute_options_id = null;
93
+ $attriute_option_value = null;
94
+ $type = $product->getTypeId();
95
+ $attributeObj = array();
96
+ $product->setStoreId($store_id);
97
+ $categories = Mage::helper('tagalys_core')->getProductCategories($productId);
98
+ $attributeObj[] = array("tag_set" => array("id" => "__categories", "label" => "Categories" ), "items" => ($categories));
99
+
100
+ $attributes = $product->getAttributes();
101
+ foreach ($attributes as $attribute) {
102
+ if ($attribute->getIsFilterable() || $attribute->getIsSearchable()) {
103
+ $product_attribute = $product->getResource()->getAttribute($attribute->getAttributeCode());
104
+ if ($product_attribute->usesSource()) {
105
+ // select, multi-select
106
+ $field_type = $product_attribute->getFrontendInput();
107
+ $items = array();
108
+ if ($field_type == 'multiselect') {
109
+ $value = $product->getData($attribute->getAttributeCode());
110
+ $ids = explode(',', $value);
111
+ foreach ($ids as $id) {
112
+ $label = $attribute->getSource()->getOptionText($id);
113
+ if ($id != null && $label != false) {
114
+ $items[] = array('id' => $id, 'label' => $label);
115
+ }
116
+ }
117
+ } else {
118
+ $value = $product->getData($attribute->getAttributeCode());
119
+ $label = $product->getResource()->getAttribute($attribute->getAttributeCode())->getFrontend()->getOption($value);
120
+ if ($value != null && $label != false) {
121
+ $items[] = array('id' => $value, 'label' => $label);
122
+ }
123
+ }
124
+ if (count($items) > 0) {
125
+ $attributeObj[] = array("tag_set" => array("id" => $attribute->getAttributeCode(), "label" => $attribute->getFrontend()->getLabel($product) ),"items" => $items);
126
+ }
127
+ }
128
+ }
129
+ }
130
+ if ($type === "configurable") {
131
+ $productTypeInstance = $product->getTypeInstance(true);
132
+ $configurable_attributes = array_map(function ($el) {
133
+ return $el['attribute_code'];
134
+ }, $productTypeInstance->getConfigurableAttributesAsArray($product));
135
+
136
+ $configurable_product = Mage::getModel('catalog/product_type_configurable')->setProduct($product);
137
+ $simple_products_collection = $configurable_product->getUsedProductCollection()->addAttributeToFilter('status', 1)->addAttributeToSelect('*')->addFilterByRequiredOptions();
138
+
139
+ foreach($configurable_attributes as $configurable_attribute) {
140
+ $attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product',$configurable_attribute);
141
+ $items = array();
142
+ foreach($simple_products_collection as $simple_product){
143
+ $items[] = array('id' => $simple_product->getData($configurable_attribute), 'label' => $simple_product->getAttributeText($configurable_attribute));
144
+ }
145
+ if (count($items) > 0) {
146
+ $attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', $configurable_attribute);
147
+ $attributeObj[] = array( "tag_set" => array("id" => $configurable_attribute, "label" => $attributeModel->getStoreLabel($store_id)), "items" => $items);
148
+ }
149
+ }
150
+ }
151
+
152
+ return ($attributeObj);
153
+ }
154
+ }
app/code/community/Tagalys/Core/Model/Queue.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tagalys_Core_Model_Queue extends Mage_Core_Model_Abstract {
4
+ protected function _construct(){
5
+ $this->_init("tagalys_core/queue");
6
+ }
7
+
8
+ public function queuePrimaryProductIdFor($product_id) {
9
+ $primary_product_id = $this->getPrimaryProductId($product_id);
10
+ if ($primary_product_id === false) {
11
+ // no related product id
12
+ } elseif ($product_id == $primary_product_id) {
13
+ // same product. so no related product id.
14
+ } else {
15
+ // add primary_product_id and remove product_id
16
+ $this->blindlyAddProduct($primary_product_id);
17
+ }
18
+ return $primary_product_id;
19
+ }
20
+
21
+ public function prune($limit = 100) {
22
+ // remove products with visibility 1 (not visible invidivually); replace with the configurable product if exists
23
+ $changed_count = 0;
24
+ $queue_collection = $this->getCollection()->setOrder('id', 'ASC')->setPageSize($limit);
25
+ foreach ($queue_collection as $i => $queue_item) {
26
+ $product_id = $queue_item->getData('product_id');
27
+ $primary_product_id = $this->queuePrimaryProductIdFor($product_id);
28
+ if ($primary_product_id == false || $product_id != $primary_product_id) {
29
+ $queue_item->delete();
30
+ }
31
+ }
32
+ if ($changed_count > 0) {
33
+ prune($limit);
34
+ }
35
+ }
36
+
37
+ public function _visibleInAnyStore($product_id) {
38
+ $visible = false;
39
+ $store_ids = Mage::helper("tagalys_core")->getStoresForTagalys();
40
+ foreach ($store_ids as $store_id) {
41
+ Mage::app()->setCurrentStore($store_id);
42
+ $product = Mage::getModel('catalog/product')->load($product_id);
43
+ $product_visibility = $product->getVisibility();
44
+ if ($product_visibility != 1) {
45
+ $visible = true;
46
+ break;
47
+ }
48
+ }
49
+ return $visible;
50
+ }
51
+
52
+ public function getPrimaryProductId($product_id) {
53
+ $product = Mage::getModel('catalog/product')->load($product_id);
54
+ if ($product) {
55
+ $product_type = $product->getTypeId();
56
+ $visible_in_any_store = $this->_visibleInAnyStore($product_id);
57
+ if (!$visible_in_any_store) {
58
+ // not visible individually
59
+ if ($product_type == 'simple') {
60
+ // coulbe be attached to configurable product
61
+ $parent_ids = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product_id);
62
+ if (count($parent_ids) > 0) {
63
+ // check and return configurable product id
64
+ return $this->getPrimaryProductId($parent_ids[0]);
65
+ }
66
+ } else {
67
+ // configurable / grouped / bundled product that is not visible individually
68
+ return false;
69
+ }
70
+ } else {
71
+ // any type of product that is visible individually. add to queue.
72
+ return $product_id;
73
+ }
74
+ } else {
75
+ // product not found. might have to delete
76
+ return $product_id;
77
+ }
78
+ }
79
+
80
+ public function blindlyAddProduct($product_id) {
81
+ $existingProduct = $this->load($product_id, 'product_id');
82
+ $id_in_queue = $existingProduct->getId();
83
+ if (empty($id_in_queue)) {
84
+ $data = array('product_id' => $product_id);
85
+ $this->setData($data);
86
+ try {
87
+ $this->save();
88
+ return true;
89
+ } catch(Exception $e) {
90
+ Mage::log("Error adding product_id $product_id to tagalys_queue.", null, "tagalys.log");
91
+ }
92
+ return false;
93
+ } else {
94
+ return false;
95
+ }
96
+ }
97
+ }
app/code/community/Tagalys/Core/controllers/.DS_Store ADDED
Binary file
app/code/community/Tagalys/Core/controllers/Adminhtml/TagalysController.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tagalys_Core_Adminhtml_TagalysController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ protected function _isAllowed() {
6
+ return true;
7
+ }
8
+
9
+ public function indexAction() {
10
+ $this->_title('Tagalys Configuration');
11
+ $this->loadLayout();
12
+ $this->_setActiveMenu('Tagalys/core');
13
+ $this->renderLayout();
14
+ }
15
+
16
+ public function saveAction() {
17
+ $params = $this->getRequest()->getParams();
18
+ if (!empty($params['tagalys_submit_action'])) {
19
+ $result = false;
20
+ $this->_helper = Mage::helper('tagalys_core');
21
+ $redirect_to_tab = null;
22
+ switch ($params['tagalys_submit_action']) {
23
+ case 'Save API Credentials':
24
+ try {
25
+ $result = $this->_saveApiCredentials($params);
26
+ if ($result !== false) {
27
+ Mage::getSingleton('tagalys_core/client')->log('info', 'Saved API credentials', array('api_credentials' => $params['api_credentials']));
28
+ $setup_status = Mage::getModel('tagalys_core/config')->getTagalysConfig('setup_status');
29
+ if ($setup_status == 'api_credentials') {
30
+ Mage::getModel('tagalys_core/config')->setTagalysConfig('setup_status', 'sync_settings');
31
+ }
32
+ }
33
+ $redirect_to_tab = 'api_credentials';
34
+ } catch (Exception $e) {
35
+ Mage::getSingleton('tagalys_core/client')->log('error', 'Error in _saveApiCredentials: ' . $e->getMessage(), array('api_credentials' => $params['api_credentials']));
36
+ Mage::getSingleton('core/session')->addError("Sorry, something went wrong while saving your API credentials. Please <a href=\"mailto:cs@tagalys.com\">email us</a> so we can resolve this issue.");
37
+ $redirect_to_tab = 'api_credentials';
38
+ }
39
+ break;
40
+ case 'Save & Start Sync':
41
+ try {
42
+ if (count($params['stores_for_tagalys']) > 0) {
43
+ Mage::getSingleton('tagalys_core/client')->log('info', 'Starting configuration sync', array('stores_for_tagalys' => $params['stores_for_tagalys']));
44
+ $result = Mage::helper("tagalys_core/service")->syncClientConfiguration($params['stores_for_tagalys']);
45
+ if ($result === false) {
46
+ Mage::getSingleton('tagalys_core/client')->log('error', 'syncClientConfiguration returned false', array('stores_for_tagalys' => $params['stores_for_tagalys']));
47
+ Mage::getSingleton('core/session')->addError("Sorry, something went wrong while saving your store's configuration. We've logged the issue and we'll get back once we know more. You can contact us here: <a href=\"mailto:cs@tagalys.com\">cs@tagalys.com</a>");
48
+ $redirect_to_tab = 'sync_settings';
49
+ } else {
50
+ Mage::getSingleton('tagalys_core/client')->log('info', 'Completed configuration sync', array('stores_for_tagalys' => $params['stores_for_tagalys']));
51
+ Mage::getModel('tagalys_core/config')->setTagalysConfig('stores', json_encode($params['stores_for_tagalys']));
52
+ foreach($params['stores_for_tagalys'] as $i => $store_id) {
53
+ Mage::helper("tagalys_core/SyncFile")->triggerFeedForStore($store_id);
54
+ }
55
+ $setup_status = Mage::getModel('tagalys_core/config')->getTagalysConfig('setup_status');
56
+ if ($setup_status == 'sync_settings') {
57
+ Mage::getModel('tagalys_core/config')->setTagalysConfig('setup_status', 'sync');
58
+ }
59
+ $redirect_to_tab = 'sync';
60
+ }
61
+ } else {
62
+ Mage::getSingleton('core/session')->addError("Please choose at least one store to continue.");
63
+ $redirect_to_tab = 'sync_settings';
64
+ }
65
+ } catch (Exception $e) {
66
+ Mage::getSingleton('tagalys_core/client')->log('error', 'Error in syncClientConfiguration: ' . $e->getMessage(), array('stores_for_tagalys' => $params['stores_for_tagalys']));
67
+ Mage::getSingleton('core/session')->addError("Sorry, something went wrong while saving your configuration. Please <a href=\"mailto:cs@tagalys.com\">email us</a> so we can resolve this issue.");
68
+ $redirect_to_tab = 'sync_settings';
69
+ }
70
+ break;
71
+ case 'Save Search Suggestions Settings':
72
+ Mage::getModel('tagalys_core/config')->setTagalysConfig('module:search_suggestions:enabled', $params['enable_searchsuggestions']);
73
+ $redirect_to_tab = 'search_suggestions';
74
+ break;
75
+ case 'Save Search Settings':
76
+ Mage::getModel('tagalys_core/config')->setTagalysConfig('module:search:enabled', $params['enable_search']);
77
+ if ($params['enable_search'] == '1') {
78
+ Mage::getModel('tagalys_core/config')->setTagalysConfig('module:search_suggestions:enabled', $params['enable_search']);
79
+ }
80
+ $redirect_to_tab = 'search';
81
+ break;
82
+ case 'Save Merchandising Pages Settings':
83
+ Mage::getModel('tagalys_core/config')->setTagalysConfig('module:mpages:enabled', $params['enable_mpages']);
84
+ $redirect_to_tab = 'mpages';
85
+ break;
86
+ case 'Trigger full products resync now':
87
+ Mage::getSingleton('tagalys_core/client')->log('warn', 'Triggering full products resync');
88
+ foreach (Mage::helper('tagalys_core')->getStoresForTagalys() as $store_id) {
89
+ Mage::helper("tagalys_core/SyncFile")->triggerFeedForStore($store_id);
90
+ }
91
+ $redirect_to_tab = 'support';
92
+ break;
93
+ case 'Trigger configuration resync now':
94
+ Mage::getSingleton('tagalys_core/client')->log('warn', 'Triggering configuration resync');
95
+ Mage::getModel('tagalys_core/config')->setTagalysConfig("config_sync_required", '1');
96
+ $redirect_to_tab = 'support';
97
+ break;
98
+ case 'Restart Tagalys Setup':
99
+ Mage::getSingleton('tagalys_core/client')->log('warn', 'Restarting Tagalys Setup');
100
+ Mage::getResourceModel('tagalys_core/queue')->truncate();
101
+ Mage::getResourceModel('tagalys_core/config')->truncate();
102
+ $redirect_to_tab = 'api_credentials';
103
+ break;
104
+ }
105
+ return $this->_redirect('*/tagalys', array('_query' => 'tab='.$redirect_to_tab));
106
+ }
107
+ }
108
+
109
+ protected function _saveApiCredentials($params) {
110
+ $tagalys_api_client = Mage::getSingleton("tagalys_core/client");
111
+ $result = $tagalys_api_client->identificationCheck(json_decode($params['api_credentials'], true));
112
+ if ($result['result'] != 1) {
113
+ Mage::getSingleton('core/session')->addError("Invalid API Credentials. Please try again. If you continue having issues, please email us <a href=\"mailto:cs@tagalys.com\">email us</a>.");
114
+ return false;
115
+ }
116
+ // save credentials
117
+ Mage::getModel('tagalys_core/config')->setTagalysConfig('api_credentials', $params['api_credentials']);
118
+ Mage::getSingleton('tagalys_core/client')->cacheApiCredentials();
119
+ return true;
120
+ }
121
+
122
+ }
app/code/community/Tagalys/Core/controllers/SyncfilesController.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagalys_Core_SyncfilesController extends Mage_Core_Controller_Front_Action {
3
+
4
+ public function _checkPrivateIdentification($identification) {
5
+ $api_credentials = Mage::getModel('tagalys_core/config')->getTagalysConfig('api_credentials', true);
6
+ return ($identification['client_code'] == $api_credentials['client_code'] && $identification['api_key'] == $api_credentials['private_api_key']);
7
+ }
8
+
9
+ public function callbackAction() {
10
+ $params = $this->getRequest()->getParams();
11
+
12
+ if ($this->_checkPrivateIdentification($params['identification'])) {
13
+ $split = explode('media/tagalys/', $params['completed']);
14
+ $filename = $split[1];
15
+ if (is_null($filename)) {
16
+ $split = explode('media\/tagalys\/', $params['completed']);
17
+ $filename = $split[1];
18
+ }
19
+ if (is_null($filename)) {
20
+ Mage::getSingleton('tagalys_core/client')->log('error', 'Error in callbackAction. Unable to read filename', array('params' => $params));
21
+ return false;
22
+ }
23
+ Mage::helper('tagalys_core/SyncFile')->tagalysCallback($params['identification']['store_id'], $filename);
24
+ return true;
25
+ } else {
26
+ Mage::getSingleton('tagalys_core/client')->log('warn', 'Invalid identification in callbackAction', array('params' => $params));
27
+ return false;
28
+ }
29
+ }
30
+
31
+ }
app/code/community/Tagalys/Core/etc/config.xml ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+
5
+ <default>
6
+ <tagalys>
7
+ <package>
8
+ <name>Mpages</name>
9
+ <version>1.1.0</version>
10
+ </package>
11
+ </tagalys>
12
+ </default>
13
+
14
+ <modules>
15
+ <Tagalys_Core>
16
+ <version>0.3.0</version>
17
+ </Tagalys_Core>
18
+ </modules>
19
+
20
+ <frontend>
21
+ <routers>
22
+ <tagalys>
23
+ <use>standard</use>
24
+ <args>
25
+ <module>Tagalys_Core</module>
26
+ <frontName>tagalys</frontName>
27
+ </args>
28
+ </tagalys>
29
+ </routers>
30
+ </frontend>
31
+
32
+ <global>
33
+ <events>
34
+ <controller_action_postdispatch>
35
+ <observers>
36
+ <controller_action_after>
37
+ <class>tagalys_core/observer</class>
38
+ <method>tagalys_distpatch</method>
39
+ </controller_action_after>
40
+ </observers>
41
+ </controller_action_postdispatch>
42
+ <catalog_product_import_finish_before>
43
+ <observers>
44
+ <tagalys_catalog_product_import_finish_before_handler>
45
+ <type>singleton</type>
46
+ <class>tagalys_core/observer</class>
47
+ <method>productsImported</method>
48
+ <args></args>
49
+ </tagalys_catalog_product_import_finish_before_handler>
50
+ </observers>
51
+ </catalog_product_import_finish_before>
52
+ <catalog_product_save_after>
53
+ <observers>
54
+ <tagalys_catalog_product_save_after_handler>
55
+ <type>singleton</type>
56
+ <class>tagalys_core/observer</class>
57
+ <method>productChanged</method>
58
+ <args></args>
59
+ </tagalys_catalog_product_save_after_handler>
60
+ </observers>
61
+ </catalog_product_save_after>
62
+ <catalog_product_delete_before>
63
+ <observers>
64
+ <tagalys_catalog_product_delete_before_handler>
65
+ <type>singleton</type>
66
+ <class>tagalys_core/observer</class>
67
+ <method>productChanged</method>
68
+ <args></args>
69
+ </tagalys_catalog_product_delete_before_handler>
70
+ </observers>
71
+ </catalog_product_delete_before>
72
+ <catalog_product_delete_commit_after>
73
+ <observers>
74
+ <tagalys_catalog_product_delete_commit_after_handler>
75
+ <type>singleton</type>
76
+ <class>tagalys_core/observer</class>
77
+ <method>productChanged</method>
78
+ <args></args>
79
+ </tagalys_catalog_product_delete_commit_after_handler>
80
+ </observers>
81
+ </catalog_product_delete_commit_after>
82
+ </events>
83
+
84
+ <models>
85
+ <tagalys_core>
86
+ <class>Tagalys_Core_Model</class>
87
+ <resourceModel>tagalys_core_mysql4</resourceModel>
88
+ </tagalys_core>
89
+ <tagalys_core_mysql4>
90
+ <class>Tagalys_Core_Model_Mysql4</class>
91
+ <entities>
92
+ <config>
93
+ <table>tagalys_core_config</table>
94
+ </config>
95
+ <queue>
96
+ <table>tagalys_core_queue</table>
97
+ </queue>
98
+ </entities>
99
+ </tagalys_core_mysql4>
100
+ </models>
101
+
102
+ <resources>
103
+ <tagalys_core_setup>
104
+ <setup>
105
+ <module>Tagalys_Core</module>
106
+ </setup>
107
+ <connection>
108
+ <use>core_setup</use>
109
+ </connection>
110
+ </tagalys_core_setup>
111
+ <tagalys_core_write>
112
+ <connection>
113
+ <use>core_write</use>
114
+ </connection>
115
+ </tagalys_core_write>
116
+ <tagalys_core_read>
117
+ <connection>
118
+ <use>core_read</use>
119
+ </connection>
120
+ </tagalys_core_read>
121
+ </resources>
122
+
123
+ <blocks>
124
+ <tagalys_core>
125
+ <class>Tagalys_Core_Block</class>
126
+ </tagalys_core>
127
+ </blocks>
128
+
129
+ <helpers>
130
+ <tagalys_core>
131
+ <class>Tagalys_Core_Helper</class>
132
+ </tagalys_core>
133
+ </helpers>
134
+ </global>
135
+
136
+ <admin>
137
+ <routers>
138
+ <adminhtml>
139
+ <args>
140
+ <modules>
141
+ <tagalys_core before="Mage_Adminhtml">Tagalys_Core_Adminhtml</tagalys_core>
142
+ </modules>
143
+ </args>
144
+ </adminhtml>
145
+ </routers>
146
+ </admin>
147
+
148
+ <adminhtml>
149
+ <menu>
150
+ <Tagalys translate="title" module="core">
151
+ <title>Tagalys</title>
152
+ <sort_order>100</sort_order>
153
+ <children>
154
+ <tagalys_core translate="title" module="core">
155
+ <sort_order>10</sort_order>
156
+ <title>Configuration</title>
157
+ <action>adminhtml/tagalys</action>
158
+ </tagalys_core>
159
+ </children>
160
+ </Tagalys>
161
+ </menu>
162
+ <!-- The <layout> updates allow us to define our block layouts in a separate file so are aren't messin' with the Magento layout files. -->
163
+ <layout>
164
+ <updates>
165
+ <tagalys_core>
166
+ <file>tagalys_core.xml</file>
167
+ </tagalys_core>
168
+ </updates>
169
+ </layout>
170
+ <!-- The <acl> section is for access control. Here we define the pieces where access can be controlled within a role. -->
171
+ <acl>
172
+ <resources>
173
+ <admin>
174
+ <children>
175
+ <tagalys_core>
176
+ <title>Tagalys</title>
177
+ <children>
178
+ <example translate="title" module="tagalys_core">
179
+ <title>Core</title>
180
+ </example>
181
+ </children>
182
+ </tagalys_core>
183
+ </children>
184
+ </admin>
185
+ </resources>
186
+ </acl>
187
+ </adminhtml>
188
+
189
+ <crontab>
190
+ <jobs>
191
+ <tagalys_sync_cron>
192
+ <schedule>
193
+ <cron_expr>*/5 * * * *</cron_expr>
194
+ </schedule>
195
+ <run>
196
+ <model>tagalys_core/observer::syncCron</model>
197
+ </run>
198
+ </tagalys_sync_cron>
199
+ <tagalys_resync_cron>
200
+ <schedule>
201
+ <cron_expr>0 1 * * *</cron_expr>
202
+ </schedule>
203
+ <run>
204
+ <model>tagalys_core/observer::resyncCron</model>
205
+ </run>
206
+ </tagalys_resync_cron>
207
+ </jobs>
208
+ </crontab>
209
+ </config>
app/code/community/Tagalys/Core/sql/.DS_Store ADDED
Binary file
app/code/community/Tagalys/Core/sql/tagalys_core_setup/mysql4-install-0.3.0.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+
4
+ $installer->startSetup();
5
+
6
+ $installer->run("DROP TABLE IF EXISTS {$this->getTable('tagalys_queue')}");
7
+ $installer->run("DROP TABLE IF EXISTS {$this->getTable('tagalys_core_config')}");
8
+ $installer->run("DROP TABLE IF EXISTS {$this->getTable('tagalys_core_queue')}");
9
+ Mage::getModel('core/config_data')->load('crontab/jobs/tagalys_updates_cron/schedule/cron_expr', 'path')->delete();
10
+ Mage::getModel('core/config_data')->load('crontab/jobs/tagalys_resync_cron/schedule/cron_expr', 'path')->delete();
11
+
12
+ $tagalys_core_config_table = $installer->getConnection()->newTable($installer->getTable('tagalys_core_config'))
13
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
14
+ 'unsigned' => true,
15
+ 'nullable' => false,
16
+ 'primary' => true,
17
+ 'identity' => true,
18
+ ), 'ID')
19
+ ->addColumn('path', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
20
+ 'nullable' => false,
21
+ 'default' => '-',
22
+ ), 'Config Path')
23
+ ->addColumn('value', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
24
+ 'nullable' => false,
25
+ 'default' => '',
26
+ ), 'Config Value');
27
+ $tagalys_core_config_table->addIndex(
28
+ $installer->getIdxName('tagalys_core/config', array('path'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
29
+ array('path'),
30
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)
31
+ );
32
+ $installer->getConnection()->createTable($tagalys_core_config_table);
33
+
34
+ $tagalys_core_queue_table = $installer->getConnection()->newTable($installer->getTable('tagalys_core_queue'))
35
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
36
+ 'unsigned' => true,
37
+ 'nullable' => false,
38
+ 'primary' => true,
39
+ 'identity' => true,
40
+ ), 'ID')
41
+ ->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 50, array(
42
+ 'nullable' => false,
43
+ 'default' => '0',
44
+ ), 'Product ID')
45
+ ->setComment('Tagalys Product Queue Table');
46
+ $installer->getConnection()->createTable($tagalys_core_queue_table);
47
+
48
+ $installer->endSetup();
app/code/community/Tagalys/Core/sql/tagalys_core_setup/mysql4-upgrade-0.1.0-0.3.0.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+
4
+ $installer->startSetup();
5
+
6
+ $installer->run("DROP TABLE IF EXISTS {$this->getTable('tagalys_queue')}");
7
+ $installer->run("DROP TABLE IF EXISTS {$this->getTable('tagalys_core_config')}");
8
+ $installer->run("DROP TABLE IF EXISTS {$this->getTable('tagalys_core_queue')}");
9
+ Mage::getModel('core/config_data')->load('crontab/jobs/tagalys_updates_cron/schedule/cron_expr', 'path')->delete();
10
+ Mage::getModel('core/config_data')->load('crontab/jobs/tagalys_resync_cron/schedule/cron_expr', 'path')->delete();
11
+
12
+ $tagalys_core_config_table = $installer->getConnection()->newTable($installer->getTable('tagalys_core_config'))
13
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
14
+ 'unsigned' => true,
15
+ 'nullable' => false,
16
+ 'primary' => true,
17
+ 'identity' => true,
18
+ ), 'ID')
19
+ ->addColumn('path', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
20
+ 'nullable' => false,
21
+ 'default' => '-',
22
+ ), 'Config Path')
23
+ ->addColumn('value', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
24
+ 'nullable' => false,
25
+ 'default' => '',
26
+ ), 'Config Value');
27
+ $tagalys_core_config_table->addIndex(
28
+ $installer->getIdxName('tagalys_core/config', array('path'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
29
+ array('path'),
30
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)
31
+ );
32
+ $installer->getConnection()->createTable($tagalys_core_config_table);
33
+
34
+ $tagalys_core_queue_table = $installer->getConnection()->newTable($installer->getTable('tagalys_core_queue'))
35
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
36
+ 'unsigned' => true,
37
+ 'nullable' => false,
38
+ 'primary' => true,
39
+ 'identity' => true,
40
+ ), 'ID')
41
+ ->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 50, array(
42
+ 'nullable' => false,
43
+ 'default' => '0',
44
+ ), 'Product ID')
45
+ ->setComment('Tagalys Product Queue Table');
46
+ $installer->getConnection()->createTable($tagalys_core_queue_table);
47
+
48
+ $installer->endSetup();
app/code/community/Tagalys/Core/sql/tagalys_core_setup/mysql4-upgrade-0.2.0-0.3.0.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+
4
+ $installer->startSetup();
5
+
6
+ $installer->run("DROP TABLE IF EXISTS {$this->getTable('tagalys_queue')}");
7
+ $installer->run("DROP TABLE IF EXISTS {$this->getTable('tagalys_core_config')}");
8
+ $installer->run("DROP TABLE IF EXISTS {$this->getTable('tagalys_core_queue')}");
9
+ Mage::getModel('core/config_data')->load('crontab/jobs/tagalys_updates_cron/schedule/cron_expr', 'path')->delete();
10
+ Mage::getModel('core/config_data')->load('crontab/jobs/tagalys_resync_cron/schedule/cron_expr', 'path')->delete();
11
+
12
+ $tagalys_core_config_table = $installer->getConnection()->newTable($installer->getTable('tagalys_core_config'))
13
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
14
+ 'unsigned' => true,
15
+ 'nullable' => false,
16
+ 'primary' => true,
17
+ 'identity' => true,
18
+ ), 'ID')
19
+ ->addColumn('path', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
20
+ 'nullable' => false,
21
+ 'default' => '-',
22
+ ), 'Config Path')
23
+ ->addColumn('value', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
24
+ 'nullable' => false,
25
+ 'default' => '',
26
+ ), 'Config Value');
27
+ $tagalys_core_config_table->addIndex(
28
+ $installer->getIdxName('tagalys_core/config', array('path'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
29
+ array('path'),
30
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)
31
+ );
32
+ $installer->getConnection()->createTable($tagalys_core_config_table);
33
+
34
+ $tagalys_core_queue_table = $installer->getConnection()->newTable($installer->getTable('tagalys_core_queue'))
35
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
36
+ 'unsigned' => true,
37
+ 'nullable' => false,
38
+ 'primary' => true,
39
+ 'identity' => true,
40
+ ), 'ID')
41
+ ->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 50, array(
42
+ 'nullable' => false,
43
+ 'default' => '0',
44
+ ), 'Product ID')
45
+ ->setComment('Tagalys Product Queue Table');
46
+ $installer->getConnection()->createTable($tagalys_core_queue_table);
47
+
48
+ $installer->endSetup();
app/code/{local/Tagalys/Tsearch/Model → community/Tagalys/Mpages}/.DS_Store RENAMED
Binary file
app/code/community/Tagalys/Mpages/controllers/IndexController.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagalys_Mpages_IndexController extends Mage_Core_Controller_Front_Action {
3
+
4
+ public function indexAction() {
5
+ $this->loadLayout();
6
+
7
+ if (Mage::helper('tagalys_core')->isTagalysModuleEnabled('mpages')) {
8
+ try {
9
+ $params = Mage::app()->getRequest()->getParams();
10
+ $response = Mage::getSingleton('tagalys_core/client')->storeApiCall(Mage::app()->getStore()->getId().'', '/v1/mpages/'.$params['mpage'], array('request' => array('variables', 'banners')));
11
+ if ($response !== false) {
12
+ $head = $this->getLayout()->getBlock('head');
13
+ if ($head) {
14
+ if (isset($response['variables'])) {
15
+ if (isset($response['variables']['page_title']) && $response['variables']['page_title'] != '' ) {
16
+ $head->setTitle($response['variables']['page_title']);
17
+ } else {
18
+ $head->setTitle($response['name']);
19
+ }
20
+ if (isset($response['variables']['meta_keywords'])) {
21
+ $head->setKeywords($response['variables']['meta_keywords']);
22
+ }
23
+ if (isset($response['variables']['meta_description'])) {
24
+ $head->setDescription($response['variables']['meta_description']);
25
+ }
26
+ }
27
+ }
28
+ }
29
+ } catch (Exception $e) {
30
+
31
+ }
32
+
33
+ $block = $this->getLayout()->createBlock(
34
+ 'Mage_Core_Block_Template',
35
+ 'search',
36
+ array('template' => 'tagalys_mpages/index.phtml')
37
+ );
38
+ $this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
39
+ $this->getLayout()->getBlock('content')->append($block);
40
+ $this->_initLayoutMessages('core/session');
41
+ $this->renderLayout();
42
+ } else {
43
+ $this->norouteAction();
44
+ return;
45
+ }
46
+ }
47
+
48
+ }
app/code/community/Tagalys/Mpages/etc/config.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+
5
+ <modules>
6
+ <Tagalys_Mpages>
7
+ <version>0.1.0</version>
8
+ </Tagalys_Mpages>
9
+ </modules>
10
+
11
+ <frontend>
12
+ <routers>
13
+ <tagalys_mpage>
14
+ <use>standard</use>
15
+ <args>
16
+ <module>Tagalys_Mpages</module>
17
+ <frontName>m</frontName>
18
+ </args>
19
+ </tagalys_mpage>
20
+ </routers>
21
+ </frontend>
22
+
23
+ <global>
24
+ <rewrite>
25
+ <tagalys_mpage>
26
+ <from><![CDATA[#^/m/([\w-]+)/?#]]></from>
27
+ <to><![CDATA[/m/index/index/mpage/$1]]></to>
28
+ <complete>1</complete>
29
+ </tagalys_mpage>
30
+ </rewrite>
31
+ </global>
32
+ </config>
app/code/{local/Tagalys/MerchandisingPage/Model → community/Tagalys/Search}/.DS_Store RENAMED
Binary file
app/code/community/Tagalys/Search/controllers/IndexController.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagalys_Search_IndexController extends Mage_Core_Controller_Front_Action {
3
+
4
+ public function indexAction() {
5
+ $this->loadLayout();
6
+ if (Mage::helper('tagalys_core')->isTagalysModuleEnabled('search')) {
7
+ $block = $this->getLayout()->createBlock(
8
+ 'Mage_Core_Block_Template',
9
+ 'search',
10
+ array('template' => 'tagalys_search/index.phtml')
11
+ );
12
+
13
+ $this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
14
+ $this->getLayout()->getBlock('head')->setTitle('Search Results for "' . Mage::app()->getRequest()->getParam('q', null) . '"');
15
+ $this->getLayout()->getBlock('content')->append($block);
16
+ $this->_initLayoutMessages('core/session');
17
+ $this->renderLayout();
18
+ } else {
19
+ $this->norouteAction();
20
+ return;
21
+ }
22
+ }
23
+
24
+ }
app/code/community/Tagalys/Search/etc/config.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+
5
+ <modules>
6
+ <Tagalys_Search>
7
+ <version>0.1.0</version>
8
+ </Tagalys_Search>
9
+ </modules>
10
+
11
+ <frontend>
12
+ <routers>
13
+ <tagalys_search>
14
+ <use>standard</use>
15
+ <args>
16
+ <module>Tagalys_Search</module>
17
+ <frontName>tsearch</frontName>
18
+ </args>
19
+ </tagalys_search>
20
+ </routers>
21
+ </frontend>
22
+ </config>
app/code/community/Tagalys/SearchSuggestions/Helper/Data.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tagalys_SearchSuggestions_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+ public function getCurrentCurrency() {
6
+ $currency_rate = array();
7
+ $currencyModel = Mage::getModel('directory/currency');
8
+ $currencies = $currencyModel->getConfigAllowCurrencies(); // abaliable currency
9
+ $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode(); //default code
10
+ $defaultCurrencies = $currencyModel->getConfigBaseCurrencies();
11
+ $rates=$currencyModel->getCurrencyRates($defaultCurrencies, $currencies); //rates of each currency
12
+ $current_currency = Mage::getModel('core/cookie')->get('currency') ? Mage::getModel('core/cookie')->get('currency') : Mage::app()->getStore()->getBaseCurrencyCode();
13
+ if (empty($rates[$baseCurrencyCode])) {
14
+ $rates[$baseCurrencyCode] = array($baseCurrencyCode => '1.0000');
15
+ }
16
+ foreach($rates[$baseCurrencyCode] as $key=>$value) {
17
+ $default = $baseCurrencyCode == $key ? true : false;
18
+ if ($key == $current_currency) {
19
+ $label = Mage::app()->getLocale()->currency($key)->getSymbol();
20
+ if (empty($label)) {
21
+ if ($baseCurrencyCode == "INR") {
22
+ $label = "₹";
23
+ }
24
+ }
25
+ $currency_rate[] = array("id" => $key, "label" => $label, "fractional_digits" => 2 , "rounding_mode" => "round", "exchange_rate" => (float)$value, "default" => $default); //getFinalPrice
26
+ }
27
+ }
28
+ return $currency_rate;
29
+ }
30
+
31
+ public function cachePopularSearches() {
32
+ try {
33
+ $setup_status = Mage::getModel('tagalys_core/config')->getTagalysConfig('setup_status');
34
+ $setup_complete = ($setup_status == 'completed');
35
+ if ($setup_complete) {
36
+ $stores_for_tagalys = Mage::helper('tagalys_core')->getStoresForTagalys();
37
+ if ($stores_for_tagalys != null) {
38
+ foreach ($stores_for_tagalys as $store_id) {
39
+ $popular_searches = Mage::getSingleton('tagalys_core/client')->storeApiCall($store_id, '/v1/popular_searches');
40
+ if ($popular_searches != false && array_key_exists('popular_searches', $popular_searches)) {
41
+ Mage::getModel('tagalys_core/config')->setTagalysConfig("store:{$store_id}:popular_searches", $popular_searches['popular_searches'], true);
42
+ }
43
+ }
44
+ }
45
+ }
46
+ } catch (Exception $e) {
47
+ Mage::log("Error in cachePopularSearches: ". $e->getMessage(), null, "tagalys.log");
48
+ }
49
+ return $this;
50
+ }
51
+ }
app/code/community/Tagalys/SearchSuggestions/Model/Observer.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tagalys_SearchSuggestions_Model_Observer {
3
+
4
+ public function cachePopularSearchesCron() {
5
+ try {
6
+ $utc_now = new DateTime("now", new DateTimeZone('UTC'));
7
+ $time_now = $utc_now->format(DateTime::ATOM);
8
+ Mage::getModel('tagalys_core/config')->setTagalysConfig("heartbeat:cachePopularSearchesCron", $time_now);
9
+ Mage::helper("search_suggestions")->cachePopularSearches();
10
+ } catch (Exception $e) {
11
+ Mage::log("Error in cachePopularSearchesCron: ". $e->getMessage(), null, "tagalys.log");
12
+ }
13
+ return $this;
14
+ }
15
+ }
app/code/community/Tagalys/SearchSuggestions/etc/config.xml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Tagalys_SearchSuggestions>
5
+ <version>0.1.0</version>
6
+ </Tagalys_SearchSuggestions>
7
+ </modules>
8
+ <frontend>
9
+ <layout>
10
+ <updates>
11
+ <tagalys_search_suggestions>
12
+ <file>tagalys_search_suggestions.xml</file>
13
+ </tagalys_search_suggestions>
14
+ </updates>
15
+ </layout>
16
+ </frontend>
17
+ <global>
18
+ <models>
19
+ <tagalys_search_suggestions>
20
+ <class>Tagalys_SearchSuggestions_Model</class>
21
+ </tagalys_search_suggestions>
22
+ <tagalys_search_suggestions>
23
+ <resourceModel>tagalys_search_suggestions_resource</resourceModel>
24
+ </tagalys_search_suggestions>
25
+ <tagalys_search_suggestions_resource>
26
+ <class>Tagalys_SearchSuggestions_Model_Resource</class>
27
+ </tagalys_search_suggestions_resource>
28
+ </models>
29
+ <helpers>
30
+ <search_suggestions>
31
+ <class>Tagalys_SearchSuggestions_Helper</class>
32
+ </search_suggestions>
33
+ </helpers>
34
+ </global>
35
+ <crontab>
36
+ <jobs>
37
+ <tagalys_popular_searches_cron>
38
+ <schedule>
39
+ <cron_expr>*/15 * * * *</cron_expr>
40
+ </schedule>
41
+ <run>
42
+ <model>tagalys_search_suggestions/observer::cachePopularSearchesCron</model>
43
+ </run>
44
+ </tagalys_popular_searches_cron>
45
+ </jobs>
46
+ </crontab>
47
+ </config>
app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit.php DELETED
@@ -1,41 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Core_Block_Adminhtml_Tagalys_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
- {
5
- public function __construct() {
6
-
7
- $this->_objectId = 'id';
8
- $this->_controller = 'adminhtml_tagalys';
9
- $this->_blockGroup = 'tagalys_core';
10
- parent::__construct();
11
-
12
- $this->_removeButton('save');
13
- $this->_removeButton('back');
14
- $this->_removeButton('reset');
15
-
16
- }
17
-
18
- /**
19
- * Get header text
20
- *
21
- * @return string
22
- */
23
- public function getHeaderText() {
24
-
25
- $status = Mage::helper('tagalys_core')->getTagalysConfig('setup_complete');
26
- if($status) {
27
- return $this->__('Tagalys Configuration');
28
- }
29
- return $this->__('Initial Setup');
30
- }
31
-
32
- /**
33
- * Check permission for passed action
34
- *
35
- * @param string $action
36
- * @return bool
37
- */
38
- protected function _isAllowedAction($action) {
39
- return true;
40
- }
41
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Form.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
- {
5
-
6
- protected function _prepareForm()
7
- {
8
- /** @var $form Varien_Data_Form */
9
- $form = new Varien_Data_Form(array(
10
- 'id' => 'edit_form',
11
- 'action' => $this->getUrl('*/tagalys/save/', array('id' => $this->getRequest()->getParam('id'))),
12
- 'method' => 'post'
13
- ));
14
-
15
- $form->setUseContainer(true);
16
- $this->setForm($form);
17
-
18
- return parent::_prepareForm();
19
- }
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Credentials.php DELETED
@@ -1,119 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tab_Credentials extends Mage_Adminhtml_Block_Widget_Form
4
- implements Mage_Adminhtml_Block_Widget_Tab_Interface {
5
-
6
- public function __construct() {
7
- parent::__construct();
8
- }
9
-
10
- protected function _prepareForm() {
11
- $this->_helper = Mage::helper('tagalys_core');
12
-
13
- $form = Mage::getModel('varien/data_form', array(
14
- 'id' => 'edit_form',
15
- 'action' => $this->getUrl('*/tagalys', array('_current' => true)),
16
- 'method' => 'post'
17
- ));
18
-
19
- $form->setHtmlIdPrefix('admin_tagalys_core');
20
- $htmlIdPrefix = $form->getHtmlIdPrefix();
21
-
22
- $fieldset = $form->addFieldset('tagalys_core_fieldset', array('legend' => $this->__('Credentials')));
23
-
24
- $fieldset->addField('api_server', 'text', array(
25
- 'name' => 'api_server',
26
- 'label' => $this->__('Enter API Server'),
27
- 'value' => $this->_helper->getTagalysConfig("client_code"),
28
- 'required' => true,
29
- 'style' => "width:100%",
30
- 'value' => $this->_helper->getTagalysConfig("api_server"),
31
- 'after_element_html' => '<small>Server Name can be found in the API Credentials section of your <a href=http://dashboard.tagalys.com/signup target=_blank> Tagalys Account </a></small>',
32
- 'tabindex' => 1
33
- ));
34
-
35
-
36
- $fieldset->addField('client_code', 'text', array(
37
- 'label' => $this->__('Client Code'),
38
- 'required' => true,
39
- 'name' => 'client_code',
40
- 'value' => $this->_helper->getTagalysConfig("client_code"),
41
- 'disabled' => false,
42
- // 'readonly' => false,
43
- 'style' => "width:100%",
44
- 'after_element_html' => '<small>Client Code can be found in the API Credentials section of your Tagalys Account </small>',
45
- 'tabindex' => 1
46
- ));
47
-
48
-
49
- $fieldset->addField('public_api_key', 'text', array(
50
- 'label' => $this->__('Public API Key'),
51
- 'required' => true,
52
- 'name' => 'public_api_key',
53
- 'value' => $this->_helper->getTagalysConfig("public_api_key"),
54
- 'disabled' => false,
55
- // 'readonly' => false,
56
- 'style' => "width:100%",
57
- 'after_element_html' => '<small>This API key which will be included in the public JavaScript code </small>',
58
- 'tabindex' => 1
59
- ));
60
- $fieldset->addField('private_api_key', 'password', array(
61
- 'label' => $this->__('Private API Key'),
62
- 'required' => true,
63
- 'name' => 'private_api_key',
64
- 'value' => $this->_helper->getTagalysConfig("private_api_key"),
65
- 'disabled' => false,
66
- // 'readonly' => false,
67
- 'style' => "width:100%",
68
- 'after_element_html' => '<small>This API Key is used to authenticate all communications between Client & Tagalys servers(To be kept Private)</small>',
69
- 'tabindex' => 1
70
- ));
71
-
72
- $fieldset->addField('submit', 'submit', array(
73
- 'name' => 'submit_auth',
74
- 'value' => 'Submit',
75
- 'class'=> "tagalys-btn",
76
- 'tabindex' => 1
77
- ));
78
-
79
- $this->setForm($form);
80
- return parent::_prepareForm();
81
- }
82
-
83
- /**
84
- * Tab label getter
85
- *
86
- * @return string
87
- */
88
- public function getTabLabel() {
89
- return $this->__('Tagalys Credentials');
90
- }
91
-
92
- /**
93
- * Tab title getter
94
- *
95
- * @return string
96
- */
97
- public function getTabTitle() {
98
- return $this->__('Tagalys Credentials');
99
- }
100
-
101
- /**
102
- * Check if tab can be shown
103
- *
104
- * @return bool
105
- */
106
- public function canShowTab() {
107
- return true;
108
- }
109
-
110
- /**
111
- * Check if tab hidden
112
- *
113
- * @return bool
114
- */
115
- public function isHidden() {
116
- return false;
117
- }
118
-
119
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Debug.php DELETED
@@ -1,87 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tab_Debug extends Mage_Adminhtml_Block_Widget_Form
4
- implements Mage_Adminhtml_Block_Widget_Tab_Interface {
5
-
6
- public function __construct() {
7
- parent::__construct();
8
- }
9
-
10
-
11
- protected function _prepareForm() {
12
-
13
- /** @var $form Varien_Data_Form */
14
- $form = Mage::getModel('varien/data_form', array(
15
- 'id' => 'edit_form',
16
- 'action' => $this->getUrl('*/tagalys', array('_current' => true)),
17
- 'method' => 'post'
18
- ));
19
-
20
- $form->setHtmlIdPrefix('admin_');
21
- $htmlIdPrefix = $form->getHtmlIdPrefix();
22
-
23
-
24
- $debug_fieldset = $form->addFieldset('debug_fieldset', array('legend' => $this->__('Manual Product Resync')));
25
-
26
-
27
- $debug_fieldset->addField('note_resync', 'note', array(
28
- 'text' => $this->__('Do not manually sync the catalog unless you face any issues with normal setup. This is not a part of regular setup, please do this with guidance from the tagalys team (cs@tagalys.com)'),
29
- ));
30
-
31
- $debug_fieldset->addField('submit_resync', 'submit', array(
32
- 'name' => 'submit_resync',
33
- 'value' => 'Manual Catalog Resync',
34
- 'class'=> "tagalys-btn",
35
- 'tabindex' => 1
36
- ));
37
-
38
- $debug_fieldset = $form->addFieldset('debug_fieldset1', array('legend' => $this->__('Manual Configuration Resync')));
39
-
40
-
41
- $debug_fieldset->addField('note_reconfig', 'note', array(
42
- 'text' => $this->__('Do not manually sync the Configuration unless you face any issues with normal setup. This is not a part of regular setup, please do this with guidance from the tagalys team (cs@tagalys.com)'),
43
- ));
44
-
45
- $debug_fieldset->addField('submit_reconfig', 'submit', array(
46
- 'name' => 'submit_reconfig',
47
- 'value' => 'Manual Configuration Update',
48
- 'class'=> "tagalys-btn",
49
- 'tabindex' => 1
50
- ));
51
-
52
- $this->setForm($form);
53
- return parent::_prepareForm();
54
- }
55
-
56
-
57
- public function getTabLabel() {
58
- return $this->__('Settings');
59
- }
60
-
61
- /**
62
- * Tab title getter
63
- *
64
- * @return string
65
- */
66
- public function getTabTitle() {
67
- return $this->__('Settings');
68
- }
69
-
70
- /**
71
- * Check if tab can be shown
72
- *
73
- * @return bool
74
- */
75
- public function canShowTab() {
76
- return true;
77
- }
78
-
79
- /**
80
- * Check if tab hidden
81
- *
82
- * @return bool
83
- */
84
- public function isHidden() {
85
- return false;
86
- }
87
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Merchandisingpage.php DELETED
@@ -1,96 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tab_Merchandisingpage extends Mage_Adminhtml_Block_Widget_Form
4
- implements Mage_Adminhtml_Block_Widget_Tab_Interface {
5
-
6
- public function __construct() {
7
- parent::__construct();
8
- }
9
-
10
- protected function _prepareForm() {
11
- $this->_helper = Mage::helper('tagalys_core');
12
-
13
- /** @var $form Varien_Data_Form */
14
- $form = Mage::getModel('varien/data_form', array(
15
- 'id' => 'tsearch_edit_form',
16
- 'action' => $this->getUrl('*/tagalys', array('_current' => true)),
17
- 'method' => 'post'
18
- ));
19
-
20
- $form->setHtmlIdPrefix('admin_tagalys_merchandisingpage');
21
- $htmlIdPrefix = $form->getHtmlIdPrefix();
22
- $fieldset = $form->addFieldset('tagalys_merchandisingpage_fieldset', array('legend' => $this->__('Merchandising Page Settings')));
23
-
24
- $fieldset->addField('is_merchandising_page_active', 'select', array(
25
- 'name' => 'is_merchandising_page_active',
26
- 'label' => $this->__('Enable merchandising page'),
27
- 'title' => $this->__('Enable merchandising page'),
28
- 'options' => array(
29
- '0' => $this->__('No'),
30
- '1' => $this->__('Yes'),
31
- ),
32
- 'required' => true,
33
- 'style' => "width:100%",
34
- 'value' => (int)$this->_helper->getTagalysConfig("is_merchandising_page_active")
35
- ));
36
-
37
-
38
- $fieldset->addField('merchandising_page_template', 'textarea', array(
39
- 'label' => $this->__('Enter Template Config'),
40
- 'required' => false,
41
- 'name' => 'merchandising_page_template',
42
- 'value' => $this->_helper->getTagalysConfig("merchandising_page_template"),
43
- 'disabled' => false,
44
- // 'readonly' => false,
45
- 'style' => "width:100%",
46
- 'after_element_html' => '<small> </small>',
47
- 'tabindex' => 1
48
- ));
49
-
50
- $fieldset->addField('submit', 'submit', array(
51
- 'name' => 'submit_merchandising_page_config',
52
- 'value' => 'Submit',
53
- 'class'=> "tagalys-btn",
54
- 'tabindex' => 1
55
- ));
56
-
57
- $this->setForm($form);
58
- return parent::_prepareForm();
59
- }
60
-
61
- /**
62
- * Tab label getter
63
- *
64
- * @return string
65
- */
66
- public function getTabLabel() {
67
- return $this->__('Settings');
68
- }
69
-
70
- /**
71
- * Tab title getter
72
- *
73
- * @return string
74
- */
75
- public function getTabTitle() {
76
- return $this->__('Settings');
77
- }
78
-
79
- /**
80
- * Check if tab can be shown
81
- *
82
- * @return bool
83
- */
84
- public function canShowTab() {
85
- return false;
86
- }
87
-
88
- /**
89
- * Check if tab hidden
90
- *
91
- * @return bool
92
- */
93
- public function isHidden() {
94
- return true;
95
- }
96
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Setup.php DELETED
@@ -1,169 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tab_Setup extends Mage_Adminhtml_Block_Widget_Form
4
- implements Mage_Adminhtml_Block_Widget_Tab_Interface {
5
-
6
- public function __construct() {
7
- parent::__construct();
8
- }
9
- protected function _prepareForm() {
10
- $sync_helper = Mage::helper("sync/service");
11
- $this->_helper = Mage::helper('tagalys_core');
12
- $this->_feed = Mage::helper("sync/tagalysFeedFactory");
13
-
14
- /** @var $form Varien_Data_Form */
15
- $form = Mage::getModel('varien/data_form', array(
16
- 'id' => 'edit_form',
17
- 'action' => $this->getUrl('*/tagalys', array('_current' => true)),
18
- 'method' => 'post'
19
- ));
20
-
21
- $form->setHtmlIdPrefix('admin_');
22
- $htmlIdPrefix = $form->getHtmlIdPrefix();
23
- $fieldset = $form->addFieldset('tagalys_sync_fieldset', array('legend' => $this->__('Product Catalog Store Settings')));
24
-
25
- $fieldset->addField('note_ss', 'note', array(
26
- 'text' => $this->__('<small>NOTICE : Please make you disable default magento auto-complete for this to appear on your frontend. </small><br>'),
27
- ));
28
-
29
-
30
- $stores = Mage::helper("sync/data")->getAllWebsiteStores();
31
- $fieldset->addField('stores_setup', 'multiselect', array(
32
- 'label' => $this->__('Select Store'),
33
- 'class' => 'required-entry',
34
- 'required' => true,
35
- 'name' => 'stores_setup',
36
- 'style' => "width:100%",
37
- 'onclick' => "return false;",
38
- 'onchange' => "return false;",
39
- 'value' => 'default',
40
- 'value' => Mage::helper("sync/data")->getSelectedStore(),
41
- 'values' => $stores,
42
- 'disabled' => false,
43
- 'readonly' => false,
44
- 'after_element_html' => '<small>Select appropriate store which you is being used and you would like to sync.</small>',
45
- 'tabindex' => 1
46
- ));
47
- if(Mage::helper('tagalys_core')->getTagalysConfig("setup_complete")) {
48
- $fieldset->addField('tagalys_updates_cron_time', 'select', array(
49
- 'label' => $this->__('Catalog Sync Frequency'),
50
- 'required' => true,
51
- 'name' => 'tagalys_updates_cron_time',
52
- 'options' => array(
53
- '' => '',
54
- '*/1 * * * *' => $this->__('Every 1 Minute'),
55
- '*/5 * * * *' => $this->__('Every 5 Minutes'),
56
- '*/10 * * * *' => $this->__('Every 10 Minutes'),
57
- '*/30 * * * *' => $this->__('Every 30 Minutes'),
58
- '0 * * * *' => $this->__('Every 60 Minutes'),
59
- ),
60
- 'value' => $this->_helper->getTagalysConfig("tagalys_updates_cron_time"),
61
- 'required' => true,
62
- 'style' => "width:100%",
63
- // 'readonly' => false,
64
- 'after_element_html' => '<small>Please select how often you would like to sync your incremental updates with us.</small>'
65
- ));
66
-
67
- $dateFormatIso = Mage::app()->getLocale()->getTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
68
-
69
- $fieldset->addField('feed_cron_time', 'time', array(
70
- 'label' => $this->__('Feed Cron Time'),
71
- 'class' => 'required-entry',
72
- 'required' => true,
73
- 'name' => 'feed_cron_time',
74
- 'value' => date("h,i,s a", Mage::getModel('core/date')->timestamp(time())),
75
- 'disabled' => false,
76
- 'readonly' => false,
77
- 'style' => "width:30%",
78
- 'after_element_html' => '<small> This time is specific to your magento timezone setup <br> Your magento timezone is <em><b>'.Mage::getStoreConfig('general/locale/timezone'). '</b></em><br> We recommend you to select a low traffic time period </small>',
79
- 'tabindex' => 1
80
- ));
81
-
82
- $fieldset->addField('note_cron', 'note', array(
83
- 'text' => $this->__('<small>NOTICE : Please make sure cron is setup and running.</small><br>
84
- REF: <a target=_blank href="http://devdocs.magento.com/guides/m1x/install/installing_install.html#install-cron">Magento Cron Documentation</a>'),
85
- ));
86
-
87
- $fieldset->addField('submit_config', 'submit', array(
88
- 'name' => 'submit_config',
89
- 'value' => 'Save settings',
90
- 'class'=> "tagalys-btn",
91
- 'disabled' => false,
92
- 'style' => "width:100%",
93
- 'after_element_html' => '<small><em></em></small>',
94
- 'tabindex' => 1
95
- ));
96
- } else {
97
- $fieldset->addField('note_cron', 'note', array(
98
- 'text' => $this->__('<small>NOTICE : Please make sure cron is setup and running.</small><br>
99
- REF: <a target=_blank href="http://devdocs.magento.com/guides/m1x/install/installing_install.html#install-cron">Magento Cron Documentation</a>'),
100
- ));
101
-
102
- $fieldset->addField('checkbox', 'checkbox', array(
103
- 'name' => 'Checkbox',
104
- 'checked' => false,
105
- 'onclick' => 'this.value = this.checked ? 1 : 0;',
106
- 'disabled' => false,
107
- 'after_element_html' => '<small>I confirm to start product catalog sync for the above selected stores.<br><em>We recommend you to do this at low traffic hours.</em><br><em>Please enable the checkbox to Submit and start catalog sync.</em></small>',
108
- 'tabindex' => 1
109
- ));
110
-
111
- $fieldset->addField('submit', 'submit', array(
112
- 'name' => 'submit_config',
113
- 'value' => 'Submit & Start Catalog Sync',
114
- 'class'=> "tagalys-btn",
115
- 'disabled' => true,
116
- 'style' => "width:100%",
117
- 'after_element_html' => '<small><em></em></small>',
118
- 'tabindex' => 1
119
- ));
120
-
121
- }
122
-
123
-
124
-
125
- $this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')
126
- ->addFieldMap("{$htmlIdPrefix}sync_level", 'sync_level')
127
- ->addFieldMap("{$htmlIdPrefix}note_advanced", 'note_advanced')
128
- ->addFieldMap("{$htmlIdPrefix}checkbox", 'checkbox')
129
- ->addFieldMap("{$htmlIdPrefix}submit", 'submit')
130
- ->addFieldDependence('note_advanced', 'sync_level', 'advanced')
131
- // ->addFieldDependence('submit', 'checkbox', '1')
132
- );
133
-
134
- $this->setForm($form);
135
- return parent::_prepareForm();
136
- }
137
-
138
-
139
- public function getTabLabel() {
140
- return $this->__('Catalog Store Setup');
141
- }
142
-
143
- /**
144
- * Tab title getter
145
- *
146
- * @return string
147
- */
148
- public function getTabTitle() {
149
- return $this->__('Catalog Store Setup');
150
- }
151
-
152
- /**
153
- * Check if tab can be shown
154
- *
155
- * @return bool
156
- */
157
- public function canShowTab() {
158
- return true;
159
- }
160
-
161
- /**
162
- * Check if tab hidden
163
- *
164
- * @return bool
165
- */
166
- public function isHidden() {
167
- return false;
168
- }
169
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Signup.php DELETED
@@ -1,79 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tab_Signup extends Mage_Adminhtml_Block_Widget_Form
4
- implements Mage_Adminhtml_Block_Widget_Tab_Interface {
5
-
6
- public function __construct() {
7
- parent::__construct();
8
- }
9
-
10
- protected function _prepareForm() {
11
- $this->_helper = Mage::helper('tagalys_core');
12
-
13
- $form = Mage::getModel('varien/data_form', array(
14
- 'id' => 'edit_form',
15
- 'action' => $this->getUrl('*/tagalys', array('_current' => true)),
16
- 'method' => 'post'
17
- ));
18
-
19
- $form->setHtmlIdPrefix('admin_tagalys_core');
20
- $htmlIdPrefix = $form->getHtmlIdPrefix();
21
-
22
- $welcome_fieldset = $form->addFieldset('welcome_fieldset', array('legend' => $this->__('General')));
23
-
24
- $welcome_fieldset->addField('note', 'note', array(
25
- 'text' => '<img src='. $this->getSkinUrl("images/logo-tagalys.png") .' alt="" />'.'<br>'.$this->__('Thank you for downloading Tagalys.'),
26
- ));
27
-
28
- $welcome_fieldset->addField('note_live_server', 'note', array(
29
- 'text' => $this->__('Please Login/Sign up into your <a href=http://dashboard.tagalys.com/signup target=_blank> Tagalys account </a>.'),
30
- ));
31
-
32
- $welcome_fieldset->addField('submit', 'submit', array(
33
- 'name' => 'submit_signup_next',
34
- 'value' => 'Got my credentials, Proceed !',
35
- 'class'=> "tagalys-btn",
36
- 'tabindex' => 1
37
- ));
38
-
39
- $this->setForm($form);
40
- return parent::_prepareForm();
41
- }
42
-
43
- /**
44
- * Tab label getter
45
- *
46
- * @return string
47
- */
48
- public function getTabLabel() {
49
- return $this->__('Tagalys Setup');
50
- }
51
-
52
- /**
53
- * Tab title getter
54
- *
55
- * @return string
56
- */
57
- public function getTabTitle() {
58
- return $this->__('Tagalys Setup');
59
- }
60
-
61
- /**
62
- * Check if tab can be shown
63
- *
64
- * @return bool
65
- */
66
- public function canShowTab() {
67
- return true;
68
- }
69
-
70
- /**
71
- * Check if tab hidden
72
- *
73
- * @return bool
74
- */
75
- public function isHidden() {
76
- return false;
77
- }
78
-
79
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Similarproducts.php DELETED
@@ -1,83 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tab_Similarproducts extends Mage_Adminhtml_Block_Widget_Form
4
- implements Mage_Adminhtml_Block_Widget_Tab_Interface {
5
-
6
- public function __construct() {
7
- parent::__construct();
8
- }
9
-
10
- protected function _prepareForm() {
11
- $this->_helper = Mage::helper('tagalys_core');
12
-
13
- /** @var $form Varien_Data_Form */
14
- $form = Mage::getModel('varien/data_form', array(
15
- 'id' => 'tsearch_edit_form',
16
- 'action' => $this->getUrl('*/tagalys', array('_current' => true)),
17
- 'method' => 'post'
18
- ));
19
-
20
- $form->setHtmlIdPrefix('admin_tagalys_similarproducts');
21
- $htmlIdPrefix = $form->getHtmlIdPrefix();
22
- $fieldset = $form->addFieldset('tagalys_similarproducts_fieldset', array('legend' => $this->__('Similar Products Settings')));
23
-
24
- $fieldset->addField('is_similar_products_active', 'select', array(
25
- 'name' => 'is_similar_products_active',
26
- 'label' => $this->__('Enable similar products'),
27
- 'title' => $this->__('Enable similar products'),
28
- 'options' => array(
29
- '0' => $this->__('No'),
30
- '1' => $this->__('Yes'),
31
- ),
32
- 'required' => true,
33
- 'style' => "width:100%",
34
- 'value' => (int)$this->_helper->getTagalysConfig("is_similar_products_active")
35
- ));
36
-
37
- $fieldset->addField('submit', 'submit', array(
38
- 'name' => 'submit_similar_products_config',
39
- 'value' => 'Submit',
40
- 'class'=> "tagalys-btn",
41
- 'tabindex' => 1
42
- ));
43
-
44
- $this->setForm($form);
45
- return parent::_prepareForm();
46
- }
47
-
48
- /**
49
- * Tab label getter
50
- *
51
- * @return string
52
- */
53
- public function getTabLabel() {
54
- return $this->__('Settings');
55
- }
56
-
57
- /**
58
- * Tab title getter
59
- *
60
- * @return string
61
- */
62
- public function getTabTitle() {
63
- return $this->__('Settings');
64
- }
65
-
66
- /**
67
- * Check if tab can be shown
68
- *
69
- * @return bool
70
- */
71
- public function canShowTab() {
72
- return false;
73
- }
74
-
75
- /**
76
- * Check if tab hidden
77
- *
78
- * @return bool
79
- */
80
- public function isHidden() {
81
- return true;
82
- }
83
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Sync.php DELETED
@@ -1,145 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tab_Sync extends Mage_Adminhtml_Block_Widget_Form
4
- implements Mage_Adminhtml_Block_Widget_Tab_Interface {
5
-
6
- public function __construct() {
7
- parent::__construct();
8
- }
9
-
10
-
11
- protected function _prepareForm() {
12
- $sync_helper = Mage::helper("sync/service");
13
- $this->_helper = Mage::helper('tagalys_core');
14
- $this->_feed = Mage::helper("sync/tagalysFeedFactory");
15
-
16
- /** @var $form Varien_Data_Form */
17
- $form = Mage::getModel('varien/data_form', array(
18
- 'id' => 'edit_form',
19
- 'action' => $this->getUrl('*/tagalys', array('_current' => true)),
20
- 'method' => 'post'
21
- ));
22
-
23
- $form->setHtmlIdPrefix('admin_');
24
- $htmlIdPrefix = $form->getHtmlIdPrefix();
25
-
26
- foreach (Mage::helper("sync/data")->getSelectedStore() as $key => $value){
27
- if(!Mage::helper('tagalys_core')->checkStoreInitSync($value)) {
28
- $display = true;
29
- break;
30
- } else {
31
- $display = false;
32
- }
33
- }
34
-
35
-
36
- $product_feed = Mage::helper("sync/tagalysFeedFactory")->getAllProductFeed();
37
- if(!empty($product_feed)) {
38
- $init_email = $form->addFieldset('tagalys_email_fieldset', array(
39
- 'style' => "width:100%",
40
- // 'class' => 'inline'
41
- ));
42
-
43
- $init_email->addField('email_note', 'note', array(
44
- 'after_element_html' =>'<b>You can close this screen now. We will notify you via e-mail when the sync is completed.</b>'
45
- ));
46
-
47
- $fieldset = $form->addFieldset('tagalys_sync_fieldset', array(
48
- 'class' => 'tagalys-progress-inline'
49
- ));
50
-
51
- $search_fieldset = $form->addFieldset('tagalys_search_fieldset', array(
52
- 'class' => 'tagalys-progress-inline'
53
- ));
54
-
55
- $selected_stores = Mage::helper("sync/data")->getSelectedStore();
56
-
57
- $fieldset->addField('note_sync', 'note', array(
58
- 'label' => $this->__('Feed Creation Status 4(a)'),
59
- 'after_element_html' => '<small>Feed creation is processed one store at a time.</small>',
60
- ));
61
-
62
- $fieldset->addType('tagalys_custom_feed_progress', 'Tagalys_Core_Block_Adminhtml_Tagalys_Progress');
63
- foreach ($selected_stores as $key => $value) {
64
- $fieldset->addField('tagalys_feed_'.$value, 'tagalys_custom_feed_progress', array(
65
- 'store_id' => $value,
66
- 'after_element_html' => '<small>Please wait while your Catalog feed file is being generated.</small>',
67
- ));
68
- }
69
-
70
- $search_fieldset->addField('note_search', 'note', array(
71
- 'label' => $this->__('Tagalys Product Index status 4(b)'),
72
- ));
73
-
74
- $search_fieldset->addType('tagalys_search_progress', 'Tagalys_Core_Block_Adminhtml_Tagalys_SearchReady');
75
- foreach ($selected_stores as $key => $value) {
76
- $search_fieldset->addField('tagalys_search_'.$value, 'tagalys_search_progress', array(
77
- 'store_id' => $value,
78
- 'after_element_html' => '<small>Please wait while your products are been processed by Tagalys.</small>'
79
- ));
80
- }
81
-
82
-
83
- }
84
-
85
-
86
- $status = $form->addFieldset('tagalys_status_fieldset', array(
87
- 'style' => "width:50%",
88
- 'class' => 'inline'
89
- ));
90
-
91
-
92
-
93
- $status->addField('cron_note', 'note', array(
94
- 'after_element_html' => Mage::helper('tagalys_core')->getTagalysConfig('setup_complete') ? '<small>Incremental updates will happen every 5 minutes. </small>' : '<small>The duration for Step 4 in setup (Catalog sync) will depend on your cron frequency/setting, catalog size and server throughput. Initial catalog sync usually process around 1000 products per cron.<br><b>We will notify you via e-mail when the sync is completed.</b></small>' ,
95
- ));
96
-
97
- $status->addField('tagalys_reload', 'submit', array(
98
- 'name' => 'submit_reload',
99
- 'value' => 'Next to Continue',
100
- 'class'=> "tagalys-btn",
101
- 'style' => "width:100%",
102
- 'tabindex' => 1
103
- ));
104
-
105
-
106
- $this->setForm($form);
107
- return parent::_prepareForm();
108
- }
109
-
110
- public function getTagalysSyncUrl() {
111
- return $this->getUrl('*/tagalys/initialSync/');
112
- }
113
-
114
-
115
- public function getTabLabel() {
116
- return $this->__('Settings');
117
- }
118
-
119
- /**
120
- * Tab title getter
121
- *
122
- * @return string
123
- */
124
- public function getTabTitle() {
125
- return $this->__('Settings');
126
- }
127
-
128
- /**
129
- * Check if tab can be shown
130
- *
131
- * @return bool
132
- */
133
- public function canShowTab() {
134
- return true;
135
- }
136
-
137
- /**
138
- * Check if tab hidden
139
- *
140
- * @return bool
141
- */
142
- public function isHidden() {
143
- return false;
144
- }
145
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Tsearch.php DELETED
@@ -1,88 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tab_Tsearch extends Mage_Adminhtml_Block_Widget_Form
4
- implements Mage_Adminhtml_Block_Widget_Tab_Interface {
5
-
6
- public function __construct() {
7
- parent::__construct();
8
- }
9
-
10
- protected function _prepareForm() {
11
- $this->_helper = Mage::helper('tagalys_core');
12
-
13
- /** @var $form Varien_Data_Form */
14
- $form = Mage::getModel('varien/data_form', array(
15
- 'id' => 'tsearch_edit_form',
16
- 'action' => $this->getUrl('*/tagalys', array('_current' => true)),
17
- 'method' => 'post'
18
- ));
19
-
20
- $form->setHtmlIdPrefix('admin_tagalys_tsearch');
21
- $htmlIdPrefix = $form->getHtmlIdPrefix();
22
- $fieldset = $form->addFieldset('tagalys_tsearch_fieldset', array('legend' => $this->__('Site Search Settings')));
23
-
24
-
25
- //to-do show only after 100%
26
- $fieldset->addField('is_tsearch_active', 'select', array(
27
- 'name' => 'is_tsearch_active',
28
- 'label' => $this->__('Enable search'),
29
- 'title' => $this->__('Enable search'),
30
- 'options' => array(
31
- '0' => $this->__('No'),
32
- '1' => $this->__('Yes'),
33
- ),
34
- 'required' => true,
35
- 'style' => "width:100%",
36
- 'value' => (int)$this->_helper->getTagalysConfig("is_tsearch_active")
37
- ));
38
-
39
-
40
- $fieldset->addField('submit', 'submit', array(
41
- 'name' => 'submit_search_config',
42
- 'value' => 'Submit',
43
- 'class'=> "tagalys-btn",
44
- 'tabindex' => 1
45
- ));
46
-
47
-
48
-
49
- $this->setForm($form);
50
- return parent::_prepareForm();
51
- }
52
-
53
- /**
54
- * Tab label getter
55
- *
56
- * @return string
57
- */
58
- public function getTabLabel() {
59
- return $this->__('Settings');
60
- }
61
-
62
- /**
63
- * Tab title getter
64
- *
65
- * @return string
66
- */
67
- public function getTabTitle() {
68
- return $this->__('Settings');
69
- }
70
-
71
- /**
72
- * Check if tab can be shown
73
- *
74
- * @return bool
75
- */
76
- public function canShowTab() {
77
- return false;
78
- }
79
-
80
- /**
81
- * Check if tab hidden
82
- *
83
- * @return bool
84
- */
85
- public function isHidden() {
86
- return true;
87
- }
88
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Tsearchsuggestion.php DELETED
@@ -1,121 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tab_Tsearchsuggestion extends Mage_Adminhtml_Block_Widget_Form
4
- implements Mage_Adminhtml_Block_Widget_Tab_Interface {
5
-
6
- public function __construct() {
7
- parent::__construct();
8
- }
9
-
10
- protected function _prepareForm() {
11
- $this->_helper = Mage::helper('tagalys_core');
12
-
13
- /** @var $form Varien_Data_Form */
14
- $form = Mage::getModel('varien/data_form', array(
15
- 'id' => 'tsearch_edit_form',
16
- 'action' => $this->getUrl('*/tagalys', array('_current' => true)),
17
- 'method' => 'post'
18
- ));
19
-
20
- $form->setHtmlIdPrefix('admin_tagalys_tsearch_ss');
21
- $htmlIdPrefix = $form->getHtmlIdPrefix();
22
- $fieldset = $form->addFieldset('tagalys_tsearch_ss_fieldset', array('legend' => $this->__('Search Suggestion Settings')));
23
-
24
- $fieldset->addField('is_tsearchsuggestion_active', 'select', array(
25
- 'name' => 'is_tsearchsuggestion_active',
26
- 'label' => $this->__('Enable Search Suggestions'),
27
- 'title' => $this->__('Enable Search Suggestions'),
28
- 'options' => array(
29
- '0' => $this->__('No'),
30
- '1' => $this->__('Yes'),
31
- ),
32
- 'required' => true,
33
- 'style' => "width:100%",
34
- 'value' => (int)$this->_helper->getTagalysConfig("is_tsearchsuggestion_active")
35
- ));
36
-
37
- $fieldset->addField('search_box', 'text', array(
38
- 'label' => $this->__('Enter Search Box Selector'),
39
- 'required' => false,
40
- 'name' => 'search_box',
41
- 'value' => $this->_helper->getTagalysConfig("search_box"),
42
- 'disabled' => false,
43
- // 'readonly' => false,
44
- 'style' => "width:100%",
45
- 'after_element_html' => '<small> Please consult with your tech team or <a href="mailto:cs@tagalys.com">contact us</a>. <br> This can either be an ID or a Class Selector.<br> Eg: #search or .search-field </small>',
46
- 'tabindex' => 1
47
- ));
48
-
49
-
50
- $fieldset->addField('search_box_container', 'text', array(
51
- 'label' => $this->__('Enter Search Box Container'),
52
- 'required' => false,
53
- 'name' => 'search_box_container',
54
- 'value' => $this->_helper->getTagalysConfig("search_box_container"),
55
- 'disabled' => false,
56
- // 'readonly' => false,
57
- 'style' => "width:100%",
58
- 'after_element_html' => '<em>This is the element to which you want Tagalys suggestions box to be aligned with. This can either be the search input box itself or any container around it based on your design. If left blank, it will be aligned to the default search input box.</em><br><small> Please consult with your tech team or <a href="mailto:cs@tagalys.com">contact us</a>. <br> This can either be an ID or a Class Selector.<br> Eg: #search or .search-field </small>',
59
- 'tabindex' => 1
60
- ));
61
-
62
-
63
- $fieldset->addField('submit', 'submit', array(
64
- 'name' => 'submit_search_config',
65
- 'value' => 'Submit',
66
- 'class'=> "tagalys-btn",
67
- 'tabindex' => 1
68
- ));
69
-
70
- $fieldset->addField('ss_note', 'note', array(
71
- 'after_element_html' =>'<b> You need to disable Magento default search auto complete/suggestions. Please refer <a target="_blank" href="http://stackoverflow.com/questions/8688338/remove-magentos-search-suggest-feature">Link</a></b>'
72
- ));
73
-
74
- $this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')
75
- ->addFieldMap("{$htmlIdPrefix}is_tsearchsuggestion_active", 'is_tsearchsuggestion_active')
76
- ->addFieldMap("{$htmlIdPrefix}search_box", 'search_box')
77
- ->addFieldMap("{$htmlIdPrefix}search_box_container", 'search_box_container')
78
- ->addFieldDependence('search_box', 'is_tsearchsuggestion_active', '1')
79
- ->addFieldDependence('search_box_container', 'is_tsearchsuggestion_active', '1')
80
- );
81
-
82
- $this->setForm($form);
83
- return parent::_prepareForm();
84
- }
85
-
86
- /**
87
- * Tab label getter
88
- *
89
- * @return string
90
- */
91
- public function getTabLabel() {
92
- return $this->__('Settings');
93
- }
94
-
95
- /**
96
- * Tab title getter
97
- *
98
- * @return string
99
- */
100
- public function getTabTitle() {
101
- return $this->__('Settings');
102
- }
103
-
104
- /**
105
- * Check if tab can be shown
106
- *
107
- * @return bool
108
- */
109
- public function canShowTab() {
110
- return false;
111
- }
112
-
113
- /**
114
- * Check if tab hidden
115
- *
116
- * @return bool
117
- */
118
- public function isHidden() {
119
- return true;
120
- }
121
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tabs.php DELETED
@@ -1,120 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Core_Block_Adminhtml_Tagalys_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
4
- /**
5
- * Setting tab id, DOM destination element id, title
6
- */
7
- public function __construct() {
8
- parent::__construct();
9
- $this->setId('tagalys');
10
- $this->setDestElementId('edit_form');
11
- $this->setTitle($this->__('Tagalys'));
12
- $this->_helper = Mage::helper('tagalys_core');
13
-
14
- }
15
- protected function _beforeToHtml()
16
- {
17
- $status = Mage::helper('tagalys_core')->getTagalysConfig('setup_complete') && $this->_helper->getTagalysConfig("is_tagalys_active");
18
- if((int)$this->_helper->getTagalysConfig("is_signup")) {
19
- $this->setActiveTab('core');
20
- if((int)$this->_helper->getTagalysConfig("is_tagalys_active")) {
21
- $this->setActiveTab('setup');
22
- $stores_setup = $this->_helper->getTagalysConfig("stores_setup");
23
- if(!empty($stores_setup)) {
24
- $this->setActiveTab('sync');
25
- }
26
- }
27
- } else {
28
- $this->setActiveTab('general');
29
- }
30
- if($status && Mage::helper('core')->isModuleEnabled('Tagalys_SearchSuggestions')) {
31
- $this->setActiveTab('tagalys_tsearch_ss');
32
- }
33
- if($status && Mage::helper('core')->isModuleEnabled('Tagalys_Tsearch')) {
34
- $this->setActiveTab('tagalys_tsearch');
35
- }
36
- if($status && Mage::helper('core')->isModuleEnabled('Tagalys_MerchandisingPage')) {
37
- $this->setActiveTab('tagalys_merchandisingpage');
38
- }
39
- if($status && Mage::helper('core')->isModuleEnabled('Tagalys_SimilarProducts')) {
40
- $this->setActiveTab('tagalys_similarproducts');
41
- }
42
- return parent::_beforeToHtml();
43
- }
44
- /**
45
- * Preparing global layout
46
- *
47
- * @return Mage_Core_Block_Abstract
48
- */
49
- protected function _prepareLayout() {
50
- $status = Mage::helper('tagalys_core')->getTagalysConfig('setup_complete') && $this->_helper->getTagalysConfig("search_complete");
51
- $this->addTab('general', array(
52
- 'label' => $status ? $this->__('Account') : $this->__('Step 1 : Signup'),
53
- 'content' => $this->getLayout()->createBlock('tagalys_core/adminhtml_tagalys_edit_tab_signup')
54
- ->toHtml(),
55
- ));
56
-
57
- if((int)$this->_helper->getTagalysConfig("is_signup")) {
58
- $this->addTab('core', array(
59
- 'label' => $status ? $this->__('Credentials') : $this->__('Step 2 : Credentials'),
60
- 'content' => $this->getLayout()->createBlock('tagalys_core/adminhtml_tagalys_edit_tab_credentials')
61
- ->toHtml(),
62
- ));
63
-
64
- if((int)$this->_helper->getTagalysConfig("is_tagalys_active")) { //to-do
65
- $this->addTab('setup', array(
66
- 'label' => $status ? $this->__('Catalog Sync Settings') : $this->__('Step 3 : Initial Settings'),
67
- 'content' => $this->getLayout()->createBlock('tagalys_core/adminhtml_tagalys_edit_tab_setup')
68
- ->toHtml(),
69
- ));
70
- $stores_setup = $this->_helper->getTagalysConfig("stores_setup");
71
- if(!empty($stores_setup)) {
72
- $this->addTab('sync', array(
73
- 'label' => $status ? $this->__('Catalog Sync Status') : $this->__('Step 4 : Catalog Sync Status'),
74
- 'content' => $this->getLayout()->createBlock('tagalys_core/adminhtml_tagalys_edit_tab_sync')->toHtml(),
75
-
76
- ));
77
- }
78
- }
79
- }
80
- if($status && Mage::helper('core')->isModuleEnabled('Tagalys_SearchSuggestions')) {
81
- $this->addTab('tagalys_tsearch_ss', array(
82
- 'label' => $this->__('Search Suggestions Settings'),
83
- 'content' => $this->getLayout()->createBlock('tagalys_core/adminhtml_tagalys_edit_tab_tsearchsuggestion')
84
- ->toHtml()
85
- ));
86
- }
87
- if($status && Mage::helper('core')->isModuleEnabled('Tagalys_Tsearch')) {
88
- $this->addTab('tagalys_tsearch', array(
89
- 'label' => $this->__('Site Search Settings'),
90
- 'content' => $this->getLayout()->createBlock('tagalys_core/adminhtml_tagalys_edit_tab_tsearch')
91
- ->toHtml()
92
- ));
93
- }
94
- if($status && Mage::helper('core')->isModuleEnabled('Tagalys_MerchandisingPage')) {
95
- $this->addTab('tagalys_merchandisingpage', array(
96
- 'label' => $this->__('Merchandising Page Settings'),
97
- 'content' => $this->getLayout()->createBlock('tagalys_core/adminhtml_tagalys_edit_tab_merchandisingpage')
98
- ->toHtml()
99
- ));
100
- }
101
-
102
- if($status && Mage::helper('core')->isModuleEnabled('Tagalys_SimilarProducts')) {
103
- $this->addTab('tagalys_similarproducts', array(
104
- 'label' => $this->__('Similar Products Settings'),
105
- 'content' => $this->getLayout()->createBlock('tagalys_core/adminhtml_tagalys_edit_tab_similarproducts')
106
- ->toHtml()
107
- ));
108
- }
109
-
110
- if($stores_setup) {
111
- $this->addTab('tagalys_debug', array(
112
- 'label' => $this->__('Troubleshooting'),
113
- 'content' => $this->getLayout()->createBlock('tagalys_core/adminhtml_tagalys_edit_tab_debug')
114
- ->toHtml()
115
- ));
116
- }
117
-
118
- return parent::_prepareLayout();
119
- }
120
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Notifications.php DELETED
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Core_Block_Adminhtml_Tagalys_Notifications extends Mage_Adminhtml_Block_Template
4
- {
5
- public function _toHtml($className = "notification-global")
6
- {
7
- // Let other extensions add messages
8
- $html = null;
9
- Mage::dispatchEvent('tagalys_notifications_before');
10
- if(Mage::helper('tagalys_core')->getTagalysConfig('is_resync_needed')) {
11
- $message = "Please manually resync your products at Tagalys -> Configuration -> Catalog Sync Status -> Manual Resync";
12
- $html .= "<div class='$className'><strong class='label'>Tagalys Notice:</strong>" . $message . "</div>";
13
- }
14
-
15
- return $html;
16
- }
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Progress.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Core_Block_Adminhtml_Tagalys_Progress extends Varien_Data_Form_Element_Abstract {
4
- protected $_storeId;
5
-
6
- public function __construct($attributes = array())
7
- {
8
- $this->_storeId = $attributes['store_id'];
9
- parent::__construct($attributes);
10
- }
11
-
12
-
13
- public function getElementHtml() {
14
-
15
- $html = '
16
- <div class="tagalys-progress">
17
- <div class="tagalys-progress-bar" id="sync_store_'.$this->_storeId.'" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:100%">
18
- <div class="status sr-only">Please Wait ...</div>
19
- </div>
20
- <div class="row"><div id="sync_msg_'.$this->_storeId.'"></div></div>
21
- </div>';
22
-
23
- return $html;
24
- }
25
-
26
- public function getLabel() {
27
- return Mage::getModel('core/store')->load($this->_storeId)->getName();
28
- }
29
-
30
-
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/SearchReady.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Core_Block_Adminhtml_Tagalys_SearchReady extends Varien_Data_Form_Element_Abstract {
4
- protected $_storeId;
5
-
6
- public function __construct($attributes = array())
7
- {
8
- $this->_storeId = $attributes['store_id'];
9
- parent::__construct($attributes);
10
- }
11
- public function getElementHtml() {
12
-
13
-
14
- $html = '<div class="tagalys-progress">
15
- <div class="tagalys-progress-bar" id="search_store_'.$this->_storeId.'" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:100%">
16
- <div class="status sr-only">Please Wait ...</div>
17
- </div>
18
- <div class="row"><div id="search_msg_'.$this->_storeId.'"></div></div>
19
- </div>';
20
-
21
-
22
- return $html;
23
- }
24
-
25
- public function getLabel() {
26
- return Mage::getModel('core/store')->load($this->_storeId)->getName();
27
- }
28
- }
29
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Helper/Data.php DELETED
@@ -1,90 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Core_Helper_Data extends Mage_Core_Helper_Abstract {
4
-
5
- public function object_to_array($obj) {
6
- if(is_object($obj)) $obj = (array) $obj;
7
- if(is_array($obj)) {
8
- $new = array();
9
- foreach($obj as $key => $val) {
10
- $new[$key] = $this->object_to_array($val);
11
- }
12
- }
13
- else $new = $obj;
14
- return $new;
15
- }
16
-
17
-
18
- public function getTagalysConfig($config) {
19
- $configValue = Mage::getModel("tagalys_core/config")->getCollection()->addFieldToFilter('path',$config)->getFirstItem()->getData("value");
20
- return $configValue;
21
- }
22
-
23
- public function setTagalysConfig($config, $value) {
24
- $data = array('path' => $config,'value' => $value);
25
-
26
- $collection = Mage::getModel('tagalys_core/config')->getCollection()->addFieldToFilter('path',$config )->getFirstItem();
27
- if($id = $collection->getId()){
28
- $model = Mage::getModel('tagalys_core/config')->load($id)->addData($data);
29
- try {
30
- $model->setId($id)->save();
31
- } catch (Exception $e){
32
- Mage::log("TagalysControllerException".print_r($e->getMessage()), null, "tagalys-exception.log");
33
- }
34
-
35
- } else {
36
- $model = Mage::getModel("tagalys_core/config")->setData($data);
37
- try {
38
- $insertId = $model->save()->getId();
39
- } catch (Exception $e){
40
- Mage::log("TagalysControllerException".print_r($e->getMessage()), null, "tagalys-exception.log");
41
- }
42
- }
43
- }
44
-
45
-
46
- public function checkStoreInitSync($storeId) {
47
- $this->_helper = Mage::helper('tagalys_core');
48
- $status = $this->_helper->getTagalysConfig("sync-".$storeId);
49
- $stores = Mage::helper("sync/data")->getSelectedStore();
50
- $store_status = in_array($storeId, $stores);
51
- return $status && $store_status;
52
- }
53
-
54
- public function checkStoreIndex($storeId) {
55
- $this->_helper = Mage::helper('tagalys_core');
56
- $status = $this->_helper->getTagalysConfig("search_index_".$storeId);
57
- $stores = Mage::helper("sync/data")->getSelectedStore();
58
- $store_status = in_array($storeId, $stores);
59
- return $status && $store_status;
60
- }
61
-
62
- public function setupCompelete() {
63
- $selected_stores = Mage::helper("sync/data")->getSelectedStore();
64
- foreach ($selected_stores as $key => $value) {
65
- $store = $this->checkStoreIndex($value);
66
- if (!$store) {
67
- return false;
68
- }
69
- }
70
-
71
- return true;
72
- }
73
-
74
- public function getTimeZoneOffset(){
75
- $dateTimeZoneBase = new DateTimeZone(date_default_timezone_get());
76
- $dateTimeZoneOff = new DateTimeZone(Mage::getStoreConfig('general/locale/timezone'));
77
-
78
- $dateTimeBase = new DateTime("now", $dateTimeZoneBase);
79
- $dateTimeOff = new DateTime("now", $dateTimeZoneOff);
80
-
81
- $timeOffset = $dateTimeZoneOff->getOffset($dateTimeBase);
82
-
83
- if($timeOffset < 0) {
84
- $value ="-".date('g:i',-$timeOffset);
85
- } else {
86
- $value ="+".date('g:i',$timeOffset);
87
- }
88
- return $value;
89
- }
90
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Model/Config.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
- class Tagalys_Core_Model_Config extends Mage_Core_Model_Abstract
3
- {
4
- public function _construct()
5
- {
6
- parent::_construct();
7
- $this->_init("tagalys_core/config");
8
- }
9
-
10
- }
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Model/Mysql4/Config.php DELETED
@@ -1,8 +0,0 @@
1
- <?php
2
- class Tagalys_Core_Model_Mysql4_Config extends Mage_Core_Model_Mysql4_Abstract
3
- {
4
- protected function _construct()
5
- {
6
- $this->_init("tagalys_core/config","config_id");
7
- }
8
- }
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/Model/Observer.php DELETED
@@ -1,144 +0,0 @@
1
- <?php
2
- class Tagalys_Core_Model_Observer extends Varien_Object
3
- {
4
-
5
- public function tagalys_distpatch(Varien_Event_Observer $observer)
6
- {
7
- if(!Mage::helper('tagalys_core')->getTagalysConfig("is_tsearchsuggestion_active")) {
8
- return false;
9
- }
10
- $params = $observer->getEvent()->getControllerAction()->getRequest()->getParams();
11
- $tagalys_config_events = array('adminhtml_catalog_product_attribute_delete','adminhtml_catalog_product_attribute_save', 'adminhtml_system_currency_saveRates','adminhtml_system_currencysymbol_save');
12
- if(in_array ($observer->getEvent()->getControllerAction()->getFullActionName(), $tagalys_config_events))
13
- {
14
- Mage::dispatchEvent("tagalys_custom_config_event", array('request' => $observer->getControllerAction()->getRequest()));
15
- }
16
- if(in_array ($observer->getEvent()->getControllerAction()->getFullActionName(), array("adminhtml_catalog_category_save")))
17
- {
18
-
19
- $catid = $params["id"];
20
- $this->updateCategory($catid);
21
- }
22
- if($params["section"] == "currency") {
23
- Mage::dispatchEvent("tagalys_custom_config_event", array('request' => $observer->getControllerAction()->getRequest()));
24
- }
25
- }
26
-
27
- public function updateCategory($catid) {
28
- $this->_queue = Mage::getModel('sync/queue');
29
- try {
30
- $category = Mage::getModel('catalog/category')->setId($catid);
31
- $products = Mage::getResourceModel('catalog/product_collection')
32
- ->addCategoryFilter($category)
33
- ->getAllIds();
34
- if(!empty($products)) {
35
- foreach ($products as $key => $value) {
36
- $existingProduct = Mage::getModel('sync/queue')->load($value,'product_id');
37
- $_id = $existingProduct->getId();
38
- if(!isset($_id)) {
39
- $data = array(
40
- "product_id" => $value
41
- );
42
- $this->_queue->setData($data);
43
- $queue_id = $this->_queue->save()->getId();
44
- }
45
- }
46
- }
47
-
48
- return true;
49
-
50
- } catch (Exception $e) {
51
- Mage::log("Sync: ". $e->getMessage(), null, "tagalys.log");
52
- }
53
-
54
- }
55
-
56
- public function ValidateClientConfig() {
57
- // $config_data = $observer->getObject();
58
-
59
- $tagalys_response = $this->getTagalysConfig();
60
- if($tagalys_response["result"] != true ) {
61
- Mage::helper('tagalys_core')->setTagalysConfig('stores_setup', 0);
62
- $tagalys_response["message"] = empty($tagalys_response["message"]) ? "Something went wrong. Please write to us at cs@tagalys.com" : $tagalys_response["message"];
63
- Mage::getSingleton('core/session')->addError("NOTICE:". $tagalys_response["message"]);
64
- Mage::app()->getResponse()->setRedirect(Mage::helper("adminhtml")->getUrl("adminhtml/tagalys/index"));
65
- Mage::app()->getResponse()->sendResponse();
66
- exit;
67
- } else {
68
- $this->startInitialSync();
69
- return true;
70
- }
71
- // Mage::dispatchEvent('start_init_sync', array('object'=> []));
72
-
73
- }
74
-
75
- public function getTagalysConfig() {
76
-
77
- $service = Mage::getSingleton("sync/client");
78
- $this->_helper = Mage::helper("sync/service");
79
- $stores = Mage::helper("sync/data")->getSelectedStore();
80
- if (empty($stores)) {
81
- return false;
82
- }
83
- foreach ($stores as $key => $value) {
84
- $locale = Mage::getStoreConfig('general/locale/code', $value);
85
- $language= substr(Mage::getStoreConfig('general/locale/code', $value),0,2);
86
- $temp_currency_data = $this->_helper->getClientSetData();
87
- $client_config[] = array(
88
- "id" => $value,
89
- "label" => Mage::getModel('core/store')->load($value)->getName(),
90
- "locale" => $locale,
91
- "multi_currency_mode"=>"exchange_rate",
92
- "currencies" => $this->_helper->getClientCurrencyData(),
93
- "fields" => $temp_currency_data["fields"],
94
- "tag_sets" => $temp_currency_data["tag_set"],
95
- "sort_options" => $this->_helper->getClientSortOptions(),
96
- "products_count" => Mage::helper("sync/tagalysFeedFactory")->getTotal($value, true));
97
- }
98
-
99
-
100
- $tagalys_response = $service->notify_tagalys(array("stores" => $client_config), "client_config", true);//to-do
101
-
102
- if($tagalys_response["result"] == true) {
103
- if(!empty($tagalys_response["product_sync_required"])) {
104
- foreach ($tagalys_response["product_sync_required"] as $key => $value) {
105
- # code...
106
- Mage::helper('tagalys_core')->setTagalysConfig('product_sync_required_'.$key, (int)$value);
107
- }
108
-
109
- }
110
- }
111
- return $tagalys_response;
112
- }
113
-
114
- public function authClient(Varien_Event_Observer $observer) {
115
- $auth_data = $observer->getObject();
116
- $service = Mage::getSingleton("sync/client");
117
- $tagalys_response = $service->notify_tagalys($auth_data, "api_auth", true);//to-do
118
- if($tagalys_response["result"] != true ){ //to-do
119
- Mage::helper('tagalys_core')->setTagalysConfig('is_tagalys_active', 0);
120
- $tagalys_response["message"] = empty($tagalys_response["message"]) ? "Invalid Credentials. For any help, please write to us at cs@tagalys.com" : $tagalys_response["message"];
121
- Mage::getSingleton('core/session')->addError("NOTICE:".$tagalys_response["message"]);
122
- Mage::app()->getResponse()->setRedirect(Mage::helper("adminhtml")->getUrl("adminhtml/tagalys/index"));
123
- Mage::app()->getResponse()->sendResponse();
124
- exit;
125
- } else {
126
- Mage::helper('tagalys_core')->setTagalysConfig('is_tagalys_active', 1);
127
- Mage::getSingleton('core/session')->addSuccess("NOTICE: Tagalys Authentication Success");
128
-
129
- }
130
- return true;
131
- }
132
-
133
-
134
-
135
- public function startInitialSync(){
136
- $this->_sync_helper = Mage::helper("sync/data");
137
- foreach ($this->_sync_helper->getSelectedStore() as $key) {
138
- $response = Mage::helper("sync/tagalysFeedFactory")->getProductDump($key);
139
- }
140
- }
141
-
142
- }
143
-
144
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/etc/adminhtml.xml DELETED
@@ -1,17 +0,0 @@
1
- <?xml version="1.0"?>
2
-
3
- <config>
4
- <menu>
5
- <Tagalys translate="title" module="core">
6
- <title>Tagalys</title>
7
- <sort_order>100</sort_order>
8
- <children>
9
- <tagalys_core translate="title" module="core">
10
- <sort_order>10</sort_order>
11
- <title>Configuration</title>
12
- <action>adminhtml/tagalys/</action>
13
- </tagalys_core>
14
- </children>
15
- </Tagalys>
16
- </menu>
17
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/etc/config.xml DELETED
@@ -1,160 +0,0 @@
1
- <?xml version="1.0"?>
2
-
3
- <config>
4
- <modules>
5
- <Tagalys_Core>
6
- <version>0.2.0</version>
7
- </Tagalys_Core>
8
- </modules>
9
-
10
- <global>
11
- <events>
12
- <controller_action_postdispatch>
13
- <observers>
14
- <controller_action_after>
15
- <class>tagalys_core/observer</class>
16
- <method>tagalys_distpatch</method>
17
- </controller_action_after>
18
- </observers>
19
- </controller_action_postdispatch>
20
- <tagalys_custom_config_event>
21
- <observers>
22
- <tagalys_custom_config_event_handler>
23
- <type>singleton</type>
24
- <class>tagalys_core/observer</class>
25
- <method>getTagalysConfig</method>
26
- <args></args>
27
- </tagalys_custom_config_event_handler>
28
- </observers>
29
- </tagalys_custom_config_event>
30
- <tagalys_auth_event>
31
- <observers>
32
- <tagalys_auth_event_handler>
33
- <type>singleton</type>
34
- <class>tagalys_core/observer</class>
35
- <method>authClient</method>
36
- <args></args>
37
- </tagalys_auth_event_handler>
38
- </observers>
39
- </tagalys_auth_event>
40
- <start_init_sync>
41
- <observers>
42
- <start_init_sync_handler>
43
- <type>singleton</type>
44
- <class>tagalys_core/startInitialSync</class>
45
- <method>authClient</method>
46
- <args></args>
47
- </start_init_sync_handler>
48
- </observers>
49
- </start_init_sync>
50
- <tagalys_client_config>
51
- <observers>
52
- <tagalys_client_config_handler>
53
- <type>singleton</type>
54
- <class>tagalys_core/observer</class>
55
- <method>ValidateClientConfig</method>
56
- <args></args>
57
- </tagalys_client_config_handler>
58
- </observers>
59
- </tagalys_client_config>
60
- </events>
61
- <models>
62
- <tagalys_core>
63
- <class>Tagalys_Core_Model</class>
64
- <resourceModel>tagalys_core_mysql4</resourceModel>
65
- </tagalys_core>
66
- <tagalys_core_mysql4>
67
- <class>Tagalys_Core_Model_Mysql4</class>
68
- <entities>
69
- <config>
70
- <table>tagalys_core_config</table>
71
- </config>
72
- </entities>
73
- </tagalys_core_mysql4>
74
- </models>
75
-
76
- <resources>
77
- <tagalys_core_setup>
78
- <setup>
79
- <module>Tagalys_Core</module>
80
- </setup>
81
- <connection>
82
- <use>core_setup</use>
83
- </connection>
84
- </tagalys_core_setup>
85
- <tagalys_core_write>
86
- <connection>
87
- <use>core_write</use>
88
- </connection>
89
- </tagalys_core_write>
90
- <tagalys_core_read>
91
- <connection>
92
- <use>core_read</use>
93
- </connection>
94
- </tagalys_core_read>
95
- </resources>
96
-
97
- <blocks>
98
- <tagalys_core>
99
- <class>Tagalys_Core_Block</class>
100
- </tagalys_core>
101
- </blocks>
102
-
103
- <helpers>
104
- <tagalys_core>
105
- <class>Tagalys_Core_Helper</class>
106
- </tagalys_core>
107
- </helpers>
108
- </global>
109
-
110
- <admin>
111
- <routers>
112
- <adminhtml>
113
- <args>
114
- <modules>
115
- <tagalys_core before="Mage_Adminhtml">Tagalys_Core_Adminhtml_Tagalys</tagalys_core>
116
- </modules>
117
- </args>
118
- </adminhtml>
119
- </routers>
120
- </admin>
121
- <adminhtml>
122
- <!-- The <layout> updates allow us to define our block layouts in a separate file so are aren't messin' with the Magento layout files. -->
123
- <layout>
124
- <updates>
125
- <tagalys_core>
126
- <file>Tagalys_core.xml</file>
127
- </tagalys_core>
128
- </updates>
129
- </layout>
130
- <!-- The <acl> section is for access control. Here we define the pieces where access can be controlled within a role. -->
131
- <acl>
132
- <resources>
133
- <admin>
134
- <children>
135
- <tagalys_core>
136
- <title>Tagalys</title>
137
- <children>
138
- <example translate="title" module="tagalys_core">
139
- <title>Core</title>
140
- </example>
141
- </children>
142
- </tagalys_core>
143
- </children>
144
- </admin>
145
- </resources>
146
- </acl>
147
- </adminhtml>
148
- <crontab>
149
- <jobs>
150
- <tagalys_config_cron>
151
- <schedule>
152
- <cron_expr>0 1,13 * * *</cron_expr>
153
- </schedule>
154
- <run>
155
- <model>tagalys_core/observer::ValidateClientConfig</model>
156
- </run>
157
- </tagalys_config_cron>
158
- </jobs>
159
- </crontab>
160
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Core/sql/tagalys_core_setup/mysql4-install-0.2.0.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- $installer = $this;
3
- /* @var $installer Mage_Core_Model_Resource_Setup */
4
-
5
- $installer->startSetup();
6
-
7
- $installer->run("
8
-
9
- -- DROP TABLE IF EXISTS {$this->getTable('tagalys_core_config')};
10
- CREATE TABLE {$this->getTable('tagalys_core_config')} (
11
- `config_id` int(10) unsigned NOT NULL auto_increment,
12
- `path` varchar(255) NOT NULL default 'general',
13
- `value` text NOT NULL,
14
- PRIMARY KEY (`config_id`),
15
- UNIQUE KEY `config_scope` (`path`)
16
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
17
-
18
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Layer/Filter/Attribute.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- * Handles attribute filtering in layered navigation.
4
- *
5
- * @package Tagalys_Merchandising
6
- * @subpackage Tagalys_Merchandising_Block
7
- * @author Aaditya
8
- */
9
- class Tagalys_MerchandisingPage_Block_Catalog_Layer_Filter_Attribute extends Mage_Catalog_Block_Layer_Filter_Attribute
10
- {
11
- /**
12
- * Defines specific filter model name.
13
- *
14
- * @see Tagalys_Merchandising_Model_Catalog_Layer_Filter_Attribute
15
- */
16
- public function __construct()
17
- {
18
-
19
- parent::__construct();
20
-
21
- $this->_filterModelName = 'merchandisingpage/catalog_layer_filter_attribute';
22
- }
23
-
24
- /**
25
- * Prepares filter model.
26
- *
27
- * @return Tagalys_Merchandising_Block_Catalog_Layer_Filter_Attribute
28
- */
29
- protected function _prepareFilter()
30
- {
31
- $this->_filter->setAttributeModel($this->getAttributeModel());
32
-
33
- return $this;
34
- }
35
-
36
- /**
37
- * Adds facet condition to filter.
38
- *
39
- * @see Tagalys_Merchandising_Model_Catalog_Layer_Filter_Attribute::addFacetCondition()
40
- * @return Tagalys_Merchandising_Block_Catalog_Layer_Filter_Attribute
41
- */
42
- public function addFacetCondition()
43
- {
44
- // Mage::log("Tagalys_Merchandising_Block_Catalog_Layer_Filter_Attribute::addFacetCondition()",null,'debug.log');
45
- $this->_filter->addFacetCondition();
46
-
47
- return $this;
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Layer/Filter/Category.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
- /**
3
- * Handles category filtering in layered navigation.
4
- *
5
- * @package Tagalys_MerchandisingPage
6
- * @subpackage Tagalys_MerchandisingPage_Block
7
- * @author Tagalys
8
- */
9
- class Tagalys_MerchandisingPage_Block_Catalog_Layer_Filter_Category extends Mage_Catalog_Block_Layer_Filter_Category
10
- {
11
- /**
12
- * Defines specific filter model name.
13
- *
14
- * @see Tagalys_MerchandisingPage_Model_Catalog_Layer_Filter_Category
15
- */
16
- public function __construct()
17
- {
18
- parent::__construct();
19
- $this->_filterModelName = 'merchandisingpage/catalog_layer_filter_category';
20
- }
21
-
22
- /**
23
- * Adds facet condition to filter.
24
- *
25
- * @see Tagalys_MerchandisingPage_Model_Catalog_Layer_Filter_Category::addFacetCondition()
26
- * @return Tagalys_MerchandisingPage_Block_Catalog_Layer_Filter_Attribute
27
- */
28
- public function addFacetCondition()
29
- {
30
- $this->_filter->addFacetCondition();
31
-
32
- return $this;
33
- }
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Layer/Filter/Price.php DELETED
@@ -1,48 +0,0 @@
1
- <?php
2
- /**
3
- * Handles decimal attribute filtering in layered navigation.
4
- *
5
- * @package Tagalys_MerchandisingPage
6
- * @subpackage Tagalys_MerchandisingPage_Block
7
- * @author Tagalys
8
- */
9
- class Tagalys_MerchandisingPage_Block_Catalog_Layer_Filter_Price extends Mage_Catalog_Block_Layer_Filter_Price
10
- {
11
- /**
12
- * Defines specific filter model name.
13
- *
14
- * @see Tagalys_MerchandisingPage_Model_Catalog_Layer_Filter_Price
15
- */
16
- public function __construct()
17
- {
18
- parent::__construct();
19
- $this->_filterModelName = 'merchandisingpage/catalog_layer_filter_price';
20
- }
21
-
22
- /**
23
- * Prepares filter model.
24
- *
25
- * @return Tagalys_MerchandisingPage_Block_Catalog_Layer_Filter_Price
26
- */
27
- protected function _prepareFilter()
28
- {
29
- $this->_filter->setAttributeModel($this->getAttributeModel());
30
-
31
- return $this;
32
- }
33
-
34
- /**
35
- * Adds facet condition to filter.
36
- *
37
- * @see Tagalys_MerchandisingPage_Model_Catalog_Layer_Filter_Price::addFacetCondition()
38
- * @return Tagalys_MerchandisingPage_Block_Catalog_Layer_Filter_Price
39
- */
40
- public function addFacetCondition()
41
- {
42
- if (!$this->getRequest()->getParam('price')) {
43
- $this->_filter->addFacetCondition();
44
- }
45
-
46
- return $this;
47
- }
48
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Layer/State.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- class Tagalys_MerchandisingPage_Block_Catalog_Layer_State extends Mage_Catalog_Block_Layer_State
3
- {
4
- public function getActiveFilters()
5
- {
6
-
7
- $filters = $this->getLayer()->getFilters();
8
- if (!is_array($filters)) {
9
- $filters = array();
10
- }
11
- $filters = array();
12
- return $filters;
13
- }
14
-
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Layer/View.php DELETED
@@ -1,135 +0,0 @@
1
- <?php
2
- /**
3
- * Overrides default layer view process to define custom filter blocks.
4
- *
5
- * @package Tagalys_MerchandisingPage
6
- * @subpackage Tagalys_MerchandisingPage_Block
7
- * @author Tagalys
8
- */
9
- class Tagalys_MerchandisingPage_Block_Catalog_Layer_View extends Mage_Catalog_Block_Layer_View
10
- {
11
- /**
12
- * Boolean block name.
13
- *
14
- * @var string
15
- */
16
- protected $_booleanFilterBlockName;
17
- /**
18
- * Registers current layer in registry.
19
- *
20
- * @see Mage_Catalog_Block_Product_List::getLayer()
21
- */
22
- protected function _construct()
23
- {
24
- // die(var_dump('expression'));
25
- parent::_construct();
26
- Mage::unregister('current_layer');
27
- Mage::register('current_layer', $this->getLayer());
28
- }
29
- /**
30
- * Modifies default block names to specific ones if engine is active.
31
- */
32
- protected function _initBlocks()
33
- {
34
- parent::_initBlocks();
35
- if (Mage::helper('merchandisingpage')->isTagalysActive()) {
36
- $this->_categoryBlockName = 'merchandisingpage/catalog_layer_filter_category';
37
- $this->_attributeFilterBlockName = 'merchandisingpage/catalog_layer_filter_attribute';
38
- $this->_priceFilterBlockName = 'merchandisingpage/catalog_layer_filter_price';
39
- // $this->_booleanFilterBlockName = 'merchandisingpage/catalog_layer_filter_boolean';
40
- }
41
- }
42
- /**
43
- * Prepares layout if engine is active.
44
- * Difference between parent method is addFacetCondition() call on each created block.
45
- *
46
- * @return Tagalys_MerchandisingPage_Block_Catalog_Layer_View
47
- */
48
- protected function _prepareLayout()
49
- {
50
-
51
- if (Mage::helper('merchandisingpage')->isTagalysActive()) {
52
- $stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)
53
- ->setLayer($this->getLayer());
54
- $categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)
55
- ->setLayer($this->getLayer())
56
- ->init();
57
- $this->setChild('layer_state', $stateBlock);
58
- $this->setChild('category_filter', $categoryBlock->addFacetCondition());
59
- $filterableAttributes = $this->_getFilterableAttributes();
60
- $filters = array();
61
- foreach ($filterableAttributes as $attribute) {
62
-
63
- if ($attribute->getAttributeCode() == 'price') {
64
- $filterBlockName = $this->_priceFilterBlockName;
65
-
66
- } else {
67
- $filterBlockName = $this->_attributeFilterBlockName;
68
- }
69
-
70
- if(isset($filterBlockName)) {
71
- $filters[$attribute->getAttributeCode() . '_filter'] = $this->getLayout()->createBlock($filterBlockName)
72
- ->setLayer($this->getLayer())
73
- ->setAttributeModel($attribute)
74
- ->init();
75
- }
76
-
77
- }
78
- foreach ($filters as $filterName => $block) {
79
- // var_dump($filterName);
80
- $this->setChild($filterName, $block->addFacetCondition());
81
- }
82
- $this->getLayer()->apply();
83
- $this->getLayer()->getProductCollection()->load();
84
- } else {
85
- parent::_prepareLayout();
86
- }
87
- return $this;
88
- }
89
- public function getRequest(){
90
- $controller = Mage::app()->getFrontController();
91
- if ($controller) {
92
- $this->_request = $controller->getRequest();
93
- } else {
94
- throw new Exception(Mage::helper('core')->__("Can't retrieve request object"));
95
- }
96
- return $this->_request;
97
- }
98
- /**
99
- * Returns current catalog layer.
100
- *
101
- * @return Tagalys_MerchandisingPage_Model_Catalog_Layer|Mage_Catalog_Model_Layer
102
- */
103
- public function getLayer()
104
- {
105
-
106
- return parent::getLayer();
107
- }
108
- public function getFilters()
109
- {
110
- try {
111
- $filters = array();
112
- if ($categoryFilter = $this->_getCategoryFilter()) {
113
- $filters[] = $categoryFilter;
114
- }
115
- $filterableAttributes = $this->_getFilterableAttributes();
116
- foreach ($filterableAttributes as $attribute) {
117
- $filters[] = $this->getChild($attribute->getAttributeCode() . '_filter');
118
-
119
- }
120
- return $filters;
121
- } catch (Exception $e) {
122
- // die("die");
123
- var_dump($e);
124
- }
125
-
126
- }
127
- protected function _getFilterableAttributes(){
128
- if (Mage::helper('merchandisingpage')->isTagalysActive()) {
129
- $attributeModel = Mage::getResourceModel('catalog/product_attribute_collection')->getItems();
130
- return $attributeModel;
131
- }
132
- return parent::_getFilterableAttributes();
133
- }
134
-
135
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Product/List.php DELETED
@@ -1,48 +0,0 @@
1
- <?php
2
- class Tagalys_MerchandisingPage_Block_Catalog_Product_List extends Mage_Catalog_Block_Product_List
3
- {
4
- public function getLoadedProductCollection()
5
- {
6
- var_dump("asggag");
7
- return $this->_getProductCollection();
8
- }
9
-
10
- protected function _getProductCollection()
11
- {
12
-
13
- $tagalys = Mage::helper("merchandisingPage")->getTagalysSearchData();
14
-
15
- if($tagalys == false) {
16
-
17
-
18
- return parent::_getProductCollection();
19
-
20
- } else {
21
-
22
- $searchResult = $tagalys;
23
- // die(var_dump(empty($searchResult));
24
- if(empty($searchResult) || empty($searchResult["results"])) {
25
- return parent::_getProductCollection();
26
- }
27
-
28
- $collection = $this->_productCollection = Mage::getModel('catalog/product')
29
- ->getCollection()
30
- ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
31
- ->setStore(Mage::app()->getStore())
32
- ->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
33
- ->addAttributeToFilter( 'entity_id', array( 'in' => $searchResult['results'] ) );
34
-
35
- $orderString = array('CASE e.entity_id');
36
- foreach($searchResult['results'] as $i => $productId) {
37
- $orderString[] = 'WHEN '.$productId.' THEN '.$i;
38
- }
39
- $orderString[] = 'END';
40
- $orderString = implode(' ', $orderString);
41
-
42
- $collection->getSelect()->order(new Zend_Db_Expr($orderString));
43
-
44
- return $this->_productCollection;
45
-
46
- }
47
- }
48
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Product/List/Toolbar.php DELETED
@@ -1,95 +0,0 @@
1
- <?php
2
- class Tagalys_MerchandisingPage_Block_Catalog_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar {
3
-
4
- public function getAvailableOrders()
5
- {
6
- $tagalysData = Mage::helper("merchandisingpage")->getTagalysSearchData();
7
- if($tagalysData == false) {
8
- return $this->_availableOrder;
9
- } else {
10
- $sort_options = array();
11
- foreach ($tagalysData['sort_options'] as $key => $sort) {
12
- foreach ($sort as $key => $value) {
13
- foreach ($value as $field => $val) {
14
- $sort_options[$val["id"]] = $val['label'];
15
- }
16
- }
17
- }
18
- $sort_options = array();
19
- foreach ($tagalysData['sort_options'] as $key => $sort) {
20
- $sort_options[$sort["id"]] =$sort["label"];
21
- }
22
- $this->_availableOrder = $sort_options;
23
- return $this->_availableOrder;
24
- }
25
- }
26
- public function getLastPageNum() {
27
-
28
- $this->_pageSize = $this->getLimit();
29
- $tagalysData = Mage::helper("merchandisingpage")->getTagalysSearchData();
30
- if($tagalysData == false) {
31
- return parent::getLastPageNum();
32
- } else {
33
-
34
- $collectionSize = (int) $tagalysData["total"];
35
-
36
- if (0 === $collectionSize) {
37
- return 1;
38
- }
39
- elseif($this->_pageSize) {
40
- return ceil($collectionSize/$this->_pageSize);
41
- }
42
- else{
43
- return 1;
44
- }
45
- }
46
- }
47
-
48
- public function getTotalNum() {
49
- $tagalysData = Mage::helper("merchandisingpage")->getTagalysSearchData();
50
- if($tagalysData == false) {
51
- return parent::getTotalNum();
52
- } else {
53
- return (int) $tagalysData["total"];
54
- }
55
- }
56
-
57
- public function getLimit() {
58
- $current_list_mode = Mage::app()->getLayout()->createBlock('catalog/product_list_toolbar')->getCurrentMode();
59
-
60
- if( $current_list_mode == "grid" || $current_list_mode == "grid-list") {
61
- $defaultLimit = Mage::getStoreConfig('catalog/frontend/grid_per_page');
62
-
63
- } else if($current_list_mode == "list" || $current_list_mode == "list-grid") {
64
- $defaultLimit = Mage::getStoreConfig('catalog/frontend/list_per_page');
65
- }
66
- $session_limit = $this->getRequest()->getParam($this->getLimitVarName(), $this->getDefaultPerPageValue());
67
-
68
- !empty($session_limit) ? $session_limit : $defaultLimit;
69
- return !empty($session_limit) ? $session_limit : $defaultLimit;
70
- }
71
-
72
- public function getFirstNum()
73
- {
74
- $tagalysData = Mage::helper("merchandisingpage")->getTagalysSearchData();
75
- if($tagalysData == false) {
76
- return parent::getFirstNum();
77
- } else {
78
- $this->_pageSize = $this->getLimit();
79
- return $this->_pageSize*($this->getCurrentPage()-1)+1;
80
- }
81
- }
82
- public function getLastNum()
83
- {
84
- $tagalysData = Mage::helper("merchandisingpage")->getTagalysSearchData();
85
- if($tagalysData == false) {
86
- return parent::getLastNum();
87
- } else {
88
- $this->_pageSize = $this->getLimit();
89
- $blind_last_num = $this->getFirstNum() + $this->_pageSize - 1;
90
- $actual_last_num = min($blind_last_num, $tagalysData["total"]);
91
- return $actual_last_num;
92
- }
93
- }
94
-
95
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Block/Catalogsearch/Layer.php DELETED
@@ -1,32 +0,0 @@
1
-
2
-
3
- <?php
4
-
5
- class Tagalys_Tsearch_Block_Catalogsearch_Layer extends Tagalys_Tsearch_Block_Catalogsearch_Layer_View {
6
-
7
- protected function _initBlocks()
8
- {
9
- parent::_initBlocks();
10
-
11
- }
12
- public function canShowBlock() {
13
-
14
- $availableResCount = (int) Mage::app()->getStore()
15
- ->getConfig(Mage_CatalogSearch_Model_Layer::XML_PATH_DISPLAY_LAYER_COUNT);
16
-
17
- if (!$availableResCount || ($availableResCount >= $this->getLayer()->getProductCollection()->getSize())) {
18
- return parent::canShowBlock();
19
- }
20
- return false;
21
- }
22
-
23
- protected function createCategoriesBlock() {
24
-
25
- $categoryBlock = $this->getLayout()
26
- ->createBlock('tsearch/catalog_layer_filter_category')
27
- ->setLayer($this->getLayer())
28
- ->init();
29
- $this->setChild('category_filter', $categoryBlock);
30
- }
31
-
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Block/Catalogsearch/Layer/Filter/Attribute.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- /**
3
- * Handles attribute filtering in layered navigation in a query search context.
4
- *
5
- * @package Unbxd_Search
6
- * @subpackage Unbxd_Search_Block
7
- * @author Tagalys
8
- */
9
- class Tagalys_Tsearch_Block_Catalogsearch_Layer_Filter_Attribute extends Mage_Catalog_Block_Layer_Filter_Attribute
10
- {
11
- /**
12
- * Set filter model name
13
- *
14
- */
15
- public function __construct()
16
- {
17
- parent::__construct();
18
- $this->_filterModelName = 'tsearch/catalogsearch_layer_filter_attribute';
19
-
20
- }
21
- protected function _prepareFilter()
22
- {
23
- $this->_filter->setAttributeModel($this->getAttributeModel());
24
-
25
- return $this;
26
- }
27
-
28
- /**
29
- * Adds facet condition to filter.
30
- *
31
- * @see Tagalys_Tsearch_Model_Catalog_Layer_Filter_Attribute::addFacetCondition()
32
- * @return Tagalys_Tsearch_Block_Catalogsearch_Layer_Filter_Attribute
33
- */
34
- public function addFacetCondition()
35
- {
36
- $this->_filter->addFacetCondition();
37
- return $this;
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Block/Catalogsearch/Layer/View.php DELETED
@@ -1,145 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_MerchandisingPage_Block_Catalogsearch_Layer_View extends Mage_Catalog_Block_Layer_View {
4
-
5
- protected $_filterBlocks = null;
6
- protected $_helper = null;
7
- //to-do
8
- public function __construct() {
9
- parent::__construct();
10
- // $this->_helper = Mage::helper('layerednav');
11
-
12
- if (Mage::helper('tsearch')->isTagalysActive()) {
13
-
14
- $this->_categoryBlockName = 'tsearch/catalog_layer_filter_category';
15
- $this->_attributeFilterBlockName = 'tsearch/catalog_layer_filter_attribute';
16
- $this->_priceFilterBlockName = 'tsearch/catalog_layer_filter_price';
17
- // $this->_decimalFilterBlockName = 'tsearch/catalog_layer_filter_decimal';
18
- // $this->_booleanFilterBlockName = 'tsearch/catalog_layer_filter_boolean';
19
- } else {
20
- $this->_categoryBlockName = 'catalog/layer_filter_category';
21
- $this->_attributeFilterBlockName = 'catalog/layer_filter_attribute';
22
- $this->_priceFilterBlockName = 'catalog/layer_filter_price';
23
- }
24
- }
25
-
26
-
27
- public function getClearUrl()
28
- {
29
-
30
- $params['_current'] = true;
31
- $params['_use_rewrite'] = true;
32
- $params['_query'] = "q=".Mage::helper('catalogsearch')->getQuery()->getQueryText();
33
- $params['_escape'] = true;
34
-
35
- return Mage::getUrl('*/*/*', $params );
36
- }
37
-
38
- protected function _prepareLayout() {
39
- // $_hlp = $this->_helper;
40
- // Return an object of current category
41
- $category = Mage::registry('current_category');
42
-
43
- if ($category) {
44
- $currentCategoryID = $category->getId();
45
- } else {
46
- $currentCategoryID = null;
47
- }
48
-
49
- // Return session object
50
- $sessionObject = Mage::getSingleton('catalog/session');
51
- if ($sessionObject AND $lastCategoryID = $sessionObject->getLastCatgeoryID()) {
52
- if ($currentCategoryID != $lastCategoryID) {
53
- Mage::register('new_category', true);
54
- }
55
- }
56
- $sessionObject->setLastCatgeoryID($currentCategoryID);
57
-
58
- //Create Category Blocks
59
- $stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)
60
- ->setLayer($this->getLayer());
61
-
62
- $categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)
63
- ->setLayer($this->getLayer())
64
- ->init();
65
-
66
-
67
- $this->setChild('layer_state', $stateBlock);
68
- $this->setChild('category_filter', $categoryBlock);
69
- // $this->createCategoriesBlock();
70
-
71
- // preload setting
72
- // $this->setIsRemoveLinks($_hlp->removeLinks());
73
-
74
- //Get $this->_getFilterableAttributes() Mage_Catalog_Block_Layer_View
75
- $filterableAttributes = $this->_getFilterableAttributes();
76
-
77
-
78
- $blocks = array();
79
- foreach ($filterableAttributes as $attribute) {
80
-
81
- $blockType = $this->_attributeFilterBlockName;
82
-
83
- if ($attribute->getAttributeCode() == 'price') {
84
- $blockType = $this->_priceFilterBlockName;
85
- }
86
-
87
- $name = $attribute->getAttributeCode() . '_filter';
88
-
89
- $blocks[$name] = $this->getLayout()->createBlock($blockType)
90
- ->setLayer($this->getLayer())
91
- ->setAttributeModel($attribute);
92
-
93
- $this->setChild($name, $blocks[$name]);
94
- }
95
-
96
- foreach ($blocks as $name => $block) {
97
- $block->init();
98
- }
99
- $this->getLayer()->apply();
100
- return Mage_Core_Block_Template::_prepareLayout();
101
- }
102
-
103
-
104
- public function getLayer() {
105
- if (!Mage::helper('tsearch')->isTagalysActive()) {
106
- return Mage::getSingleton('catalogsearch/layer');
107
- }
108
- return parent::getLayer();
109
- }
110
-
111
- protected function createCategoriesBlock() {
112
-
113
-
114
-
115
- $categoryBlock = $this->getLayout()
116
- ->createBlock("tsearch/catalog_layer_filter_category")
117
- ->setLayer($this->getLayer())
118
- ->init();
119
- $this->setChild('category_filter', $categoryBlock);
120
- }
121
-
122
- public function getFilters() {
123
- if (is_null($this->_filterBlocks)) {
124
- $this->_filterBlocks = parent::getFilters();
125
- }
126
- return $this->_filterBlocks;
127
- }
128
-
129
- protected function _toHtml() {
130
- $html = parent::_toHtml();
131
- if (!Mage::app()->getRequest()->isXmlHttpRequest()) {
132
- $html = '<div id="catalog-filters">' . $html . '</div>';
133
- }
134
- return $html;
135
- }
136
- protected function _getFilterableAttributes(){
137
- if (Mage::helper('tsearch')->isTagalysActive()) {
138
- $attributeModel = Mage::getResourceModel('catalog/product_attribute_collection')->getItems();
139
- return $attributeModel;
140
- }
141
- return parent::_getFilterableAttributes();
142
- }
143
-
144
- }
145
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Block/Catalogsearch/Result.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
-
3
-
4
- class Tagalys_Tsearch_Block_Catalogsearch_Result extends Mage_CatalogSearch_Block_Result
5
- {
6
-
7
- public function setListCollection()
8
- {
9
- $this->getListBlock()
10
- ->setCollection($this->_getProductCollection());
11
- return $this;
12
- }
13
- /**
14
- * Retrieve loaded category collection
15
- *
16
- * @return Mage_CatalogSearch_Model_Mysql4_Fulltext_Collection
17
- */
18
- protected function _getProductCollection()
19
- {
20
-
21
- if (is_null($this->_productCollection)) {
22
- //$this->_productCollection = $this->getListBlock()->getLoadedProductCollection();
23
- $this->_productCollection = Mage::getSingleton('catalogsearch/layer')->getProductCollection();
24
- }
25
-
26
- return $this->_productCollection;
27
- }
28
-
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Block/Filter.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
- /**
3
- * Merchanding Page Filter Helper
4
- */
5
-
6
- class Tagalys_MerchandisingPage_Block_Filter extends Mage_Core_Block_Template
7
- {
8
- protected function _construct()
9
- {
10
- // die('asdfus');
11
- // $this->setTemplate('catalog/layer/filter.phtml');
12
- }
13
-
14
- protected function _toHtml() {
15
- return parent::_toHtml();
16
- }
17
-
18
- public function canShowBlock() {
19
- return true;
20
- }
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Block/Page/Html/Pager.php DELETED
@@ -1,156 +0,0 @@
1
- <?php
2
- class Tagalys_MerchandisingPage_Block_Page_Html_Pager extends Mage_Page_Block_Html_Pager {
3
-
4
- public function getLastPageNum() {
5
- $this->_pageSize = $this->getLimit();
6
- $tagalysData = Mage::helper("merchandisingpage")->getTagalysSearchData();
7
- if($tagalysData == false) {
8
- return parent::getLastPageNum();
9
- } else {
10
- $collectionSize = (int) $tagalysData["total"];
11
-
12
- if (0 === $collectionSize) {
13
- return 1;
14
- }
15
- elseif($this->_pageSize) {
16
- return ceil($collectionSize/$this->_pageSize);
17
- }
18
- else {
19
- return 1;
20
- }
21
- }
22
- }
23
-
24
- public function getTotalNum() {
25
- $tagalysData = Mage::helper("merchandisingpage")->getTagalysSearchData();
26
- if($tagalysData == false) {
27
- return parent::getTotalNum();
28
- } else {
29
- return (int) $tagalysData["total"];
30
- }
31
- }
32
-
33
- public function getLimit() {
34
- $current_list_mode = Mage::app()->getLayout()->createBlock('catalog/product_list_toolbar')->getCurrentMode();
35
-
36
- if( $current_list_mode == "grid" || $current_list_mode == "grid-list") {
37
- $defaultLimit = Mage::getStoreConfig('catalog/frontend/grid_per_page');
38
-
39
- } else if($current_list_mode == "list" || $current_list_mode == "list-grid") {
40
- $defaultLimit = Mage::getStoreConfig('catalog/frontend/list_per_page');
41
- }
42
-
43
- $session_limit = $this->getRequest()->getParam($this->getLimitVarName(), $this->getDefaultPerPageValue());
44
-
45
- !empty($session_limit) ? $session_limit : $defaultLimit;
46
- return !empty($session_limit) ? $session_limit : $defaultLimit;
47
- }
48
-
49
- public function getPages()
50
- {
51
- $collection = $this->getCollection();
52
-
53
- $pages = array();
54
- if ($this->getLastPageNum() <= $this->_displayPages) {
55
- $pages = range(1, $this->getLastPageNum());
56
- }
57
- else {
58
- $half = ceil($this->_displayPages / 2);
59
- if ($collection->getCurPage() >= $half
60
- && $collection->getCurPage() <= $this->getLastPageNum() - $half
61
- ) {
62
- $start = ($collection->getCurPage() - $half) + 1;
63
- $finish = ($start + $this->_displayPages) - 1;
64
- }
65
- elseif ($collection->getCurPage() < $half) {
66
- $start = 1;
67
- $finish = $this->_displayPages;
68
- }
69
- elseif ($collection->getCurPage() > ($this->getLastPageNum() - $half)) {
70
- $finish = $this->getLastPageNum();
71
- $start = $finish - $this->_displayPages + 1;
72
- }
73
-
74
- $pages = range($start, $finish);
75
- }
76
- return $pages;
77
- }
78
-
79
- protected function _initFrame()
80
- {
81
- if (!$this->isFrameInitialized()) {
82
- $start = 0;
83
- $end = 0;
84
-
85
- //$collection = $this->getCollection();
86
- if ($this->getLastPageNum() <= $this->getFrameLength()) {
87
- $start = 1;
88
- $end = $this->getLastPageNum();
89
- }
90
- else {
91
- $half = ceil($this->getFrameLength() / 2);
92
- if ($this->getCurrentPage() >= $half && $this->getCurrentPage() <= $this->getLastPageNum() - $half) {
93
- $start = ($this->getCurrentPage() - $half) + 1;
94
- $end = ($start + $this->getFrameLength()) - 1;
95
- }
96
- elseif ($this->getCurrentPage() < $half) {
97
- $start = 1;
98
- $end = $this->getFrameLength();
99
- }
100
- elseif ($this->getCurrentPage() > ($this->getLastPageNum() - $half)) {
101
- $end = $this->getLastPageNum();
102
- $start = $end - $this->getFrameLength() + 1;
103
- }
104
- //$start = 1;
105
- //$end = $this->getLastPageNum() - abs($this->getLastPageNum() - $this->getFrameLength());
106
-
107
- }
108
- $this->_frameStart = $start;
109
- $this->_frameEnd = $end;
110
-
111
- $this->_setFrameInitialized(true);
112
- }
113
-
114
- return $this;
115
- }
116
-
117
- public function getFramePages()
118
- {
119
- $start = $this->getFrameStart();
120
-
121
- $end = $this->getFrameEnd();
122
-
123
- return range($start, $end);
124
- }
125
-
126
- public function getCurrentPage()
127
- {
128
- return (int) $this->getRequest()->getParam($this->getPageVarName(), 1);
129
- }
130
-
131
- public function getPreviousPageUrl()
132
- {
133
- return $this->getPageUrl($this->getCurrentPage() - 1);
134
- }
135
-
136
- public function getNextPageUrl()
137
- {
138
- return $this->getPageUrl($this->getCurrentPage() + 1);
139
- }
140
- public function getFirstPageUrl()
141
- {
142
- return $this->getPageUrl($this->getLastPageNum());
143
- }
144
- public function getLastPageUrl()
145
- {
146
- return $this->getPageUrl($this->getLastPageNum());
147
- }
148
- public function isFirstPage()
149
- {
150
- return $this->getCurrentPage() == 1;
151
- }
152
- public function isLastPage()
153
- {
154
- return $this->getCurrentPage() == $this->getLastPageNum();
155
- }
156
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Helper/Data.php DELETED
@@ -1,203 +0,0 @@
1
- <?php
2
- /**
3
- * Merchandising Page Helper
4
- */
5
- class Tagalys_MerchandisingPage_Helper_Data extends Mage_Core_Helper_Abstract {
6
-
7
- public function getMerchandisingData() {
8
- $service = Mage::getModel("Tagalys_MerchandisingPage_Model_Client");
9
- // die(var_dump($service));
10
- $query = Mage::app()->getRequest()->getParam('q');
11
- $q = Mage::app()->getRequest();
12
-
13
- $request = array();
14
- $request = $q->getParams();
15
- $request['filters'] = true;
16
- $request['q'] = $request['product'];
17
-
18
- $payload = $request;
19
- $entity = 'catalog_product';
20
-
21
- $current_list_mode = Mage::app()->getLayout()->createBlock('catalog/product_list_toolbar')->setChild('product_list_toolbar_pager', $pager)->getCurrentMode();
22
-
23
- if( $current_list_mode == "grid" || $current_list_mode == "grid-list") {
24
- $defaultLimit = Mage::getStoreConfig('catalog/frontend/grid_per_page');
25
-
26
- } else if($current_list_mode == "list" || $current_list_mode == "list-grid") {
27
- $defaultLimit = Mage::getStoreConfig('catalog/frontend/list_per_page');
28
- }
29
-
30
- $payload['filters'] = true;
31
-
32
- $session_limit = $request['limit']; //Mage::getSingleton('catalog/session')->getLimitPage();
33
-
34
- $payload['per_page'] = (!empty($session_limit) ? $session_limit : $defaultLimit);
35
- $payload['page'] = (!empty($request['p'])) ? $request['p'] : 1;
36
- // $payload['per_page'] = (!empty($session_limit) ? $session_limit : $defaultLimit) * ($payload['page'] + 1);
37
- // if($payload['page'] == 1) {
38
- // $payload['per_page'] = (!empty($session_limit) ? $session_limit : $defaultLimit) * 2;
39
- // } else {
40
- // $payload['per_page'] = (!empty($session_limit) ? $session_limit : $defaultLimit) ;
41
- // }
42
- foreach ($request as $key => $value) {
43
-
44
- $code = $key;
45
- $attr = Mage::getResourceModel('catalog/eav_attribute')
46
- ->loadByCode($entity,$code);
47
-
48
- if ($attr->getId()) {
49
- $filters[$key] = array($request[$key]);
50
- }
51
-
52
- }
53
-
54
- if(isset($request["cat"])) {
55
- $filters["__categories"] = array($request["cat"]);
56
- // $payload["f"] = $category;
57
- }
58
- if(isset($request["min"]) && isset($request["max"])) {
59
- $filters["price"] = array("min" => $request["min"], "max" => $request["max"] );
60
- }
61
- if(!empty($filters)) {
62
- $payload["f"] = ($filters);
63
- }
64
-
65
- //$payload['filters'] = true;
66
- $payload['request'] = array("variables","url_component","results","sort_options","filters","total");
67
- $payload["store"] = Mage::app()->getStore()->getStoreId();
68
-
69
- //by aaditya
70
- if(isset($request['order'])) {
71
- $payload['sort'] = $request['order']."-".$request['dir'];
72
- // $payload['order'] = $request['dir'];
73
- } else {
74
- $payload['sort'] = $payload['sort']; //Mage::getSingleton('catalog/session')->getSortOrder();
75
- }
76
- $user_id = "";
77
- $request["seed"] = "";
78
- if (Mage::getSingleton('customer/session')->isLoggedIn()) {
79
- $customer = Mage::getSingleton('customer/session')->getCustomer();
80
- $user_id = $customer->getID();
81
- }
82
-
83
- $device_id = Mage::getModel('core/cookie')->get('__ta_device');
84
- $visitor_id = Mage::getModel('core/cookie')->get('__ta_visit');
85
-
86
- if (isset($payload)) {
87
- $payload['user'] = (array("ip" => Mage::helper('core/http')->getRemoteAddr(), "snapshot" => $request["snapshot"] , "visitor_id" => $visitor_id, "user_id" => $user_id , "device_id" => $device_id));
88
- }
89
-
90
- unset($payload['isAjax']);
91
-
92
- unset($payload['limit']);
93
- unset($payload['product']);
94
- unset($payload['dir']);
95
- unset($payload['order']);
96
-
97
-
98
- return $service->merchandisingPage($payload);
99
- }
100
-
101
-
102
- public function getTagalysSearchData() {
103
- $controllerModule = Mage::app()->getRequest()->getControllerModule();
104
- if($controllerModule == 'Tagalys_MerchandisingPage') {
105
- $service = Mage::getSingleton("merchandisingpage/client");
106
- } else {
107
- $service = Mage::getSingleton("tsearch/client_connector");
108
- }
109
- if($this->isTagalysActive()) {
110
- $searchResult = $service->getSearchResult();
111
- // die(var_dump($searchResult));
112
- if ($searchResult == null || ( isset($searchResult["status"]) && $searchResult["status"] != "OK")) {
113
- return false;
114
- } else {
115
-
116
- return $searchResult;
117
- }
118
- } else {
119
- return false;
120
- }
121
-
122
- }
123
-
124
- public function isTagalysActive() {
125
-
126
- $status = Mage::helper('tagalys_core')->getTagalysConfig("is_merchandising_page_active");
127
-
128
- if ($status) {
129
- $service = Mage::getSingleton("merchandisingpage/client");
130
- // $tagalys = $service->isRequestSuccess();
131
- if($service) {
132
- return true;
133
- } else {
134
- return false;
135
- }
136
- } else {
137
- return false;
138
- }
139
- // return true;
140
- }
141
-
142
- public function getTagalysFilter() {
143
- $result = Mage::helper('merchandisingpage')->getTagalysSearchData();
144
- if ($result) {
145
- $data = $result;
146
- $filters = (!empty($data['filters'])) ? $data['filters'] : null ;
147
- return $filters;
148
- }
149
- return false;
150
- }
151
-
152
- public function getAttributeFieldName($attribute, $localeCode = null)
153
- {
154
- // Mage::log($attribute,null,'debug.log');
155
-
156
- if (is_string($attribute)) {
157
- $this->getSearchableAttributes(); // populate searchable attributes if not already set
158
- if (!isset($this->_searchableAttributes[$attribute])) {
159
- return $attribute;
160
- }
161
- $attribute = $this->_searchableAttributes[$attribute];
162
- }
163
- $attributeCode = $attribute->getAttributeCode();
164
- $backendType = $attribute->getBackendType();
165
-
166
- return $attributeCode;
167
- }
168
-
169
- public function getSearchParam($attribute, $value)
170
- {
171
- if (empty($value) ||
172
- (isset($value['from']) && empty($value['from']) &&
173
- isset($value['to']) && empty($value['to']))) {
174
- return false;
175
- }
176
-
177
- $field = $this->getAttributeFieldName($attribute);
178
- $backendType = $attribute->getBackendType();
179
- if ($backendType == 'datetime') {
180
- $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
181
- if (is_array($value)) {
182
- foreach ($value as &$val) {
183
- if (!is_empty_date($val)) {
184
- $date = new Zend_Date($val, $format);
185
- $val = $date->toString(Zend_Date::ISO_8601) . 'Z';
186
- }
187
- }
188
- unset($val);
189
- } else {
190
- if (!is_empty_date($value)) {
191
- $date = new Zend_Date($value, $format);
192
- $value = $date->toString(Zend_Date::ISO_8601) . 'Z';
193
- }
194
- }
195
- }
196
-
197
- if ($attribute->usesSource()) {
198
- $attribute->setStoreId(Mage::app()->getStore()->getId());
199
- }
200
-
201
- return array($field => $value);
202
- }
203
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Model/Catalog/Layer.php DELETED
@@ -1,62 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_MerchandisingPage_Model_Catalog_Layer extends Mage_Catalog_Model_Layer
4
- {
5
-
6
- protected $_facetsConditions = array();
7
-
8
- public function getProductCollection()
9
- {
10
- try {
11
- $tagalysSearchResults = Mage::helper('merchandisingpage')->getTagalysSearchData();
12
-
13
- if($tagalysSearchResults == false) {
14
-
15
- return parent::getProductCollection();
16
- } else {
17
- if(empty($tagalysSearchResults)) {
18
- return parent::getProductCollection();
19
- }
20
-
21
- $collection = $this->_productCollection = Mage::getModel('catalog/product')
22
- ->getCollection()
23
- ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
24
- ->setStore(Mage::app()->getStore())
25
- ->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
26
- ->addAttributeToFilter( 'entity_id', array( 'in' => $tagalysSearchResults['results'] ) );
27
-
28
- $orderString = array('CASE e.entity_id');
29
-
30
- foreach($tagalysSearchResults['results'] as $i => $productId) {
31
- $orderString[] = 'WHEN '.$productId.' THEN '.$i;
32
- }
33
- $orderString[] = 'END';
34
- $orderString = implode(' ', $orderString);
35
-
36
- $collection->getSelect()->order(new Zend_Db_Expr($orderString));
37
-
38
- return $this->_productCollection;
39
-
40
- }
41
- } catch(Exception $e) {
42
-
43
- return parent::getProductCollection();
44
- }
45
- }
46
-
47
- public function addFacetCondition($field, $condition = null)
48
- {
49
-
50
- if (array_key_exists($field, $this->_facetsConditions)) {
51
- if (!empty($this->_facetsConditions[$field])){
52
- $this->_facetsConditions[$field] = array($this->_facetsConditions[$field]);
53
- }
54
- $this->_facetsConditions[$field][] = $condition;
55
- } else {
56
- $this->_facetsConditions[$field] = $condition;
57
- }
58
-
59
- return $this;
60
- }
61
-
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Model/Catalog/Layer/Filter/Attribute.php DELETED
@@ -1,166 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_MerchandisingPage_Model_Catalog_Layer_Filter_Attribute extends Mage_Catalog_Model_Layer_Filter_Attribute {
4
- const OPTIONS_ONLY_WITH_RESULTS = 1;
5
- const MULTI_SELECT_FACET_SPLIT = '-';
6
-
7
- public function addFacetCondition() {
8
-
9
- $this->getLayer()
10
- // ->getProductCollection()
11
- ->addFacetCondition($this->_getFilterField());
12
- return $this;
13
- }
14
-
15
- public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
16
- {
17
- $filter = $request->getParam($this->_requestVar);
18
- //aadi
19
-
20
- $request = Mage::app()->getRequest()->getParams();
21
- if (!empty($request["qf"])) {
22
- foreach (explode("~", $request["qf"]) as $key => $value) {
23
-
24
- $temp = explode("-", $value);
25
- if($temp[0] == $this->_requestVar) {
26
-
27
- $temp_val = explode("-", $value);
28
- $filter = $temp_val[1];
29
-
30
- }
31
- # code...
32
- }
33
- }
34
- //aadi end
35
- if (is_array($filter)) {
36
- return $this;
37
- }
38
- $text = $this->_getOptionText($filter);
39
- if ($filter && strlen($text)) {
40
- $this->_getResource()->applyFilterToCollection($this, $filter);
41
- $this->getLayer()->getState()->addFilter($this->_createItem($text, $filter));
42
- $this->_items = array();
43
- }
44
- return $this;
45
- }
46
-
47
- public function applyFilterToCollection($filter, $value) {
48
- if(!is_array($value)) {
49
- return $this;
50
- }
51
- $attribute = $filter->getAttributeModel();
52
- $param = Mage::helper('merchandisingpage')->getSearchParam($attribute, $value);
53
-
54
- $this->getLayer()
55
- ->getProductCollection();
56
- return $this;
57
- }
58
-
59
- /**
60
- * Returns facets data of current attribute.
61
- *
62
- * @return array
63
- */
64
- protected function _getFacets() {
65
- /** @var $productCollection Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection */
66
- $productCollection = $this->getLayer()->getProductCollection();
67
- $fieldName = $this->_getFilterField();
68
- $facets = $productCollection;
69
- return $facets;
70
- }
71
-
72
-
73
- public function getMaxPriceInt() {
74
- $priceStat = Mage::getSingleton('tagalys_merchandisingpage/catalog_layer')->getProductCollection()->getStats('price');
75
- $productCollection = $this->getLayer()->getProductCollection();
76
- return isset($priceStat["max"])?$priceStat["max"]:0;
77
- }
78
-
79
-
80
- /**
81
- * Returns attribute field name.
82
- *
83
- * @return string
84
- */
85
- protected function _getFilterField() {
86
-
87
- /** @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
88
- // Mage::log("Tagalys_Tsearch_Model_Catalog_Layer_Filter_Attribute::_getFilterField()",null,'debug.log');
89
- $attribute = $this->getAttributeModel();
90
- $fieldName = Mage::helper('merchandisingpage')->getAttributeFieldName($attribute);
91
-
92
- return $fieldName;
93
- }
94
-
95
- /**
96
- * Retrieves current items data.
97
- *
98
- * @return array
99
- */
100
-
101
- protected function _getItemsData() {
102
- $attribute = $this->getAttributeModel();
103
- $this->_requestVar = $attribute->getAttributeCode();
104
-
105
- $key = $this->getLayer()->getStateKey().'_'.$this->_requestVar;
106
- $data = $this->getLayer()->getAggregator()->getCacheData($key);
107
-
108
- if ($data === null) {
109
- $filters = $attribute->getFrontend()->getSelectOptions();
110
- $service = Mage::getSingleton("Tagalys_MerchandisingPage_Model_Client");
111
-
112
- $tagalys = Mage::helper('merchandisingpage')->getTagalysSearchData();
113
- // $service = Mage::getModel("Tagalys_MerchandisingPage_Model_Client");
114
- // $tagalys = $service->merchandisingPage(array());
115
- // die(var_dump($tagalys));
116
- $filters = $tagalys["filters"];
117
- $optionsCount = count($filters);
118
- $data = array();
119
- foreach ($filters as $filter) {
120
- if (!empty($filter['items'])) {
121
- // Check filter type
122
- if ($this->_getIsFilterableAttribute($attribute) == self::OPTIONS_ONLY_WITH_RESULTS && $this->_requestVar == $filter['id'] ) {
123
- foreach ($filter["items"] as $filterItem) {
124
- if ($filterItem["count"]) {
125
- $data[] = array(
126
- 'label' => $filterItem["name"],
127
- 'value' => $filterItem["id"], //$filterItem["id"],
128
- 'count' => $filterItem["count"],
129
- );
130
- }
131
- }
132
- }
133
- }
134
- }
135
-
136
- $tags = array(
137
- Mage_Eav_Model_Entity_Attribute::CACHE_TAG.':'.$attribute->getId()
138
- );
139
-
140
- $tags = $this->getLayer()->getStateTags($tags);
141
- $this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
142
- }
143
- return $data;
144
- }
145
-
146
- protected function _getOptionText($optionId) {
147
- if ($this->getAttributeModel()->getFrontendInput() == 'text') {
148
- return $optionId;
149
- }
150
-
151
- return parent::_getOptionText($optionId);
152
- }
153
-
154
- protected function getLabel($optionId) {
155
- if ($this->getAttributeModel()->getFrontendInput() == 'text') {
156
- return $optionId;
157
- }
158
-
159
- return parent::_getOptionText($optionId);
160
- }
161
-
162
- protected function _isValidFilter($filter) {
163
- return !empty($filter);
164
- }
165
-
166
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Model/Catalog/Layer/Filter/Category.php DELETED
@@ -1,103 +0,0 @@
1
- <?php
2
- /**
3
- * Handles category filtering in layered navigation.
4
- *
5
- * @package Tagalys_Tsearch
6
- * @subpackage Tagalys_Tsearch_Model
7
- * @author Tagalys
8
- */
9
- class Tagalys_MerchandisingPage_Model_Catalog_Layer_Filter_Category extends Mage_Catalog_Model_Layer_Filter_Category
10
- {
11
- /**
12
- * Adds category filter to product collection.
13
- *
14
- * @param Mage_Catalog_Model_Category $category
15
- * @return Tagalys_Tsearch_Model_Catalog_Layer_Filter_Category
16
- */
17
- public function addCategoryFilter($category)
18
- {
19
- $value = array(
20
- 'categories' => $category->getId()
21
- );
22
- $this->getLayer()->getProductCollection()
23
- ->addFqFilter($value);
24
-
25
- return $this;
26
- }
27
-
28
- /**
29
- * Adds facet condition to product collection.
30
- *
31
- * @see Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection::addFacetCondition()
32
- * @return Tagalys_Tsearch_Model_Catalog_Layer_Filter_Category
33
- */
34
- public function addFacetCondition()
35
- {
36
- /** @var $category Mage_Catalog_Model_Category */
37
- $category = $this->getCategory();
38
- $childrenCategories = $category->getChildrenCategories();
39
-
40
- $useFlat = (bool) Mage::getStoreConfig('catalog/frontend/flat_catalog_category');
41
- $categories = ($useFlat)
42
- ? array_keys($childrenCategories)
43
- : array_keys($childrenCategories->toArray());
44
-
45
- $this->getLayer()->getProductCollection();
46
-
47
- return $this;
48
- }
49
-
50
-
51
-
52
- protected function _getItemsData()
53
- {
54
- $key = $this->getLayer()->getStateKey().'_SUBCATEGORIES';
55
- $data = $this->getLayer()->getAggregator()->getCacheData($key);
56
-
57
- if ($data === null) {
58
- $tagalys = Mage::helper('merchandisingpage')->getTagalysSearchData();
59
- // $service = Mage::getModel("Tagalys_MerchandisingPage_Model_Client");
60
- // $tagalys = $service->merchandisingPage(array())['filters'];
61
- $filters = $tagalys['filters'];
62
-
63
- foreach ($filters as $filter) {
64
- if($filter["id"] == "__categories"){
65
- $tagalys_categories = $filter;
66
- }
67
- }
68
-
69
-
70
- $data = array();
71
-
72
- foreach ($tagalys_categories["items"] as $category) {
73
- if($category["selected"] == true) {
74
- foreach ($category["items"] as $sub_category) {
75
- $data[] = array(
76
- 'label' => $sub_category["name"],
77
- 'value' => $sub_category["id"],
78
- 'count' => $sub_category["count"],
79
- );
80
- }
81
-
82
- $tags = $this->getLayer()->getStateTags();
83
- $this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
84
- return $data;
85
-
86
- } else {
87
- if (true || $category->getIsActive()) {
88
- $data[] = array(
89
- 'label' => $category["name"],
90
- 'value' => $category["id"],
91
- 'count' => $category["count"],
92
- );
93
- }
94
- }
95
- //check if active
96
-
97
- }
98
- $tags = $this->getLayer()->getStateTags();
99
- $this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
100
- }
101
- return $data;
102
- }
103
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Model/Catalog/Layer/Filter/Price.php DELETED
@@ -1,177 +0,0 @@
1
- <?php
2
-
3
- // if (Mage::Helper('tsearch')->is_fme_active()) {
4
- // class MiddleManModelPriceClass extends FME_Layerednav_Model_Layer_Filter_Price { }
5
- // } else {
6
- // class MiddleManModelPriceClass extends Mage_Catalog_Model_Layer_Filter_Price { }
7
- // }
8
-
9
- class Tagalys_MerchandisingPage_Model_Catalog_Layer_Filter_Price extends Mage_Catalog_Model_Layer_Filter_Price
10
- {
11
- const CACHE_TAG = 'MAXPRICE';
12
-
13
- const DELIMITER = '-';
14
-
15
- /**
16
- * Returns cache tag.
17
- *
18
- * @return string
19
- */
20
- public function getCacheTag()
21
- {
22
- return self::CACHE_TAG;
23
- }
24
-
25
- /**
26
- * Retrieves max price for ranges definition.
27
- *
28
- * @return float
29
- */
30
- public function getMaxPriceMod()
31
- {
32
- $priceStat = Mage::getSingleton('tagalys_merchandisingpage/catalog_layer')->getProductCollection()->getStats('price');
33
- $productCollection = $this->getLayer()->getProductCollection();
34
- return isset($priceStat["max"])?(int)$priceStat["max"]:0;
35
- }
36
-
37
-
38
-
39
- /**
40
- * Retrieves min price for ranges definition.
41
- *
42
- * @return float
43
- */
44
- public function getMinPriceMod()
45
- {
46
- $priceStat = Mage::getSingleton('tagalys_tsearch/catalog_layer')->getProductCollection()->getStats('price');
47
- $productCollection = $this->getLayer()->getProductCollection();
48
- return isset($priceStat["min"])?(int)$priceStat["min"]:0;
49
- }
50
-
51
- /**
52
- * Returns price field according to current customer group and website.
53
- *
54
- * @return string
55
- */
56
- protected function _getFilterField()
57
- {
58
- $websiteId = Mage::app()->getStore()->getWebsiteId();
59
- $customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
60
- $priceField = 'price' ;
61
-
62
- return $priceField;
63
- }
64
-
65
- /**
66
- * Retrieves current items data.
67
- *
68
- * @return array
69
- */
70
- protected function _getItemsData()
71
- {
72
- if (Mage::app()->getStore()->getConfig(self::XML_PATH_RANGE_CALCULATION) == self::RANGE_CALCULATION_IMPROVED) {
73
- return $this->_getCalculatedItemsData();}
74
- if ($this->getInterval()) {
75
- return array();
76
- }
77
-
78
- $data = array();
79
- // $facets = $this->getLayer()->getFacetedData($this->_getFilterField()); ref addy
80
- $service = Mage::getSingleton("Tagalys_MerchandisingPage_Model_Client");
81
-
82
- $tagalys = Mage::helper('merchandisingpage')->getTagalysSearchData();
83
- $filters = $tagalys["filters"];
84
- foreach ($filters as $filter) {
85
-
86
- if ($filter['id'] == 'price' ) {
87
- $filterType = $filter["type"];
88
- foreach ($filter["items"] as $filterItem) {
89
- if ($filterItem["count"]) {
90
- $facets[] = $filterItem;
91
- }
92
- }
93
- }
94
-
95
- }
96
-
97
- if (!empty($facets)) {
98
- $i = 0;
99
- foreach ($facets as $key => $price) {
100
- $i++;
101
-
102
- preg_match('/^(\S*)-(\S*)$/', $price["id"], $rangeKey);
103
- $fromPrice = $rangeKey[1];
104
- $toPrice = $rangeKey[2];
105
- if($filterType == "checkbox"){
106
-
107
- $data[] = array(
108
- // 'label' => $this->_renderRangeLabel($fromPrice, $toPrice),
109
- 'label' => $price["name"],
110
- 'value' => $price["id"],
111
- 'count' => $price["count"]
112
- );
113
- }
114
-
115
- }
116
- } elseif ($filterType == "range") {
117
- $data[] = array(
118
- 'label' => $this->_renderRangeLabel($fromPrice, $toPrice),
119
- 'value' => 10,200,
120
- 'count' => $price["count"]
121
- );
122
- }
123
- return $data;
124
- }
125
-
126
-
127
- /**
128
- * Adds facet condition to product collection.
129
- *
130
- * @see Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection::addFacetCondition()
131
- * @return Tagalys_Tsearch_Model_Catalog_Layer_Filter_Attribute
132
- */
133
- public function addFacetCondition()
134
- {
135
- $this->getLayer()
136
- // ->getProductCollection()
137
- ->addFacetCondition($this->_getFilterField());
138
-
139
- return $this;
140
- }
141
-
142
-
143
- // public function apply(Zend_Controller_Request_Abstract $request, $filterBlock){
144
-
145
- // $filter = $request->getParam($this->_requestVar);
146
- // if(null == $filter){
147
- // return $this;
148
- // }
149
- // $filter =explode(self::DELIMITER, $filter);
150
- // if (!is_array($filter) || null === $filter || sizeof($filter)<2 ) {
151
- // return $this;
152
- // }
153
- // $this->applyFilterToCollection($this, $filter);
154
- // $this->_items = null;
155
- // return $this;
156
- // }
157
-
158
-
159
- function applyFilterToCollection($filter,$filterValue){
160
- $field = $this->_getFilterField();
161
- $value = array(
162
- $field => array(
163
- 'include_upper' => 0
164
- )
165
- );
166
-
167
- if($filterValue[0]< $filterValue[1]){
168
- $value[$field]['from'] = $filterValue[0];
169
- $value[$field]['to'] = $filterValue[1];
170
- }else{
171
- $value[$field]['from'] = $filterValue[1];
172
- $value[$field]['to'] = $filterValue[0];
173
- }
174
- $this->getLayer()->getProductCollection();
175
- return $this;
176
- }
177
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Model/Catalogsearch/Layer.php DELETED
@@ -1,59 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Tsearch_Model_Catalogsearch_Layer extends Mage_Catalog_Model_Layer
4
- {
5
-
6
- protected $_facetsConditions = array();
7
-
8
- public function getProductCollection()
9
- {
10
- try {
11
- $tagalysSearchResults = Mage::helper('tsearch')->getTagalysSearchData();
12
-
13
- if($tagalysSearchResults == false) {
14
- return parent::getProductCollection();
15
- } else {
16
- if(empty($tagalysSearchResults)) {
17
- return parent::getProductCollection();
18
- }
19
-
20
- $collection = $this->_productCollection = Mage::getModel('catalog/product')
21
- ->getCollection()
22
- ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
23
- ->setStore(Mage::app()->getStore())
24
- ->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
25
- ->addAttributeToFilter( 'entity_id', array( 'in' => $tagalysSearchResults['results'] ) );
26
-
27
- $orderString = array('CASE e.entity_id');
28
-
29
- foreach($tagalysSearchResults['results'] as $i => $productId) {
30
- $orderString[] = 'WHEN '.$productId.' THEN '.$i;
31
- }
32
- $orderString[] = 'END';
33
- $orderString = implode(' ', $orderString);
34
-
35
- $collection->getSelect()->order(new Zend_Db_Expr($orderString));
36
- return $this->_productCollection;
37
-
38
- }
39
- } catch(Exception $e) {
40
-
41
- return parent::getProductCollection();
42
- }
43
- }
44
-
45
- public function addFacetCondition($field, $condition = null)
46
- {
47
- if (array_key_exists($field, $this->_facetsConditions)) {
48
- if (!empty($this->_facetsConditions[$field])){
49
- $this->_facetsConditions[$field] = array($this->_facetsConditions[$field]);
50
- }
51
- $this->_facetsConditions[$field][] = $condition;
52
- } else {
53
- $this->_facetsConditions[$field] = $condition;
54
- }
55
-
56
- return $this;
57
- }
58
-
59
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/Model/Client.php DELETED
@@ -1,146 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_MerchandisingPage_Model_Client extends Mage_Core_Model_Abstract {
4
-
5
- protected $_api_key;
6
- protected $_api_server;
7
-
8
- protected $_merchandising_ep;
9
-
10
- protected $_search = array();
11
-
12
- protected $_error = false;
13
-
14
- protected $timeout = 20;
15
-
16
- protected $visitor;
17
-
18
-
19
- public function getSearchResult() {
20
- if(!empty($this->_search)) {
21
- return $this->_search;
22
- } else {
23
- // die("im here");
24
- $this->_search = Mage::helper('merchandisingpage')->getMerchandisingData();
25
- }
26
- return $this->_search;
27
- }
28
-
29
- protected function _construct() {
30
- $this->_config = Mage::helper('tagalys_core');
31
- $this->_api_server = $this->_config->getTagalysConfig("api_server");
32
- $this->_api_key = $this->_config->getTagalysConfig("private_api_key");
33
- $this->_client_code = $this->_config->getTagalysConfig("client_code");
34
- $this->_merchandising_ep = Mage::getStoreConfig('tagalys/endpoint/merchandisingpage');
35
- }
36
-
37
-
38
- protected function createPayload($payload , $action) {
39
- $request = array(
40
- 'client_code' => $this->_client_code,
41
- 'api_key' => $this->_api_key,
42
- "store_id" => $payload["store"]
43
- );
44
- $payload["identification"] = $request;
45
-
46
- return json_encode($payload);
47
- }
48
-
49
-
50
- public function merchandisingPage($payload) {
51
- try {
52
- $url = $this->_api_server.$this->_merchandising_ep;
53
- $url = str_replace(":page-name",$payload['q'],$url);
54
- $payloadData = $this->createPayload($payload);
55
- // die(var_dump($payloadData));
56
- $this->_search = $this->_payloadAgent($url,($payloadData)); //to be enabled
57
- // var_dump($this->_search); die();
58
- // $this->_search = json_decode(file_get_contents('mpage.json'),true);
59
- // $this->_search = array('status' => 'Not found');
60
- // $this->_search = array('status' => 'Internal server error');
61
- // Mage::log(">>>",null,'mrequest.log', true);
62
- // var_dump($this->_search);
63
- return $this->_search;
64
- } catch (Exception $e) {
65
-
66
- }
67
-
68
- }
69
-
70
- private function _getAgent($url) {
71
- $agent = curl_init($url);
72
- return $agent;
73
- }
74
-
75
- private function _queryAgent($url, $query) {
76
- $q_url = $url;
77
- $q_url .= '?q='.$query;
78
- $q_url .= '&api_key='.$this->_api_key;
79
- $agent = $this->_getAgent($url);
80
- curl_setopt($agent, CURLOPT_SSL_VERIFYPEER, 0);
81
- curl_setopt( $agent, CURLOPT_RETURNTRANSFER, true );
82
- curl_setopt($agent, CURLOPT_TIMEOUT, $this->timeout);
83
-
84
- $result = curl_exec($agent);
85
- $info = curl_getinfo($agent);
86
-
87
- if(curl_errno($agent)) {
88
-
89
- if (curl_error($agent) === "name lookup timed out") {
90
- for($i = 0; $i <=2 ; $i++) {
91
- $this->_queryAgent($url, $query);
92
- }
93
- }
94
- } else {
95
- if (empty($result)) {
96
- $this->_error = false;
97
-
98
- }
99
- return $result;
100
- }
101
- //end of curl error log
102
- curl_close($agent);
103
- }
104
-
105
- private function _payloadAgent($url, $payload) {
106
- $agent = $this->_getAgent($url);
107
- curl_setopt( $agent, CURLOPT_POSTFIELDS, $payload );
108
- curl_setopt($agent, CURLOPT_POST,1);
109
- curl_setopt( $agent, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
110
- curl_setopt( $agent, CURLOPT_RETURNTRANSFER, true );
111
- curl_setopt( $agent, CURLOPT_SSL_VERIFYPEER, 0 );
112
- curl_setopt($agent, CURLOPT_TIMEOUT, $this->timeout);
113
- $result = curl_exec($agent);
114
- $info = curl_getinfo($agent);
115
-
116
- // Mage::log("Tagalys Request info: ".json_encode($info),null,'mrequest.log', true);
117
- // Mage::log("Tagalys Request payload: ".($payload),null,'mrequest.log', true);
118
- // Mage::log("Tagalys Response: ".($result),null,'mrequest.log', true);
119
-
120
-
121
- if(curl_errno($agent)) {
122
- $this->_error = true;
123
-
124
- } else {
125
- if (empty($result)) {
126
- $this->_error = true;
127
-
128
- }
129
- }
130
- curl_close($agent);
131
- if (!$this->_error) {
132
- $decoded = json_decode($result, true);
133
- return $decoded;
134
- } else {
135
- return null;
136
- }
137
- }
138
-
139
- public function isRequestSuccess() {
140
-
141
- if( $this->_error == true || empty($this->_search) || $this->_search["status"] != "OK" ) {
142
- return false; //ref addy
143
- }
144
- return true;
145
- }
146
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/controllers/IndexController.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- /**
3
- * Merchandising Page Index Controller
4
- */
5
-
6
- class Tagalys_MerchandisingPage_IndexController extends Mage_Core_Controller_Front_Action
7
- {
8
- public function indexAction ()
9
- {
10
- $helper = Mage::helper('merchandisingpage');
11
- $service = Mage::getSingleton("merchandisingpage/client");
12
- $status = Mage::helper('tagalys_core')->getTagalysConfig("is_merchandising_page_active");
13
- if ($status) {
14
- $response = $helper->getTagalysSearchData();
15
- }
16
-
17
- $this->loadLayout();
18
- // var_dump($response);
19
-
20
- if(isset($response)) {
21
- $head = $this->getLayout()->getBlock('head');
22
- if ($head){
23
- if(isset($response['variables']['page_title'])) {
24
- $head->setTitle($response['variables']['page_title']);
25
- } else {
26
- $head->setTitle(ucwords(str_replace('-',' ',$response['product'])).$_SERVER['HOST_NAME'] );
27
- }
28
- $head->setKeywords($response['variables']['meta_keywords']);
29
- $head->setDescription($response['variables']['meta_description']);
30
- }
31
- $this->renderLayout();
32
- }
33
- else {
34
- return Mage::getClass('Mage_Core_Controller_Varien_Action')->norouteAction();
35
- }
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/MerchandisingPage/etc/config.xml DELETED
@@ -1,94 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <default>
4
- <tagalys>
5
- <endpoint>
6
- <merchandisingpage>/v1/mpages/:page-name</merchandisingpage>
7
- </endpoint>
8
- </tagalys>
9
- </default>
10
- <modules>
11
- <Tagalys_MerchandisingPage>
12
- <version>0.1.0</version>
13
- </Tagalys_MerchandisingPage>
14
- </modules>
15
- <global>
16
- <helpers>
17
- <merchandisingpage>
18
- <class>Tagalys_MerchandisingPage_Helper</class>
19
- </merchandisingpage>
20
- </helpers>
21
-
22
- <blocks>
23
- <merchandisingpage>
24
- <class>Tagalys_MerchandisingPage_Block</class>
25
- </merchandisingpage>
26
-
27
- <catalog>
28
- <rewrite>
29
- <layer>Tagalys_MerchandisingPage_Block_Catalog_Layer_View</layer>
30
- </rewrite>
31
- </catalog>
32
-
33
- <page>
34
- <rewrite>
35
- <html_pager>Tagalys_MerchandisingPage_Block_Page_Html_Pager</html_pager>
36
- </rewrite>
37
- </page>
38
- <catalog>
39
- <rewrite>
40
- <product_list_toolbar>Tagalys_MerchandisingPage_Block_Catalog_Product_List_Toolbar</product_list_toolbar>
41
- </rewrite>
42
- </catalog>
43
-
44
- <catalogsearch>
45
- <rewrite>
46
- <layer>Tagalys_MerchandisingPage_Block_Catalogsearch_Layer_View</layer>
47
- </rewrite>
48
- </catalogsearch>
49
- </blocks>
50
- <models>
51
- <merchandisingpage>
52
- <class>Tagalys_MerchandisingPage_Model</class>
53
- </merchandisingpage>
54
-
55
- <catalog>
56
- <rewrite>
57
- <layer>Tagalys_MerchandisingPage_Model_Catalog_Layer</layer>
58
- </rewrite>
59
- </catalog>
60
- </models>
61
- <!-- url rewrite -->
62
- <rewrite>
63
- <merchandisingpage>
64
- <from><![CDATA[#^/m/([\w-]+)/?#]]></from>
65
- <to><![CDATA[/m/index/index/product/$1]]></to>
66
- <complete>1</complete>
67
- </merchandisingpage>
68
- </rewrite>
69
- <!-- end url rewrite -->
70
- </global>
71
- <frontend>
72
- <routers>
73
- <merchandisingpage>
74
- <use>standard</use>
75
- <args>
76
- <module>Tagalys_MerchandisingPage</module>
77
- <frontName>m</frontName>
78
- </args>
79
- </merchandisingpage>
80
- </routers>
81
- <layout>
82
- <updates>
83
- <merchandisingpage>
84
- <file>tagalys_merchandising.xml</file>
85
- </merchandisingpage>
86
- </updates>
87
- </layout>
88
- </frontend>
89
- <!-- <depends>
90
- <Mage_Catalog />
91
- <Mage_CatalogSearch />
92
- <Tagalys_Sync />
93
- </depends> -->
94
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/PopularSearches/Model/Observer.php DELETED
@@ -1,86 +0,0 @@
1
- <?php
2
- class Tagalys_PopularSearches_Model_Observer extends Varien_Object
3
- {
4
- private $default_location; //defualt location of tagalys media directory
5
- private $file_path;
6
-
7
- protected function _construct(){
8
- $this->_config = Mage::helper('tagalys_core');
9
- $this->_api_server = $this->_config->getTagalysConfig("api_server");
10
- $this->_client_code = $this->_config->getTagalysConfig("client_code");
11
- $this->_private_api_key = $this->_config->getTagalysConfig("private_api_key");
12
- $this->_popular_search = Mage::getStoreConfig('tagalys_popular_searches/endpoint/popular_searches');
13
- $this->_url = $this->_api_server.$this->_popular_search;
14
- $this->default_location = Mage::getBaseDir('media'). DS .'tagalys';
15
- $this->file_path = $this->default_location . DS;
16
- }
17
- public function getPopularSearches() {
18
- if(!Mage::helper('tagalys_core')->getTagalysConfig("is_tsearchsuggestion_active")) {
19
- return false;
20
- }
21
- if(!Mage::helper('tagalys_core')->getTagalysConfig('search_complete') || !Mage::helper('tagalys_core')->getTagalysConfig('setup_complete'))
22
- return false;
23
- try {
24
- $request = array(
25
- 'client_code' => $this->_client_code,
26
- 'api_key' => $this->_private_api_key,
27
- 'store' => Mage::app()->getStore()->getStoreId() ? Mage::app()->getStore()->getStoreId() : 1
28
- );
29
- $payload["identification"] = $request;
30
- $payloadData = (json_encode($payload));
31
- $json_data = $this->_payloadAgent($this->_url,($payloadData));
32
-
33
- $fp = fopen( $this->file_path.'tagalys-popularsearches-'.$request["store"].'.json', 'w');
34
- if($json_data == null) {
35
- $json_data = array();
36
- fwrite($fp, json_encode($json_data));
37
- fclose($fp);
38
- } else {
39
- fwrite($fp, json_encode($json_data["popular_searches"]));
40
- fclose($fp);
41
- }
42
-
43
- } catch(Exception $e) {
44
- }
45
- }
46
-
47
- private function _getAgent($url) {
48
- $agent = curl_init($url);
49
- return $agent;
50
- }
51
- private function _payloadAgent($url, $payload) {
52
- $agent = $this->_getAgent($url);
53
- curl_setopt( $agent, CURLOPT_POSTFIELDS, $payload );
54
- curl_setopt($agent, CURLOPT_POST,1);
55
- curl_setopt( $agent, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
56
- curl_setopt( $agent, CURLOPT_RETURNTRANSFER, true );
57
- curl_setopt( $agent, CURLOPT_SSL_VERIFYPEER, 0 );
58
- curl_setopt($agent, CURLOPT_TIMEOUT, $this->timeout);
59
- $result = curl_exec($agent);
60
- $info = curl_getinfo($agent);
61
-
62
- if(curl_errno($agent)) {
63
- $this->_error = true;
64
- } else {
65
- $this->_error = false;
66
- if (empty($result)) {
67
- $this->_error = true;
68
- }
69
- }
70
- curl_close($agent);
71
-
72
- if (!$this->_error) {
73
- $decoded = json_decode($result, true);
74
- if($decoded["status"] == "OK") {
75
- return $decoded;
76
- } else {
77
- return array();
78
- }
79
- } else {
80
- return array();
81
- //return json_decode($result, true);
82
- }
83
- }
84
- }
85
-
86
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/PopularSearches/etc/config.xml DELETED
@@ -1,40 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <default>
4
- <tagalys_popular_searches>
5
- <endpoint>
6
- <popular_searches>/v1/popular_searches</popular_searches>
7
- </endpoint>
8
- </tagalys_popular_searches>
9
- </default>
10
- <modules>
11
- <Tagalys_PopularSearches>
12
- <version>1.1.0</version>
13
- </Tagalys_PopularSearches>
14
- </modules>
15
- <global>
16
- <models>
17
- <tagalys_popular_searches>
18
- <class>Tagalys_PopularSearches_Model</class>
19
- </tagalys_popular_searches>
20
- <tagalys_popular_searches>
21
- <resourceModel>tagalys_popular_searches_resource</resourceModel>
22
- </tagalys_popular_searches>
23
- <tagalys_popular_searches_resource>
24
- <class>Tagalys_PopularSearches_Model_Resource</class>
25
- </tagalys_popular_searches_resource>
26
- </models>
27
- </global>
28
- <crontab>
29
- <jobs>
30
- <tagalys_popular_searches>
31
- <schedule>
32
- <cron_expr>*/10 * * * *</cron_expr>
33
- </schedule>
34
- <run>
35
- <model>tagalys_popular_searches/observer::getPopularSearches</model>
36
- </run>
37
- </tagalys_popular_searches>
38
- </jobs>
39
- </crontab>
40
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/SearchSuggestions/Block/Catalog/Layer.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
- /**
3
- * Overrides default layer view process to define custom filter blocks.
4
- *
5
- * @package Tagalys_SearchSuggestions
6
- * @subpackage Tagalys_SearchSuggestions_Block
7
- * @author Tagalys
8
- */
9
- class Tagalys_SearchSuggestions_Block_Catalog_Layer extends Mage_CatalogSearch_Block_Layer
10
- {
11
- /**
12
- * Boolean block name.
13
- *
14
- * @var string
15
- */
16
-
17
- protected function _initBlocks()
18
- {
19
- parent::_initBlocks();
20
- $this->_categoryBlockName = 'tagalys_ss/catalog_layer_filter_category';
21
- $this->_attributeFilterBlockName = 'tagalys_ss/catalog_layer_filter_attribute';
22
- }
23
-
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/SearchSuggestions/Block/Catalog/Layer/Filter/Attribute.php DELETED
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_SearchSuggestions_Block_Catalog_Layer_Filter_Attribute extends Mage_Catalog_Block_Layer_Filter_Attribute
4
- {
5
- /**
6
- * Defines specific filter model name.
7
- *
8
- * @see Tagalys_SearchSuggestions_Model_Catalog_Layer_Filter_Attribute
9
- */
10
- public function __construct()
11
- {
12
- parent::__construct();
13
-
14
- $this->_filterModelName = 'tagalys_ss/catalog_layer_filter_attribute';
15
- }
16
-
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/SearchSuggestions/Block/Catalog/Layer/Filter/Category.php DELETED
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_SearchSuggestions_Block_Catalog_Layer_Filter_Category extends Mage_Catalog_Block_Layer_Filter_Category
4
- {
5
- /**
6
- * Defines specific filter model name.
7
- *
8
- * @see Tagalys_SearchSuggestions_Model_Catalog_Layer_Filter_Attribute
9
- */
10
- public function __construct()
11
- {
12
- parent::__construct();
13
-
14
- $this->_filterModelName = 'tagalys_ss/catalog_layer_filter_category';
15
- }
16
-
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/SearchSuggestions/Helper/Data.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_SearchSuggestions_Helper_Data extends Mage_Core_Helper_Abstract {
4
-
5
- public function getCurrentCurrency() {
6
- $currency_rate = array();
7
- $currencyModel = Mage::getModel('directory/currency');
8
- $currencies = $currencyModel->getConfigAllowCurrencies(); // abaliable currency
9
- $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode(); //default code
10
- $defaultCurrencies = $currencyModel->getConfigBaseCurrencies();
11
- $rates=$currencyModel->getCurrencyRates($defaultCurrencies, $currencies); //rates of each currency
12
- $current_currency = Mage::getModel('core/cookie')->get('currency') ? Mage::getModel('core/cookie')->get('currency') : Mage::app()->getStore()->getBaseCurrencyCode();
13
- if (empty($rates[$baseCurrencyCode])) {
14
- $rates[$baseCurrencyCode] = array($baseCurrencyCode => '1.0000');
15
- }
16
- foreach($rates[$baseCurrencyCode] as $key=>$value ) {
17
- if($key == $current_currency) {
18
- $label = Mage::app()->getLocale()->currency( $key )->getSymbol();
19
- if (empty($label)) {
20
- if($baseCurrencyCode == "INR") {
21
- $label = "₹";
22
- }
23
- }
24
- $currency_rate[] = array("id" => $key, "label" => $label, "fractional_digits" => 2 , "rounding_mode" => "round", "exchange_rate" => (float)$value, "default" => $default); //getFinalPrice
25
- }
26
-
27
- }
28
-
29
- return $currency_rate;
30
- }
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/SearchSuggestions/Model/Catalog/Layer/Filter/Attribute.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_SearchSuggestions_Model_Catalog_Layer_Filter_Attribute extends Mage_Catalog_Model_Layer_Filter_Attribute {
4
-
5
- public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
6
- {
7
- $filter = $request->getParam($this->_requestVar);
8
- //aadi
9
- $request = Mage::app()->getRequest()->getParams();
10
- if (!empty($request["qf"])) {
11
- foreach (explode("~", $request["qf"]) as $key => $value) {
12
- $temp = explode("-", $value);
13
- if($temp[0] == $this->_requestVar) {
14
- $temp_val = explode("-", $value);
15
- $filter = $temp_val[1];
16
- }
17
- # code...
18
- }
19
- }
20
- //aadi end
21
- if (is_array($filter)) {
22
- return $this;
23
- }
24
- $text = $this->_getOptionText($filter);
25
- if ($filter && strlen($text)) {
26
- $this->_getResource()->applyFilterToCollection($this, $filter);
27
- $this->getLayer()->getState()->addFilter($this->_createItem($text, $filter));
28
- $this->_items = array();
29
- }
30
- return $this;
31
- }
32
-
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/SearchSuggestions/Model/Catalog/Layer/Filter/Category.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_SearchSuggestions_Model_Catalog_Layer_Filter_Category extends Mage_Catalog_Model_Layer_Filter_Category {
4
-
5
- public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
6
- {
7
- $filter = (int) $request->getParam($this->getRequestVar());
8
- //aadi
9
- $request = Mage::app()->getRequest()->getParams();
10
- if (!empty($request["qf"])) {
11
- foreach (explode("~", $request["qf"]) as $key => $value) {
12
- $temp = explode("-", $value);
13
- if($temp[0] == $this->_requestVar) {
14
- $temp_val = explode("-", $value);
15
- $filter = $temp_val[1];
16
- }
17
- # code...
18
- }
19
- }
20
- //end aadi
21
- if (!$filter) {
22
- return $this;
23
- }
24
- $this->_categoryId = $filter;
25
- Mage::register('current_category_filter', $this->getCategory(), true);
26
-
27
- $this->_appliedCategory = Mage::getModel('catalog/category')
28
- ->setStoreId(Mage::app()->getStore()->getId())
29
- ->load($filter);
30
-
31
- if ($this->_isValidCategory($this->_appliedCategory)) {
32
- $this->getLayer()->getProductCollection()
33
- ->addCategoryFilter($this->_appliedCategory);
34
-
35
- $this->getLayer()->getState()->addFilter(
36
- $this->_createItem($this->_appliedCategory->getName(), $filter)
37
- );
38
- }
39
-
40
- return $this;
41
- }
42
-
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/SearchSuggestions/controllers/AutoSuggestController.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
- class Tagalys_SearchSuggestions_AutoSuggestController extends Mage_Core_Controller_Front_Action
3
- {
4
- public function ssAction() {
5
- try {
6
- $output = $this->getRequest()->getParams();
7
- $qf = $output["qf"];
8
- $q = $output["q"];
9
- $temp = array();
10
-
11
- $arr = (array)(json_decode($qf));
12
- foreach($arr as $k => $v) {
13
- if($k == "__categories")
14
- $k = "cat";
15
- foreach($v as $k1 => $v1) {
16
-
17
- $temp[$k] = $v1;
18
- }
19
- }
20
-
21
- $base = Mage::helper('catalogsearch')->getResultUrl($q);
22
- $search_url = Mage::getUrl("", array("_absolute" => false , "_query" => $temp));
23
-
24
- $filters = explode("?", $search_url);
25
- $link = $base."&".$filters[1];
26
- echo $link;
27
- }
28
- catch (Exception $e) {
29
- return false;
30
- }
31
-
32
- }
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/SearchSuggestions/etc/config.xml DELETED
@@ -1,61 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <default>
4
- <tagalys_ss>
5
- <endpoint>
6
- <ss>/v1/search_suggestion</ss>
7
- </endpoint>
8
- </tagalys_ss>
9
- </default>
10
- <modules>
11
- <Tagalys_SearchSuggestions>
12
- <version>1.0.0</version>
13
- </Tagalys_SearchSuggestions>
14
- </modules>
15
- <frontend>
16
- <layout>
17
- <updates>
18
- <tagalys_ss>
19
- <file>tagalys/ss.xml</file>
20
- </tagalys_ss>
21
- </updates>
22
- </layout>
23
- <routers>
24
- <tagalys_ss>
25
- <use>standard</use>
26
- <args>
27
- <module>Tagalys_SearchSuggestions</module>
28
- <frontName>tagalys_ss</frontName>
29
- </args>
30
- </tagalys_ss>
31
- </routers>
32
- </frontend>
33
- <global>
34
- <helpers>
35
- <search_suggestions>
36
- <class>Tagalys_SearchSuggestions_Helper</class>
37
- </search_suggestions>
38
- </helpers>
39
- <blocks>
40
- <tagalys_ss>
41
- <class>Tagalys_SearchSuggestions_Block</class>
42
- </tagalys_ss>
43
- <catalogsearch>
44
- <rewrite>
45
- <layer>Tagalys_SearchSuggestions_Block_Catalog_Layer</layer>
46
- </rewrite>
47
- </catalogsearch>
48
- </blocks>
49
- <models>
50
- <tagalys_ss>
51
- <class>Tagalys_SearchSuggestions_Model</class>
52
- </tagalys_ss>
53
- <tagalys_ss>
54
- <resourceModel>tagalys_ss_resource</resourceModel>
55
- </tagalys_ss>
56
- <tagalys_ss_resource>
57
- <class>Tagalys_SearchSuggestions_Model_Resource</class>
58
- </tagalys_ss_resource>
59
- </models>
60
- </global>
61
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/Helper/Data.php DELETED
@@ -1,90 +0,0 @@
1
- <?php
2
- class Tagalys_Sync_Helper_Data extends Mage_Core_Helper_Abstract
3
- {
4
- public function getTreeCategories($id){
5
- $clist = "";
6
- $productObj = Mage::getModel('catalog/product')->load($id);
7
- $categoryIds = $productObj->getCategoryIds();
8
- foreach ($categoryIds as $key => $value) {
9
- $category = Mage::getModel('catalog/category')->load($value);
10
- if ($category->getIsActive()) {
11
- $catId[] = $value;
12
- }
13
- }
14
- foreach ($catId as $key => $value) {
15
- $m = Mage::getModel('catalog/category')
16
- ->load($value)
17
- ->getParentCategory();
18
- $path = $m->getPath()."/".$value;
19
- $category = explode("/", $path);
20
- foreach ($category as $category_id) {
21
- if($category_id != 1 && $category_id != 2 ) {
22
- $_cat = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($category_id);
23
- $categoryList[] = $_cat->getName();
24
- }
25
- }
26
- $clist = implode(" / ", $categoryList);
27
- }
28
- return $clist;
29
- }
30
- public function getProductTreeCat($id) {
31
- $clist = "";
32
- $temp = array();
33
- $productObj = Mage::getModel('catalog/product')->load($id);
34
- $categoryIds = $productObj->getCategoryIds();
35
- foreach ($categoryIds as $key => $value) {
36
- $category = Mage::getModel('catalog/category')->load($value);
37
- if ($category->getIsActive()) {
38
- $catId[] = $value;
39
- }
40
- }
41
- foreach ($catId as $key => $value) {
42
- $m = Mage::getModel('catalog/category')
43
- ->load($value)
44
- ->getParentCategory();
45
-
46
- $tempval = explode("1/2",$m->getPath());
47
- if(!empty($tempval[1])) {
48
- $path = $tempval[1]."/".$value;
49
- $category = explode("/", $path);
50
- foreach ($category as $category_id) {
51
- $categoryList = array();
52
- if($category_id != 1 && $category_id != 2 ) {
53
- $_cat = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($category_id);
54
- $sub_categories = array("id" => $_cat->getId() , "label" => $_cat->getName());
55
- $categoryList[] = array("id" => $m->getId() , "label" => $m->getName(), "items" => array($sub_categories));
56
- }
57
- }
58
- $temp[] = $categoryList[0];
59
- }
60
- }
61
- return $temp;
62
- }
63
- public function formatDataForAdminSection($data){
64
- foreach ($data as $key => $value) {
65
- $formatted_data[] = array('label' => $key , 'value' => $value);
66
- }
67
- return $formatted_data;
68
- }
69
- public function getSelectedStore() {
70
- $this->_config = Mage::helper('tagalys_core')->getTagalysConfig("stores_setup");
71
-
72
- if($this->_config){
73
- $selected_stores = explode(",", $this->_config);
74
- return $selected_stores;
75
- }
76
- return array();
77
- }
78
- public function getAllWebsiteStores() {
79
- foreach (Mage::app()->getWebsites() as $website) {
80
- foreach ($website->getGroups() as $group) {
81
- $stores = $group->getStores();
82
- foreach ($stores as $store) {
83
- $website_stores[] = array("value" => $store->getId(), "label" => $website->getName()." / ".$group->getName(). " / ".$store->getName());
84
- }
85
- }
86
- }
87
-
88
- return $website_stores;
89
- }
90
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/Helper/Inventory.php DELETED
@@ -1,35 +0,0 @@
1
- <?php
2
- class Tagalys_Sync_Helper_Inventory extends Mage_Core_Helper_Abstract {
3
-
4
- public function getInventoryStockItemField() {
5
- $stock_item = array(
6
- "qty" => "Qty",
7
- "min_qty" => "Minimum Qty Allowed in Shopping Cart",
8
- "use_config_min_qty" => "Minimum Qty Allowed in Shopping Cart Use Config",
9
- "is_qty_decimal" => "Qty Uses Decimals",
10
- "backorders" => "Backorders",
11
- "use_config_backorders" => "Backorders Use Config Settings",
12
- "min_sale_qty" => "",
13
- "use_config_min_sale_qty" => "",
14
- "max_sale_qty" => "Maximum Qty Allowed in Shopping Cart",
15
- "use_config_max_sale_qty" => "Maximum Qty Allowed in Shopping Cart Use Config Settings",
16
- "is_in_stock" => "Stock Availability",
17
- "low_stock_date" => "",
18
- "notify_stock_qty" => "Notify for Quantity Below",
19
- "use_config_notify_stock_qty" => "Notify for Quantity Below Use Config Settings",
20
- "manage_stock" => "Manage Stock",
21
- "use_config_manage_stock" => "Manage Stock Use Config Settings",
22
- "stock_status_changed_auto" => "",
23
- "use_config_qty_increments" => "",
24
- "qty_increments" => "Enable Qty Increments",
25
- "use_config_enable_qty_inc" => "Enable Qty Increments Use Config Settings",
26
- "enable_qty_increments" => "Enable Qty Increments",
27
- "is_decimal_divided" => "",
28
- "stock_status_changed_automatically" => "",
29
- "use_config_enable_qty_increments" => "Enable Qty Use Config Settings"
30
- );
31
- return $stock_item;
32
-
33
- }
34
-
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/Helper/Service.php DELETED
@@ -1,311 +0,0 @@
1
- <?php
2
- class Tagalys_Sync_Helper_Service extends Mage_Core_Helper_Abstract {
3
- protected $_storeId;
4
- public function productSyncBySoap($page, $limit) {
5
- $payload = array();
6
- try {
7
- if(empty($this->_storeId)) {
8
- $this->_storeId = Mage::app()->getWebsite(true)->getDefaultGroup()->getDefaultStoreId();
9
- }
10
-
11
- Mage::app()->setCurrentStore($this->_storeId);
12
- $collection = Mage::getResourceModel('catalog/product_collection')
13
- //->getCollection()
14
- ->setStore($this->_storeId)
15
- ->setPageSize($limit)
16
- ->addAttributeToSelect('*')
17
- ->setCurPage($page);
18
-
19
- $payload = $this->getProductWithParentAttribute($collection,$store_id);
20
- return $payload;
21
-
22
- } catch (Exception $e) {
23
-
24
- }
25
- }
26
-
27
- public function getProductWithParentAttribute($products,$store_id) {
28
- $payload = array();
29
- foreach ($products as $product) {
30
- $simpleProduct = $this->getSingleProductWithoutPayload($product->getId(),$store_id);
31
- if(isset($simpleProduct)) {
32
- array_push($payload,array("perform" => "index", "payload" => $simpleProduct));
33
- }
34
- }
35
- return $payload;
36
- }
37
-
38
-
39
- public function getSingleProductWithoutPayload($product_id, $store_id, $admin = false) {
40
-
41
- $core_helper = Mage::helper('tagalys_core');
42
- $sync_helper = Mage::helper('sync/data');
43
- $sync_level = $core_helper->getTagalysConfig("sync_level");
44
- $details_model = Mage::getModel("sync/productDetails");
45
-
46
- $product_data = new stdClass();
47
- $utc_now = new DateTime((string)date("Y-m-d h:i:s"));
48
- $time_now = $utc_now->format(DateTime::ATOM);
49
- $attr_data = array();
50
- $attributes = $details_model->getProductAttributes($product_id, $store_id, array_keys((array) $product_data));
51
- $product_data = $details_model->getProductFields($product_id, $store_id);
52
- $product_data->synced_at = $time_now;
53
- $product_data->__tags = $attributes;
54
- if($sync_level == "advanced"){
55
- $product_data->raw_source = $this->getRawData($product_id);
56
- }
57
-
58
- // $product_data->tagalys_product_type = $details_model->getProductType($product_id);
59
-
60
- return $product_data;
61
- }
62
- public function getProductTotal() {
63
- try {
64
- $record = Mage::getModel('catalog/product')->getCollection()->count();
65
- return $record;
66
- } catch (Exception $e) {
67
- }
68
- }
69
- public function getQueueSize() {
70
- try {
71
- $record = Mage::getModel('sync/queue')->getCollection()->count();
72
- return $record;
73
- } catch (Exception $e) {
74
- }
75
- }
76
- public function getSingleProductBySku($sku) {
77
- try {
78
- if(isset($sku)) {
79
- if(empty($this->_storeId)) {
80
- $this->_storeId = Mage::app()->getWebsite(true)->getDefaultGroup()->getDefaultStoreId();
81
- }
82
- Mage::app()->setCurrentStore($this->_storeId);
83
- $collection = Mage::getResourceModel('catalog/product_collection')
84
- ->setStore($this->_storeId)
85
- ->addAttributeToSelect('*')
86
- ->addFilter('sku',$sku);
87
- $product = $this->getSingleProductWithoutPayload($collection->getFirstItem());
88
- return $product;
89
- }
90
- return null;
91
- } catch (Exception $e) {
92
- }
93
- }
94
- public function getProductUpdate($limit, $store) {
95
- try {
96
- $this->_storeId = $store;
97
- $collection = Mage::getModel('sync/queue')->getCollection()->setOrder('id', 'DESC');
98
- $collection->getSelect()->limit($limit);
99
- $products_id = array();
100
- $deleted_ids = array();
101
- $existing_products_id = array();
102
- $non_existing_ids = array();
103
- $count = 0;
104
- foreach ($collection as $key => $queue) {
105
- $product_id = $queue->getData('product_id');
106
- if (is_numeric($product_id)) {
107
- array_push($products_id, $product_id);
108
- } else {
109
- array_push($deleted_ids, $product_id);
110
- }
111
- }
112
-
113
- $productCollection = Mage::getModel('catalog/product')->getCollection()
114
- ->addAttributeToSelect('*')
115
- ->addAttributeToFilter('status',1) //only enabled product
116
- ->addAttributeToFilter('visibility',array("neq"=>1)) //except not visible individually
117
- ->setStoreId($this->_storeId)
118
- ->addStoreFilter($this->_storeId)
119
- ->addAttributeToFilter( 'entity_id', array( 'in' => $products_id ));
120
-
121
- $respone = $this->getProductWithParentAttribute($productCollection, $this->_storeId);
122
- foreach ($respone as $key => $value) {
123
- array_push($existing_products_id, $value["payload"]->__id);
124
- $count++;
125
- }
126
- $non_existing_ids = array_merge(array_diff($existing_products_id, $products_id), array_diff($products_id, $existing_products_id));
127
- foreach ($non_existing_ids as $key => $value) {
128
- if(isset($value)) {
129
- $deleted = new stdClass;
130
- $deleted->perform = "delete";
131
- $deleted->payload->__id = $value;
132
- // $deleted->deleted = true ;
133
- array_push($respone, $deleted);
134
- }
135
-
136
- }
137
- foreach ($deleted_ids as $key => $value) {
138
- $deleted = new stdClass;
139
- $deleted->perform = "delete";
140
- $temp= explode("sku-", $value);
141
- $sku = $temp[1];
142
- if(!empty($sku)){
143
- $deleted->payload->sku = $sku;
144
- }
145
- // $deleted->deleted = true ;
146
- array_push($respone, $deleted);
147
- }
148
-
149
- foreach ($collection as $key => $queue) {
150
- $queue->delete();
151
- }
152
- return $respone;
153
- } catch (Exception $e) {
154
- }
155
- }
156
- public function getRawData($product_id) {
157
-
158
- if(empty($this->_storeId)) {
159
- $this->_storeId = Mage::app()->getWebsite(true)->getDefaultGroup()->getDefaultStoreId();
160
- Mage::app()->setCurrentStore($this->_storeId);
161
- }
162
- $syncField = Mage::getModel("sync/productDetails");
163
- $fields = $syncField->getProductSyncField();
164
- //Add Extra field
165
- $fields = array_merge($fields, array('created_at', 'updated_at'));
166
- $productObject = new stdClass();
167
- $product = Mage::getModel('catalog/product')->load($product_id);
168
- $productObject->product_id = $product_id;
169
- //Get Category Details
170
- $category = $product->getCategoryIds();
171
- $categoryList = array();
172
- foreach ($category as $category_id) {
173
- $_cat = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($category_id);
174
- $categoryList[] = $_cat->getName();
175
- }
176
- //Category Container
177
- $productObject->categories = $categoryList;
178
- //Get Tag Details
179
- $model=Mage::getModel('tag/tag');
180
- $tagsOption = $model->getResourceCollection()
181
- ->addPopularity()
182
- ->addStatusFilter($model->getApprovedStatus())
183
- ->addProductFilter($product->getId())
184
- ->setFlag('relation', true)
185
- ->addStoreFilter($this->_storeId)
186
- ->setActiveFilter()
187
- ->load();
188
- $tags = array();
189
- foreach($tagsOption as $tag) $tags[] = $tag->getName();
190
- $productObject->tags = $tags;
191
- //Field Container
192
- if(empty($fields)) {
193
- $productObject->sku = $product->getData('sku');
194
- $productObject->price = $product->getData('cost');
195
- }
196
- else {
197
- foreach ($fields as $key => $name) {
198
- $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $name);
199
- if ($attribute->usesSource()) {
200
- $attributeCode = $attribute->setStoreId($this->_storeId)->getAttributeCode();
201
- $fieldValue = $product->getResource()->getAttribute($attributeCode)->getFrontend()->getValue($product);
202
- $productObject->{$name} = $fieldValue;//$product->getAttributeText($name);
203
- } else {
204
- $filter = array('image','small_image','thumbnail');
205
- if(in_array($name, $filter)) {
206
- $productObject->{$name} = '/media/catalog/product' . $product->getImage();
207
- try {
208
- if($name == "thumbnail") {
209
- $productObject->tagalys_thumbnail_url = (string)Mage::helper('catalog/image')->init($product, 'thumbnail')->resize(170);
210
- }
211
- } catch(Exception $e) {
212
- $productObject->tagalys_thumbnail_url = null;
213
- // Mage::log("Product Image not found", null, "tagalys.log");
214
- }
215
- }
216
- else if($name == 'url_key') {
217
- $productObject->{$name} = $product->getData($name);
218
- $productObject->url = parse_url($product->getProductUrl(), PHP_URL_PATH);
219
- }
220
- else {
221
- $productObject->{$name} = $product->getData($name);
222
- }
223
- }
224
- }
225
- //Adding stock field
226
- $stockField = $syncField->getInventorySyncField();
227
- $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
228
- foreach ($stockField as $key => $field) {
229
- $productObject->{$field} = $stock->getData($field);
230
- }
231
- }
232
- //Add product type field for identification
233
- $productType = $product->getTypeId();
234
- $productObject->tagalys_product_type = $productType;
235
- $details_model = Mage::getModel("sync/productDetails");
236
- $product_data->tagalys_parent_id = $details_model->getProductParent($product_id);
237
-
238
- return $productObject;
239
- }
240
-
241
- public function getClientCurrencyData() {
242
- $currency_rate = array();
243
- $currencyModel = Mage::getModel('directory/currency');
244
- $currencies = $currencyModel->getConfigAllowCurrencies(); // abaliable currency
245
- $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode(); //default code
246
- $defaultCurrencies = $currencyModel->getConfigBaseCurrencies();
247
- $rates=$currencyModel->getCurrencyRates($defaultCurrencies, $currencies); //rates of each currency
248
-
249
- if (empty($rates[$baseCurrencyCode])) {
250
- $rates[$baseCurrencyCode] = array($baseCurrencyCode => '1.0000');
251
- }
252
-
253
- foreach($rates[$baseCurrencyCode] as $key=>$value ) {
254
- $default = $baseCurrencyCode == $key ? true : false;
255
- $label = Mage::app()->getLocale()->currency( $key )->getSymbol();
256
- if (!isset($label)) {
257
- if($baseCurrencyCode == "INR") {
258
- $label = '₹';
259
- }
260
- }
261
- $currency_rate[] = array("id" => $key, "label" => $label, "fractional_digits" => 2 , "rounding_mode" => "round", "exchange_rate" => (float)$value, "default" => $default); //getFinalPrice
262
- }
263
-
264
- return $currency_rate;
265
- }
266
-
267
- public function getClientSortOptions() {
268
- $sort_options = array();
269
- foreach (Mage::getResourceModel('catalog/config')->getAttributesUsedForSortBy() as $key => $value) {
270
- # code...
271
- $sort_options[] = array("field" => $value["attribute_code"], "label" => $value["store_label"]);
272
- }
273
- return $sort_options;
274
- }
275
-
276
- public function getClientSetData() {
277
- $diff = array("name","sku","__id","link","sale_price","image_url","introduced_at","in_stock");
278
- $attributes = Mage::getResourceModel('catalog/product_attribute_collection')->getItems();
279
- $attributes_tag_set = array();
280
- $attributes_fields = array();
281
- $types = Mage::getModel('eav/adminhtml_system_config_source_inputtype')->toOptionArray();
282
- array_push($types, array("value" => "price"));
283
- foreach ($types as $key => $value) {
284
- if($value["value"] == "price") {
285
- $typemap[$value["value"]] = "float";
286
- } elseif ($value["value"] == "boolean") {
287
- $typemap[$value["value"]] = "boolean";
288
- } elseif ($value["value"] == "date") {
289
- $typemap[$value["value"]] = "date";
290
- } else {
291
- $typemap[$value["value"]] = "string";
292
- }
293
-
294
- }
295
- foreach ($attributes as $attribute){
296
- if(($attribute->getIsFilterable() || $attribute->getIsSearchable()) && ($attribute->getFrontendInput() == "select" || $attribute->getFrontendInput() == "multiselect" )) {
297
- $attributes_tag_set[] = array("id" =>$attribute->getAttributecode(), "label" =>$attribute->getFrontendLabel(), "filters" => (bool)$attribute->getIsFilterable(), "search" => (bool)$attribute->getIsSearchable());
298
- } else if(($attribute->getIsFilterable() || $attribute->getIsSearchable()) && !in_array($attribute->getAttributecode(), $diff)) {
299
- if ($attribute->getFrontendInput() == "price" ) {
300
- $attributes_fields[] = array("name" =>$attribute->getAttributecode(), "label" =>$attribute->getFrontendLabel(),"type" => $typemap[$attribute->getFrontendInput()],"currency" => true, "display" => true, "filters" => (bool)$attribute->getIsFilterable(),"search" => (bool)$attribute->getIsSearchable());
301
- } else {
302
- $attributes_fields[] = array("name" =>$attribute->getAttributecode(), "label" =>$attribute->getFrontendLabel(),"type" => $typemap[$attribute->getFrontendInput()], "filters" => (bool)$attribute->getIsFilterable(),"search" => (bool)$attribute->getIsSearchable());
303
- }
304
-
305
- }
306
-
307
- }
308
- $attributes_tag_set[] = array("id" =>"__categories", "label" =>"categories", "filters" => (bool)true, "search" => (bool)true);
309
- return array("tag_set" => $attributes_tag_set, "fields" => $attributes_fields );
310
- }
311
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/Helper/TagalysFeedFactory.php DELETED
@@ -1,463 +0,0 @@
1
- <?php
2
- /**
3
- * Tagalys Feed Wrapper
4
- *
5
- * Wrapper class creates tagalys specific product feed in json file.
6
- */
7
- class Tagalys_Sync_Helper_TagalysFeedFactory extends Varien_Io_File {
8
- private $default_location; //defualt location of tagalys media directory
9
- private $file_path; // tagalys directory location
10
- protected $_api;
11
- protected $_total;
12
-
13
- CONST PAGE_LIMIT = 1000;
14
-
15
- function __construct() {
16
- $this->default_location = Mage::getBaseDir('media'). DS .'tagalys';
17
- $this->file_path = $this->default_location . DS;
18
- // parent::__construct();
19
- }
20
- public function getProductDump($storeId) {
21
- if(!Mage::helper('tagalys_core')->getTagalysConfig("sync-".$storeId)){
22
- return $this->createProductFeed($storeId,true);
23
- }
24
- return false;
25
- }
26
- public function getUpdatesDump($storeId) {
27
- return $this->createProductFeed($storeId,false);
28
- }
29
- /**
30
- * Create new file
31
- *
32
- * @param String timestamp
33
- */
34
- public function getTotal($storeId,$dump) {
35
- if($dump == true){
36
- $collection = $this->getProductCollection($storeId);
37
- } else {
38
- $collection = Mage::getModel('sync/queue')->getCollection()->setOrder('id', 'DESC');
39
- }
40
- $total = $collection->count();
41
- return $total;
42
- }
43
-
44
- public function getDomain() {
45
- $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
46
- $format_url = explode("://", $url);
47
- $format_domain = str_replace(".", "_", $format_url[1]);
48
- $temp = explode("/", $format_domain);
49
- $domain = $temp[0];
50
-
51
- return $domain;
52
- }
53
- public function createProductFeed($storeId,$dump) {
54
- $domain = $this->getDomain();
55
- $products = array();
56
- $total = $this->getTotal($storeId,$dump);
57
- $type = $dump ? "dump" : "updates";
58
- $status = $this->isProductFeedProceesed($type);
59
- $exist_feed = $this->getFeedFile($storeId,$type);
60
- if(isset($exist_feed)) {
61
- return false;
62
- }
63
- if(!$status) {
64
- return array( "status" => false,"message"=> "Already some feed creation process in queue. Please try again later.");
65
- }
66
- $this->checkAndCreateFolder($this->default_location);
67
- if(isset($total)) {
68
- $name = md5(microtime());
69
- if($dump == true){
70
- $name = 'dump'.'-'.$name;
71
- $file = $this->file_path . $domain . '-'. $name . '-'.$storeId.'-'.$total.'.jsonl';
72
- } else {
73
- $name = 'updates'.'-'.$name;
74
- $file = $this->file_path . $domain . '-'. $name . '-'.$storeId.'-'.$total.'.jsonl';
75
- }
76
- $this->setAllowCreateFolders(true);
77
- $this->open(array('path' => $this->file_path));
78
- $this->streamOpen($file, 'w+');
79
- $this->streamClose();
80
- }
81
- return array("status" => true,
82
- "message" => $name.'.jsonl');
83
- }
84
- /**
85
- * Retuns finished product feed details
86
- *
87
- * @return Array finished files
88
- */
89
- public function getFinishedProductFeed() {
90
- $files = $this->getAllProductFeed();
91
- $finishd_files = array();
92
- foreach ($files as $key => $value) {
93
- if (!is_dir($this->file_path . $value) ) {
94
- if(!preg_match("/^\./", $value)) {
95
- $file_status = explode( '-', $value );
96
- if(count($file_status) == 3) {
97
- array_push($finishd_files, $value);
98
- }
99
- }
100
- }
101
- }
102
- return $finishd_files;
103
- }
104
- /**
105
- * Delete given file
106
- *
107
- * @param String file name
108
- */
109
- public function deleteProductFeed($filename) {
110
- if (!unlink($this->file_path . $filename)) {
111
- return array( "status" => false,"message"=>"Error while deleting the file ".$filename);
112
- } else {
113
- return array("status" => true,"message"=>"The file '".$filename. "' has been deleted successfully.");
114
- }
115
- }
116
- /**
117
- * Return file meta details from tagalys media directory
118
- *
119
- * @return Object file meta details
120
- */
121
- public function getProductFeedMetaDetails($feed= null) {
122
- $file_meta= new stdClass();
123
- if(is_null($feed)) {
124
- $files = $this->getAllProductFeed();
125
- } else {
126
- $files = $feed;
127
- $file_status = explode( '-', $files );
128
- if(count($file_status) == 3) {
129
- return true;
130
- }
131
- }
132
- foreach ($files as $key => $value) {
133
- if (!is_dir($this->file_path . $value) ) {
134
- if(!preg_match("/^\./", $value)) {
135
- $file_status = explode( '-', $value );
136
- if(count($file_status) > 4) {
137
- $meta_temp = explode( '.', $file_status[4]);
138
- $total = $meta_temp[0]; //explode('.', $file_status[1]);
139
- $file_meta->name = $value;
140
- $file_meta->store = $file_status[3];
141
- $file_meta->uniq_name =$file_status[2];
142
- $file_meta->type = $file_status[1];
143
- $file_meta->domain = $file_status[0];
144
- $file_meta->total = (int) $total;
145
- if(preg_match("/^[0-9]+$/",$total)) {
146
- $file_meta->total = (int) $total;
147
- $file_meta->status = null;
148
- } else {
149
- $file_meta->total = null;
150
- $file_meta->status = $total;
151
- }
152
- return $file_meta;
153
- }
154
- }
155
- }
156
- }
157
- return $file_meta_arr;
158
- }
159
- /**
160
- * Update product feed content
161
- */
162
- public function updateProductFeed() {
163
- try {
164
- $current_domain = $this->getDomain();
165
-
166
- $pages = 0;
167
- $page_done = 0;
168
- $products_done = 0;
169
- $total = 0;
170
- $page_no = 0;
171
- $file_meta = $this->getProductFeedMetaDetails();
172
- if (empty($file_meta)) {
173
- return false;
174
- }
175
- $helper = Mage::helper("sync/service");
176
- $file_domain = $file_meta->domain;
177
-
178
- if ($current_domain != $file_domain) {
179
- return false;
180
- }
181
- if($file_meta->type == "dump") {
182
- $total = $this->getTotal($file_meta->store, true);
183
-
184
- } else {
185
- $total = Mage::getModel('sync/queue')->getCollection()->count();
186
- }
187
- $pages = $total/self::PAGE_LIMIT;
188
- $feed_file = $this->getFeedFile($file_meta->store, "dump");
189
-
190
- if (!empty($file_meta->type)) {
191
- $fp = file((String)$this->file_path.$file_meta->domain.'-'.$file_meta->type.'-'.$file_meta->uniq_name.'-'.$file_meta->store.'-processing.jsonl', FILE_SKIP_EMPTY_LINES);
192
- $line_count = count($fp);
193
- $page_no = $pages - (($total - $line_count)/self::PAGE_LIMIT);
194
- if (is_float($page_no)) {
195
- $page_no = round($page_no + 1);
196
- }
197
- }
198
-
199
- if($file_meta->status != "processing" && $file_meta->type == "dump" ) {
200
-
201
- rename($this->file_path . $file_meta->name, $this->file_path . $file_meta->domain.'-'.$file_meta->type.'-'.$file_meta->uniq_name.'-'.$file_meta->store.'-processing.jsonl');
202
-
203
- $file = $this->file_path.$file_meta->domain.'-' . $file_meta->type.'-'.$file_meta->uniq_name.'-'.$file_meta->store.'-processing.jsonl';
204
-
205
- } else {
206
- if ($file_meta->type == "dump")
207
- $file = $this->file_path .$file_meta->domain.'-'. $file_meta->type.'-'.$file_meta->uniq_name.'-'.$file_meta->store.'-processing.jsonl';
208
- if(file_exists($file)){
209
-
210
- if($file_meta->type == "dump") {
211
- $this->open(array('path' => $this->file_path));
212
- $this->streamOpen($file, 'a');
213
- $feeds = Mage::getModel('catalog/product')->getCollection();
214
- if (isset($pages) && $pages > 0) {
215
- if (is_float($pages)) {
216
- $pages = round($pages + 1);
217
- }
218
- for ($i = $page_no ; $i <= $pages; $i++) {
219
- $products_count = $i == 1 ? 1 : ($i-1)*self::PAGE_LIMIT;
220
- $collection = $this->getProductCollectionByPage($file_meta->store,$i);
221
- foreach ($collection as $product) {
222
-
223
- $simpleProduct = (array) $helper->getSingleProductWithoutPayload($product->getId());
224
- $this->streamWrite( json_encode(array("perform" => "index", "payload" => $simpleProduct)) ."\r\n");
225
- $products_count = ($products_count) + 1;
226
- $this->updateStatusFile($file_meta->store, $products_count) ;
227
- }
228
- $page_done = $i;
229
-
230
- }
231
- }
232
- $this->streamClose();
233
- }
234
-
235
- }
236
- if($page_done == $pages && $file_meta->type == "dump") {
237
-
238
- $fp = file((String)$this->file_path.$file_meta->domain.'-'.$file_meta->type.'-'.$file_meta->uniq_name.'-'.$file_meta->store.'-processing.jsonl', FILE_SKIP_EMPTY_LINES);
239
- $line_count = count($fp);
240
- $finished_file_name = $file_meta->domain.'-'.$file_meta->type.'-'. $file_meta->uniq_name.'-'.$file_meta->store.'.jsonl';
241
- rename($file, $this->file_path.$file_meta->domain.'-' . $file_meta->type.'-'. $file_meta->uniq_name.'-'.$file_meta->store.'.jsonl');
242
-
243
- if($line_count > 0) {
244
- $this->notify_tagalys($finished_file_name, $line_count, $file_meta->store, $file_meta->type);
245
- } else {
246
- $this->deleteProductFeed($finished_file_name);
247
- }
248
-
249
-
250
- }
251
- }
252
- if($file_meta->type == "updates" ) {
253
- $collection = (array) $helper->getProductUpdate($total, $file_meta->store);
254
- $i = 0;
255
- $files = Mage::helper("sync/tagalysFeedFactory")->getAllProductFeed("updates");
256
- foreach ($files as $key => $value) {
257
- $products_done = 0;
258
- $file_meta = Mage::helper("sync/tagalysFeedFactory")->getProductFeedMetaDetails(array($key =>$value));
259
- if($file_meta->status != "processing" ) {
260
- rename(Mage::getBaseDir('media'). DS .'tagalys'. DS . $file_meta->name, Mage::getBaseDir('media'). DS .'tagalys'. DS .$file_meta->domain.'-'. $file_meta->type.'-'.$file_meta->uniq_name.'-'.$file_meta->store.'-processing.jsonl');
261
- $file = Mage::getBaseDir('media'). DS .'tagalys'. DS .$file_meta->domain.'-'. $file_meta->type.'-'.$file_meta->uniq_name.'-'.$file_meta->store.'-processing.jsonl';
262
- } else {
263
- $file = Mage::getBaseDir('media'). DS .'tagalys'. DS .$file_meta->domain.'-' . $file_meta->type.'-'.$file_meta->uniq_name.'-'.$file_meta->store.'-processing.jsonl';
264
- }
265
-
266
- $this->open(array('path' => Mage::getBaseDir('media'). DS .'tagalys'. DS));
267
- $this->streamOpen($file, 'a');
268
- foreach ($collection as $product) {
269
-
270
- $this->streamWrite( json_encode($product) ."\r\n");
271
- $i = $i + 1;
272
- $products_done = $i;
273
- }
274
- $this->streamClose();
275
- if($products_done == $total) {
276
- $fp = file((String)$this->file_path.$file_meta->domain.'-'.$file_meta->type.'-'.$file_meta->uniq_name.'-'.$file_meta->store.'-processing.jsonl', FILE_SKIP_EMPTY_LINES);
277
- $line_count = count($fp);
278
- $finished_file_name = $file_meta->domain.'-'.$file_meta->type.'-'. $file_meta->uniq_name.'-'.$file_meta->store.'.jsonl';
279
- rename($file, $this->file_path .$file_meta->domain.'-'. $file_meta->type.'-'. $file_meta->uniq_name.'-'.$file_meta->store.'.jsonl');
280
-
281
- if($line_count > 0) {
282
- $this->notify_tagalys($finished_file_name, $line_count, $file_meta->store, $file_meta->type);
283
- } else {
284
- $this->deleteProductFeed($finished_file_name);
285
- }
286
- }
287
- }
288
-
289
- }
290
- }
291
- catch (Exception $e){
292
- Mage::log("TagalysControllerException".print_r($e->getMessage()), null, "tagalys-exception.log");
293
- }
294
- }
295
- public function updateStatusFile($storeId, $products_count) {
296
- $fp = fopen( $this->file_path.'tagalys-sync-progress-'.$storeId.'.json', 'w');
297
- fwrite($fp, $products_count);
298
- fclose($fp);
299
-
300
- }
301
- public function notify_tagalys($filename, $count, $storeId, $type) {
302
- $service = Mage::getSingleton("sync/client");
303
- $params["store_id"] = $storeId;
304
-
305
- $baseUrl = "";
306
- $webUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
307
- $mediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
308
-
309
- if (strpos($mediaUrl, $webUrl) === false) {
310
- $baseUrl = $webUrl . 'media/';
311
- } else {
312
- $baseUrl = $mediaUrl;
313
- }
314
-
315
- $tagalys_feed_response = $service->notify_tagalys(array("link" => $baseUrl."tagalys/".$filename, "updates_count" => $count, "store" => $storeId, "callback_url" => Mage::getUrl('tagalys/feed/indexStatus/')), $type); //to-do
316
-
317
- $this->setInitSyncDone($storeId);
318
- Mage::dispatchEvent('tagalys_event'); //to-check to-do blank
319
- return true;
320
- }
321
- public function setInitSyncDone($storeId) {
322
- $data = array('path' => "sync-".$storeId,'value' => 1);
323
- $collection = Mage::getModel('tagalys_core/config')->getCollection()->addFieldToFilter('path',"sync-".$storeId)->getFirstItem();
324
- if($id = $collection->getId()){
325
- $model = Mage::getModel('tagalys_core/config')->load($id)->addData($data);
326
- try {
327
- $model->setId($id)->save();
328
- } catch (Exception $e){
329
- Mage::log("TagalysControllerException".print_r($e->getMessage()), null, "tagalys-exception.log");
330
- }
331
- } else {
332
- $model = Mage::getModel("tagalys_core/config")->setData($data);
333
- try {
334
- $insertId = $model->save()->getId();
335
- } catch (Exception $e){
336
- Mage::log("TagalysControllerException".print_r($e->getMessage()), null, "tagalys-exception.log");
337
- }
338
- }
339
- }
340
- /**
341
- * Return product collection by given timestamp
342
- *
343
- * @param String timestamp
344
- * @return Object production collection
345
- */
346
- public function getProductCollectionByPage($storeId, $page) {
347
- // $_storeId = Mage::app()
348
- // ->getWebsite(true)
349
- // ->getDefaultGroup()
350
- // ->getDefaultStoreId();
351
- $collection = Mage::getResourceModel('catalog/product_collection')
352
- ->addAttributeToFilter('status',1) //only enabled product
353
- ->addAttributeToFilter('visibility',array("neq"=>1)) //except not visible individually
354
- ->setStoreId($storeId)
355
- ->addStoreFilter($storeId)
356
- ->setPageSize(self::PAGE_LIMIT)
357
- ->addAttributeToSelect('*')
358
- ->setCurPage($page);
359
- return $collection;
360
- }
361
- /**
362
- * Return product collection by given timestamp
363
- *
364
- * @param String timestamp
365
- * @return Object production collection
366
- */
367
- public function getProductCollection($storeId) {
368
- // $_storeId = Mage::app()
369
- // ->getWebsite(true)
370
- // ->getDefaultGroup()
371
- // ->getDefaultStoreId();
372
- $collection = Mage::getResourceModel('catalog/product_collection')
373
- ->addAttributeToFilter('status',1) //only enabled product
374
- ->addAttributeToFilter('visibility',array("neq"=>1)) //except not visible individually
375
- ->setStoreId($storeId)
376
- ->addStoreFilter($storeId)
377
-
378
- ->addAttributeToSelect('*');
379
- return $collection;
380
- }
381
- /**
382
- * Return all file and directory from tagalys media directory
383
- *
384
- * @return Array files and directory
385
- */
386
- public function getAllProductFeed($type = null) {
387
- $feeds = scandir($this->default_location);
388
- $feed_files = array();
389
- if ($type == null) {
390
- foreach ($feeds as $key => $value) {
391
- if (!is_dir($this->file_path . $value) ) {
392
- if(!preg_match("/^\./", $value)) {
393
- $file_status = explode( '-', $value );
394
- if($file_status[1] == "dump" || $file_status[1] == "updates")
395
- $feed_files[] = $value;
396
- }
397
- }
398
- }
399
- } else {
400
- foreach ($feeds as $key => $value) {
401
- if (!is_dir($this->file_path . $value) ) {
402
- if(!preg_match("/^\./", $value)) {
403
- $file_status = explode( '-', $value );
404
- if($file_status[1] == $type ) {
405
- $feed_files[] = $value;
406
- }
407
- }
408
- }
409
- }
410
- }
411
-
412
-
413
- return $feed_files;
414
- }
415
- /**
416
- * Helper method to check is there any feed to process.
417
- * @return Bool status of the feed queue
418
- */
419
- public function isProductFeedProceesed($type) {
420
- $feed_count = 0;
421
- $files = $this->getAllProductFeed($type);
422
- foreach ($files as $key => $value) {
423
- if (!is_dir($this->file_path . $value) ) {
424
- if(!preg_match("/^\./", $value)) {
425
- $file_status = explode( '-', $value );
426
- if(count($file_status) > 4) {
427
- $feed_count++;
428
- }
429
- }
430
- }
431
- }
432
- $feed_type_count = count(Mage::helper("sync/data")->getSelectedStore());
433
- if($feed_count == 0) {
434
- return true;
435
- } elseif ($feed_type_count != $feed_count) {
436
- return true;
437
- } else {
438
- return false;
439
- }
440
- }
441
- public function getFeedFile($storeId, $type){
442
- $files = $this->getAllProductFeed($type);
443
- foreach ($files as $key => $value) {
444
- if (!is_dir($this->file_path . $value) ) {
445
- $file_status = explode( '-', $value );
446
- if($file_status[1] == $type && (int)$file_status[3] == $storeId) {
447
- return $value;
448
- }
449
- }
450
- }
451
- }
452
- public function getFeedProgress($storeId, $feed) {
453
- $line_count = file_get_contents(Mage::getBaseDir("media"). DS ."tagalys" . DS."tagalys-sync-progress-".$storeId.".json");
454
- fclose($Path);
455
- $total = $this->getTotal($storeId, true);
456
- if($line_count == $total || $storeId == null) {
457
- $percent = 100;
458
- } else {
459
- $percent = ($line_count / $total) * 100;
460
- }
461
- return number_format( min((int)$percent,100), 0 );
462
- }
463
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/Model/Adminhtml/System/Config/Backend/Tagalys/Cron.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Sync_Model_Adminhtml_System_Config_Backend_Tagalys_Cron extends Mage_Core_Model_Config_Data
4
- {
5
- const CRON_STRING_PATH = 'crontab/jobs/tagalys_updates_cron/schedule/cron_expr';
6
- const CRON_MODEL_PATH = 'crontab/jobs/tagalys_updates_cron/run/model';
7
-
8
- const CRON_FEED_STRING_PATH = 'crontab/jobs/tagalys_resync_cron/schedule/cron_expr';
9
- const CRON_FEED_MODEL_PATH = 'crontab/jobs/tagalys_resync_cron/run/model';
10
-
11
- public function setCron()
12
- {
13
-
14
- $core_helper = Mage::helper('tagalys_core');
15
-
16
- $update_frequency = $core_helper->getTagalysConfig("tagalys_updates_cron_time");
17
- $resync_frequency = $core_helper->getTagalysConfig("feed_cron_time");
18
-
19
-
20
- try {
21
- Mage::getModel('core/config_data')
22
- ->load(self::CRON_STRING_PATH, 'path')
23
- ->setValue($update_frequency)
24
- ->setPath(self::CRON_STRING_PATH)
25
- ->save();
26
-
27
- Mage::getModel('core/config_data')
28
- ->load(self::CRON_FEED_STRING_PATH, 'path')
29
- ->setValue($resync_frequency)
30
- ->setPath(self::CRON_FEED_STRING_PATH)
31
- ->save();
32
-
33
- }
34
- catch (Exception $e) {
35
- throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
36
-
37
- }
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/Model/Client.php DELETED
@@ -1,141 +0,0 @@
1
- <?php
2
- class Tagalys_Sync_Model_Client extends Mage_Core_Model_Abstract
3
- {
4
- protected $_api_key;
5
- protected $_api_server;
6
- protected $_product_feed;
7
- protected $_sync = array();
8
- protected $_error = true;
9
- protected function _construct(){
10
- $this->_config = Mage::helper('tagalys_core');
11
- $this->_api_server = $this->_config->getTagalysConfig("api_server");
12
- $this->_private_api_key = $this->_config->getTagalysConfig("private_api_key");
13
- $this->_client_code = $this->_config->getTagalysConfig("client_code");
14
- $this->_product_dump_feed = Mage::getStoreConfig('tagalys_endpoint/endpoint/product_feed');
15
- $this->_product_updates_feed = Mage::getStoreConfig('tagalys_endpoint/endpoint/sync_updates');
16
- $this->_search_status = Mage::getStoreConfig('tagalys_endpoint/endpoint/sync_feed_progress');
17
- $this->_client_config = Mage::getStoreConfig('tagalys_endpoint/endpoint/client_config');
18
- $this->_api_auth = Mage::getStoreConfig('tagalys_endpoint/endpoint/api_auth');
19
- }
20
- protected function getUrl($e_type) {
21
- switch ($e_type) {
22
- case 'client_config':
23
- $url = $this->_api_server.$this->_client_config;
24
- return $url;
25
- break;
26
- case 'api_auth':
27
- $url = $this->_api_server.$this->_api_auth;
28
- return $url;
29
- break;
30
- case 'dump':
31
- $url = $this->_api_server.$this->_product_dump_feed;
32
- return $url;
33
- break;
34
- case 'updates':
35
- $url = $this->_api_server.$this->_product_updates_feed;
36
- return $url;
37
- break;
38
- case 'sync_feed_progress':
39
- $url = $this->_api_server.$this->_search_status;
40
- return $url;
41
- break;
42
- default:
43
- break;
44
- }
45
- }
46
- protected function createAuth($payload) {
47
- if(!empty($payload["store"])) {
48
- $request = array(
49
- 'client_code' => $this->_client_code,
50
- 'api_key' => $this->_private_api_key,
51
- 'store_id' => $payload["store"] //$store_id
52
- );
53
- } else {
54
- $request = array(
55
- 'client_code' => $this->_client_code,
56
- 'api_key' => $this->_private_api_key
57
- );
58
- }
59
-
60
- $payload["identification"] = $request;
61
- return json_encode($payload);
62
- }
63
-
64
- protected function initAuth($payload) {
65
- $this->_api_server= $payload["api_server"];
66
- $request = array(
67
- 'client_code' => $payload["client_code"],
68
- 'private_api_key' => $payload["private_api_key"],
69
- 'public_api_key' => $payload["public_api_key"],
70
- 'api_server'=> $payload["api_server"]
71
- );
72
- //unset($payload);
73
- $payload["identification"] = $request;
74
- return json_encode($payload);
75
- }
76
- public function notify_tagalys($payload, $type, $init = false) {
77
- $this->_api_server= empty($this->_api_server)? $payload["api_server"] : $this->_api_server;
78
- unset($payload["key"]);
79
- unset($payload["form_key"]);
80
- try {
81
- if($type == "api_auth") {
82
- $payloadData = $this->initAuth($payload);
83
- } else {
84
- $payloadData = $this->createAuth($payload);
85
- }
86
- $url = $this->getUrl($type);
87
- return $this->_payloadAgent($url, ($payloadData));
88
-
89
- } catch(Exception $e) {
90
- }
91
- }
92
- public function is_tagalys_search_ready($store_id) {
93
- try {
94
- $url = $this->getUrl("sync_feed_progress");
95
- $payload["store"] = $store_id;
96
- $payloadData = $this->createAuth($payload);
97
- return $this->_payloadAgent($url,($payloadData));
98
-
99
- } catch(Exception $e) {
100
- }
101
- }
102
- private function _getAgent($url) {
103
- $agent = curl_init($url);
104
- return $agent;
105
- }
106
-
107
- private function _payloadAgent($url, $payload) {
108
- $agent = $this->_getAgent($url);
109
- curl_setopt( $agent, CURLOPT_POSTFIELDS, $payload );
110
- curl_setopt($agent, CURLOPT_POST,1);
111
- curl_setopt( $agent, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
112
- curl_setopt( $agent, CURLOPT_RETURNTRANSFER, true );
113
- curl_setopt( $agent, CURLOPT_SSL_VERIFYPEER, 0 );
114
- curl_setopt($agent, CURLOPT_TIMEOUT, $this->timeout);
115
- $result = curl_exec($agent);
116
- $info = curl_getinfo($agent);
117
-
118
-
119
- if(curl_errno($agent)) {
120
- $this->_error = true;
121
- } else {
122
- $this->_error = false;
123
- if (empty($result)) {
124
- $this->_error = true;
125
- }
126
- }
127
- curl_close($agent);
128
-
129
- if (!$this->_error) {
130
- $decoded = json_decode($result, true);
131
- if($decoded["status"] == "OK") {
132
- return $decoded;
133
- } else {
134
- return array();
135
- }
136
- } else {
137
- return array();
138
- //return json_decode($result, true);
139
- }
140
- }
141
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/Model/Dataflow/Convert/Adapter/Io.php DELETED
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Sync_Model_Dataflow_Convert_Adapter_Io extends Mage_Dataflow_Model_Convert_Adapter_Io
4
- {
5
- public function save() {
6
-
7
- try {
8
- $bulkimport = new Mage_Core_Model_Config();
9
- $bulkimport->saveConfig('sync/product/import_status', "disable", "default", "disable");
10
- } catch (Exception $e) {
11
-
12
- }
13
-
14
- return parent::save();
15
- }
16
-
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/Model/Mysql4/Queue.php DELETED
@@ -1,8 +0,0 @@
1
- <?php
2
- class Tagalys_Sync_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
3
- {
4
- protected function _construct()
5
- {
6
- $this->_init("sync/queue", "id");
7
- }
8
- }
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/Model/Mysql4/Queue/Collection.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
- class Tagalys_Sync_Model_Mysql4_Queue_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
- {
4
-
5
- public function _construct(){
6
- $this->_init("sync/queue");
7
- }
8
-
9
- }
10
-
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/Model/Observer.php DELETED
@@ -1,172 +0,0 @@
1
- <?php
2
- class Tagalys_Sync_Model_Observer extends Varien_Object
3
- {
4
- protected $_queue;
5
- protected $_feed;
6
- protected $_helper;
7
- protected $_bulkImport;
8
- function __construct()
9
- {
10
- $this->_config = Mage::helper('tagalys_core');
11
- $this->_status = $this->_config->getTagalysConfig("is_tagalys_active");
12
- $this->_queue = Mage::getModel('sync/queue');
13
- $this->_feed = Mage::helper("sync/tagalysFeedFactory");
14
- $this->_helper = Mage::helper("sync/service");
15
- $this->_sync_helper = Mage::helper("sync/data");
16
-
17
- }
18
- public function updatesCron() {
19
- $queue_size = Mage::getModel('sync/queue')->getCollection()->getSize();
20
- if($queue_size > 0) {
21
- foreach ($this->_sync_helper->getSelectedStore() as $key) {
22
- $response = $this->_feed->getUpdatesDump($key);
23
- }
24
- }
25
- return true;
26
- }
27
-
28
- public function resyncCron() {
29
- foreach ($this->_sync_helper->getSelectedStore() as $key) {
30
- $resync_required = Mage::helper('tagalys_core')->getTagalysConfig('product_sync_required_'.$key);
31
- if($resync_required) {
32
- $response = Mage::helper("sync/tagalysFeedFactory")->createProductFeed($key,true);;
33
- }
34
- }
35
-
36
- return true;
37
- }
38
- public function createProductFeed(Mage_Cron_Model_Schedule $schedule)
39
- {
40
- $feeds = $this->_feed->getAllProductFeed();
41
- if(!empty($feeds)) {
42
- $this->_feed->updateProductFeed();
43
- }
44
- }
45
- public function productDelete(Varien_Event_Observer $observer)
46
- {
47
- try {
48
- $product = $observer->getEvent()->getProduct();
49
- $product_id = $product->getId();
50
- if(!$product_id) {
51
- return;
52
- }
53
- //Check already record is exists in queue table
54
- $existingProduct = $this->_queue->load($product_id,'product_id');
55
- $_id = $existingProduct->getId();
56
- if(empty($_id)) {
57
- $data = array(
58
- "product_id" => $product_id
59
- );
60
- $this->_queue->setData($data);
61
- try {
62
- $queue_id = $this->_queue->save()->getId();
63
- } catch(Exception $e) {
64
- Mage::log("Sync Queue: error adding product [ ".$product." ] in queue", null, "tagalys.log");
65
- }
66
- } else {
67
- Mage::log("Sync: product already in queue [ ". $product_id." ]", null, "tagalys.log");
68
- }
69
- } catch (Exception $e) {
70
- Mage::log("Sync: product delete error", null, "tagalys.log");
71
- }
72
- }
73
- public function productUpdate(Varien_Event_Observer $observer)
74
- {
75
- try {
76
- $product = $observer->getEvent()->getProduct();
77
- $product_id = $product->getId();
78
- if(!$product_id) {
79
- return;
80
- }
81
- //Check already record is exists in queue table
82
- $existingProduct = $this->_queue->load($product_id,'product_id');
83
- $_id = $existingProduct->getId();
84
- if(empty($_id)) {
85
- $data = array(
86
- "product_id" => $product_id
87
- );
88
- $this->_queue->setData($data);
89
- try {
90
- $queue_id = $this->_queue->save()->getId();
91
- } catch(Exception $e) {
92
- Mage::log("Sync Queue: error adding product [ ".$product_id." ] in queue", null, "tagalys.log");
93
- }
94
- }
95
- } catch (Exception $e) {
96
- Mage::log("Sync: product update error", null, "tagalys.log");
97
- }
98
- }
99
- public function saleOrderComplete(Varien_Event_Observer $observer)
100
- {
101
- try {
102
- $payment = $observer->getEvent()->getPayment();
103
- $items = $payment->getOrder()->getItemsCollection();
104
- foreach($items as $item) {
105
- $product = $item->getProduct();
106
- $product_id = $product->getId();
107
- if(!$product_id) {
108
- return;
109
- }
110
- //Check already record is exists in queue table
111
- $existingProduct = $this->_queue->load($product_id,'product_id');
112
- $_id = $existingProduct->getId();
113
- if(empty($_id)) {
114
- $data = array(
115
- "product_id" => $product_id
116
- );
117
- $this->_queue->setData($data);
118
- try {
119
- $queue_id = $this->_queue->save()->getId();
120
- } catch(Exception $e) {
121
- Mage::log("Sync Queue: error adding product [ ".$product_id." ] in queue", null, "tagalys.log");
122
- }
123
- }
124
- }
125
- } catch (Exception $e) {
126
- Mage::log("Sync: ". $e->getMessage(), null, "tagalys.log");
127
- }
128
- }
129
- public function productImportByDataFlowStart(Varien_Event_Observer $observer)
130
- {
131
- Mage::log("Product Import By Data Flow Start", null, "tagalys.log");
132
- }
133
- public function getProductDump(Varien_Event_Observer $observer)
134
- {
135
- $this->_feed->updateProductFeed();
136
- }
137
- public function productsImported(Varien_Event_Observer $observer) {
138
- try {
139
- if($this->_bulkImport == "enable") {
140
- return true;
141
- }
142
- $products = array();
143
- $adapter_data = $observer->getEvent()->getData('adapter');
144
- Mage::log($observer->getEvent(), null, 'sync.log');
145
- $behavior = $adapter_data->getBehavior();
146
- if ($behavior == "delete") {
147
- while ($bunch = $adapter_data->getNextBunch()) {
148
- foreach ($bunch as $rowNum => $rowData) {
149
- $products[] = 'sku-'.$rowData['sku'];
150
- }
151
- }
152
- } else {
153
- $products = $adapter_data->getAffectedEntityIds();
154
- }
155
- if(!empty($products)) {
156
- foreach ($products as $key => $value) {
157
- $existingProduct = Mage::getModel('sync/queue')->load($value,'product_id');
158
- $_id = $existingProduct->getId();
159
- if(!isset($_id)) {
160
- $data = array(
161
- "product_id" => $value
162
- );
163
- $this->_queue->setData($data);
164
- $queue_id = $this->_queue->save()->getId();
165
- }
166
- }
167
- }
168
- } catch (Exception $e) {
169
- Mage::log("Sync: ". $e->getMessage(), null, "tagalys.log");
170
- }
171
- }
172
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/Model/ProductDetails.php DELETED
@@ -1,239 +0,0 @@
1
- <?php
2
- class Tagalys_Sync_Model_ProductDetails extends Mage_Core_Model_Abstract {
3
-
4
- protected $syncfield;
5
- protected $inventorySyncField;
6
-
7
- public function getProductFields($productId, $store = null) {
8
- try {
9
- $this->_storeId = $store;
10
- $sync_helper = Mage::helper('sync/data');
11
- $core_helper = Mage::helper('tagalys_core');
12
- $product = Mage::getModel('catalog/product')->load($productId);
13
- if(is_null($this->_storeId)) {
14
- $this->_storeId = Mage::app()->getWebsite(true)->getDefaultGroup()->getDefaultStoreId();
15
- }
16
- Mage::app()->setCurrentStore($this->_storeId);
17
- $productFields = new stdClass();
18
- $attributes = $product->getAttributes();
19
- foreach ($attributes as $attribute) {
20
- if ($attribute->getIsFilterable() || $attribute->getIsSearchable()) {
21
- $attr = $product->getResource()->getAttribute($attribute->getAttributeCode());
22
- if (!$attr->usesSource()) {
23
- $field_val = $attribute->getFrontend()->getValue($product);
24
- if(!is_null($field_val)) {
25
- $productFields->{$attribute->getAttributeCode()} = $attribute->getFrontend()->getValue($product);
26
- }
27
- }
28
- }
29
- }
30
- $productFields->__id = $product->getId();
31
- $productFields->name = $product->getName();
32
- $productFields->link = $product->getProductUrl();
33
- $productFields->sku = $product->getData('sku');
34
- if($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
35
- $arr = $product->getTypeInstance(true)->getChildrenIds($product->getId(), false);
36
- foreach($arr[key($arr)] as $k => $v ) {
37
- $price[] = Mage::getModel('catalog/product')->load($v)->getFinalPrice();
38
- $mrp[] = Mage::getModel('catalog/product')->load($v)->getPrice();
39
- }
40
- $productFields->sale_price = $this->getmultipleCurrency(min($price), true);
41
- $productFields->price = $this->getmultipleCurrency(min($mrp), true);
42
- } else {
43
- $productFields->sale_price = $this->getmultipleCurrency($product->getFinalPrice(), true);
44
- $productFields->price = $this->getmultipleCurrency($product->getPrice(), true);
45
- // $productFields->test_price = $product->getData('test_price');
46
- }
47
-
48
- $productFields->image_url = Mage::getModel('catalog/product_media_config')->getMediaUrl( $product->getImage());
49
- $fields = array( 'created_at');
50
- foreach ($fields as $key => $name) {
51
-
52
- $fieldValue = $product->getResource()->getAttribute($name)->getFrontend()->getValue($product);
53
- $utc = new DateTime((string)$fieldValue);
54
- $productFields->introduced_at = $utc->format(DateTime::ATOM);
55
- }
56
-
57
- // $productFields->parent_id = $this->getProductParent($productId);
58
- $productFields->in_stock = Mage::getModel('catalog/product')->load($product->getId())->isSaleable();
59
-
60
- return $productFields;
61
-
62
- } catch (Exception $e) {
63
-
64
- }
65
- }
66
- public function getProductType($productId) {
67
- $product = Mage::getModel('catalog/product')->load($productId);
68
- $productType = $product->getTypeId();
69
- return $productType;
70
- }
71
- public function getProductParent($productId) {
72
- $tagalys_parent_id = array();
73
- $product = Mage::getModel('catalog/product')->load($productId);
74
- $parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($productId);
75
- if(!$parentIds) {
76
- $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($productId);
77
- $parentProducts = Mage::getModel('catalog/product')
78
- ->getCollection()
79
- ->addAttributeToSelect('sku')
80
- ->addAttributeToFilter('entity_id', array('in' => $parentIds))
81
- ->load();
82
- $parents = array();
83
- foreach ($parentProducts as $key => $pro) {
84
- array_push($parents, $pro->getId());
85
- }
86
- if(isset($parents[0])) {
87
- $tagalys_parent_id = $parents;
88
- }
89
- }
90
- return $tagalys_parent_id;
91
- }
92
- public function getProductAttributes($productId, $store_id, $unsyncFields) {
93
-
94
- $product = Mage::getModel('catalog/product')->load($productId);
95
- $attribute_options_id = null;
96
- $attriute_option_value = null;
97
- $type = $product->getTypeId();
98
- $attributeObj = array();
99
- $product->setStoreId($store_id);
100
- $categories = Mage::helper('sync/data')->getProductTreeCat($productId);
101
- $attributeObj[] = array("tag_set" => array("id" => "__categories", "label" => "categories" ),"items" => ($categories));
102
-
103
- if(true) {
104
- $attributes = $product->getAttributes();
105
-
106
- foreach ($attributes as $attribute) {
107
-
108
- if ($attribute->getIsFilterable() || $attribute->getIsSearchable()) {
109
-
110
- $attr = $product->getResource()->getAttribute($attribute->getAttributeCode());
111
- if ($attr->usesSource()) {
112
- $attriute_option_value =$attribute->getFrontend()->getValue($product);
113
- $attribute_options_id = $attr->getSource()->getOptionId($attriute_option_value);
114
- }
115
- $values['label'] = $attriute_option_value;
116
- $values['id'] = $attribute_options_id;
117
- if($values && !is_null($attribute_options_id) && $values['label'] != "N/A"){
118
- $attributeObj[] = array("tag_set" => array("id" => $attribute->getAttributeCode(), "label" => $attribute->getFrontend()->getLabel($product) ),"items" => array($values));
119
- }
120
- }
121
- }
122
- }
123
- if($type === "configurable") {
124
- $config = $product->getTypeInstance(true);
125
- foreach($config->getConfigurableAttributesAsArray($product) as $attributes)
126
- {
127
- $items = array();
128
- foreach($attributes["values"] as $val){
129
- $attr = $product->getResource()->getAttribute($attributes['attribute_code']);
130
- if ($attr->getIsFilterable() || $attr->getIsSearchable()) {
131
- $attriute_option_value = $val["label"];
132
- $attribute_options_id = $attr->getSource()->getOptionId($attriute_option_value);
133
- }
134
- $values['label'] = $attriute_option_value;
135
- $values['id'] = $attribute_options_id;
136
- $items[] = $values;
137
- }
138
- if(!empty($values) && $values['label'] != "N/A") {
139
- $attributeObj[] = array( "tag_set" => array("id" => $attributes['attribute_code'], "label" => $attributes["label"]),"items" => $items);
140
- }
141
-
142
- }
143
- }
144
-
145
- return ($attributeObj);
146
- }
147
- public function getProductSyncField() {
148
- try {
149
- if(empty($this->syncfield)) {
150
- $attributes = Mage::getResourceModel('catalog/product_attribute_collection')->getItems();
151
- $default_field = array();
152
- foreach ($attributes as $attribute) {
153
- $code = $attribute->getAttributecode();
154
- //$label = $attribute->getFrontendLabel();
155
- if(isset($code)) {
156
- array_push($default_field, $code);
157
- }
158
- }
159
- $unsync_field = $this->_getProductUnSyncField();
160
- $this->syncfield = array_diff($default_field, $unsync_field);
161
- return $this->syncfield;
162
- }
163
- return $this->syncfield;
164
-
165
- } catch (Exception $e) {
166
-
167
- }
168
- }
169
- protected function _getProductUnSyncField() {
170
- $config = Mage::getStoreConfig('sync/product/sync_fields');
171
- $fields= explode(',',$config);
172
- return $fields;
173
- }
174
- public function getInventorySyncField() {
175
- try {
176
- if(empty($this->inventorySyncField)) {
177
- $helper = Mage::helper("sync/inventory");
178
- $stock_item = $helper->getInventoryStockItemField();
179
- $default_field = array();
180
- foreach ($stock_item as $key => $label) {
181
- if(isset($key)) {
182
- array_push($default_field, $key);
183
- }
184
- }
185
- $unsync_field = $this->_getInventoryUnSyncField();
186
- $this->inventorySyncField = array_diff($default_field, $unsync_field);
187
- return $this->inventorySyncField;
188
- }
189
- return $this->inventorySyncField;
190
- } catch (Exception $e) {
191
- }
192
- }
193
- protected function _getInventoryUnSyncField() {
194
- $config = Mage::getStoreConfig('sync/inventory/inventory_fields');
195
- $fields= explode(',',$config);
196
- return $fields;
197
- }
198
-
199
- //$rootCatId = Mage::app()->getStore()->getRootCategoryId();
200
- public function getFullCategoryTree($parentId, $isChild){
201
- $tree = array();
202
- $allCats = Mage::getModel('catalog/category')->getCollection()
203
- ->addAttributeToSelect('*')
204
- ->addAttributeToFilter('is_active','1')
205
- ->addAttributeToFilter('include_in_menu','1')
206
- ->addAttributeToFilter('parent_id',array('eq' => $parentId));
207
-
208
-
209
- //$children = Mage::getModel('catalog/category')->getCategories(7);
210
- foreach ($allCats as $category)
211
- {
212
- array_push($tree, $category->getName());
213
- if($category->getChildren() != ''){
214
- array_push($tree, $this->getFullCategoryTree($category->getId(), true));
215
- }
216
- }
217
- return $tree;
218
- }
219
-
220
- // echo $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode(); get base currency for api requests
221
- public function getmultipleCurrency($price, $only_base = false) {
222
- $currencyModel = Mage::getModel('directory/currency');
223
- $currencies = $currencyModel->getConfigAllowCurrencies(); // abaliable currency
224
- $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode(); // default code
225
- $defaultCurrencies = $currencyModel->getConfigBaseCurrencies();
226
- $price_array = array();
227
- $rates=$currencyModel->getCurrencyRates($defaultCurrencies, $currencies); // rates of each currency
228
- if($only_base || empty($rates[$baseCurrencyCode])) {
229
- $price_array[$baseCurrencyCode] = 1 * $price;
230
- }
231
- if($only_base) {
232
- return floatval($price);
233
- }
234
- foreach($rates[$baseCurrencyCode] as $key=>$value ) {
235
- $price_array[$key] = $value*$price; // getFinalPrice
236
- }
237
- return $price_array;
238
- }
239
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/Model/Queue.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Sync_Model_Queue extends Mage_Core_Model_Abstract
4
- {
5
- protected function _construct(){
6
-
7
- $this->_init("sync/queue");
8
-
9
- }
10
-
11
- }
12
-
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/controllers/Adminhtml/ImportController.php DELETED
@@ -1,51 +0,0 @@
1
- <?php
2
- require_once 'Mage/ImportExport/controllers/Adminhtml/ImportController.php';
3
-
4
- class Tagalys_Sync_Adminhtml_ImportController extends Mage_ImportExport_Adminhtml_ImportController
5
- {
6
-
7
- public function validateAction() {
8
- //[Custom Changes]
9
- // Mage::log("CSV Import: Validation process started", null, "tagalys.log");
10
- parent::validateAction();
11
- }
12
-
13
- public function startAction() {
14
- // Mage::log("CSV Import: Data import process started", null, "tagalys.log");
15
- $data = $this->getRequest()->getPost();
16
- if ($data) {
17
- $this->loadLayout(false);
18
-
19
- /** @var $resultBlock Mage_ImportExport_Block_Adminhtml_Import_Frame_Result */
20
- $resultBlock = $this->getLayout()->getBlock('import.frame.result');
21
- /** @var $importModel Mage_ImportExport_Model_Import */
22
- $importModel = Mage::getModel('importexport/import');
23
-
24
- try {
25
- $importModel->importSource();
26
- $importModel->invalidateIndex();
27
- $resultBlock->addAction('show', 'import_validation_container')
28
- ->addAction('innerHTML', 'import_validation_container_header', $this->__('Status'));
29
- } catch (Exception $e) {
30
- //[Custom Changes]
31
- // Mage::log("CSV Import: Data import process error", null, "tagalys.log");
32
- $resultBlock->addError($e->getMessage());
33
- $this->renderLayout();
34
- return;
35
- }
36
- //[Custom Changes]
37
- // Mage::log("CSV Import: Data import process success", null, "tagalys.log");
38
- $resultBlock->addAction('hide', array('edit_form', 'upload_button', 'messages'))
39
- ->addSuccess($this->__('Import successfully done.'));
40
- $this->renderLayout();
41
- } else {
42
- //[Custom Changes]
43
- // Mage::log("CSV Import: Record not found", null, "tagalys.log");
44
- $this->_redirect('*/*/index');
45
- }
46
-
47
- Mage::dispatchEvent('catalog_product_import_profile_after', array('adapter' => $this));
48
- return true;
49
- }
50
-
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/controllers/Adminhtml/System/Convert/GuiController.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
- require_once 'Mage/Adminhtml/controllers/System/Convert/GuiController.php';
3
- /**
4
- * Override Admin controller
5
- */
6
- class Tagalys_Sync_Adminhtml_System_Convert_GuiController extends Mage_Adminhtml_System_Convert_GuiController
7
- {
8
- public function runAction() {
9
-
10
- try {
11
- $bulkimport = new Mage_Core_Model_Config();
12
- $bulkimport->saveConfig('sync/product/import_status', "enable", "default", "disable");
13
- } catch (Exception $e) {
14
- Mage::log("TagalysGuiControllerException".print_r($e->getMessage()), null, "tagalys-exception.log");
15
- }
16
-
17
- parent::runAction();
18
- }
19
-
20
- public function batchFinishAction() {
21
- try {
22
- $bulkimport = new Mage_Core_Model_Config();
23
- $bulkimport->saveConfig('sync/product/import_status', "disable", "default", "disable");
24
- } catch (Exception $e) {
25
- Mage::log("TagalysGuiControllerException".print_r($e->getMessage()), null, "tagalys-exception.log");
26
- }
27
- parent::batchFinishAction();
28
- }
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/controllers/Adminhtml/TagalysController.php DELETED
@@ -1,110 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Sync_Adminhtml_TagalysController extends Mage_Adminhtml_Controller_Action
4
- {
5
- const CRON_STRING_PATH = 'crontab/jobs/tagalys_updates_cron/schedule/cron_expr';
6
- const CRON_FEED_STRING_PATH = 'crontab/jobs/tagalys_resync_cron/schedule/cron_expr';
7
-
8
- public function indexAction() {
9
-
10
- $this->_registryObject();
11
- $this->_title('Tagalys Configuration');
12
- $this->loadLayout();
13
- $this->_setActiveMenu('Tagalys/core');
14
- $this->renderLayout();
15
- }
16
-
17
- public function saveAction() {
18
-
19
-
20
- $output = $this->getRequest()->getParams();
21
-
22
- $this->_helper = Mage::helper('tagalys_core');
23
- $is_tagalys_active = $this->_helper->getTagalysConfig("is_tagalys_active");
24
-
25
- if(!empty($output["submit_auth"])){
26
- Mage::dispatchEvent('tagalys_auth_event', array('object'=>$output));
27
- }
28
-
29
-
30
- unset($output["key"]);
31
- unset($output["form_key"]);
32
-
33
- if(!empty($output["submit_signup_next"])) {
34
- Mage::helper('tagalys_core')->setTagalysConfig("is_signup", 1);
35
- }
36
- if(empty($output["tagalys_updates_cron_time"])) {
37
- $output["tagalys_updates_cron_time"] = "*/1 * * * *";
38
- }
39
- if(!empty($output['feed_cron_time'])) {
40
- $output['feed_cron_time'] = $output['feed_cron_time'][1].' '.$output['feed_cron_time'][0].' * * *';
41
- } else {
42
- $output['feed_cron_time'] = "00 01 * * *";
43
- }
44
- if(empty($output["search_box"])) {
45
- $output["search_box"] = "#search";
46
- }
47
-
48
- if(!empty($output["tagalys_updates_cron_time"])) {
49
- try {
50
- Mage::getModel('core/config_data')
51
- ->load(self::CRON_STRING_PATH, 'path')
52
- ->setValue($output["tagalys_updates_cron_time"])
53
- ->setPath(self::CRON_STRING_PATH)
54
- ->save();
55
-
56
- Mage::getModel('core/config_data')
57
- ->load(self::CRON_FEED_STRING_PATH, 'path')
58
- ->setValue($output["tagalys_updates_cron_time"])
59
- ->setPath(self::CRON_FEED_STRING_PATH)
60
- ->save();
61
- }catch (Exception $e){
62
- Mage::log("TagalysControllerException".print_r($e->getMessage()), null, "tagalys-exception.log");
63
- }
64
- }
65
- if(!empty($output["stores_setup"])) {
66
- $output["stores_setup"] = implode(",", $output["stores_setup"]);
67
- }
68
-
69
- foreach ($output as $key => $value) {
70
- if(!preg_match("/^submit_*/i", $key)){
71
- Mage::helper('tagalys_core')->setTagalysConfig($key, $value);
72
- }
73
- }
74
- if(!empty($output["submit_config"]) && $output["submit_config"] != "Save settings") {
75
- Mage::dispatchEvent('tagalys_client_config', array('object'=>$output));
76
- }
77
- if(!empty($output["submit_resync"])) {
78
- $this->_sync_helper = Mage::helper("sync/data");
79
- foreach ($this->_sync_helper->getSelectedStore() as $key) {
80
- $response = Mage::helper("sync/tagalysFeedFactory")->createProductFeed($key,true);;
81
- }
82
- }
83
- if(!empty($output["submit_reconfig"])) {
84
- Mage::dispatchEvent('tagalys_client_config', array('object'=>$output));
85
- }
86
- if(empty($output["submit_resync"]) && empty($output["submit_reconfig"])) {
87
- if(Mage::helper('tagalys_core')->getTagalysConfig("is_tsearchsuggestions_active") || Mage::helper('tagalys_core')->getTagalysConfig("is_tsearch_active"))
88
- Mage::getSingleton('core/session')->addSuccess("Your preference has been saved.");
89
- } else {
90
- Mage::getSingleton('core/session')->addSuccess($output["submit_resync"] ? $output["submit_resync"]." Success." : $output["submit_reconfig"]. " Success.");
91
- }
92
- return $this->_redirect('*/tagalys');
93
- }
94
-
95
- /**
96
- * registry form object
97
- */
98
- protected function _registryObject() {
99
- // Mage::register('sync', Mage::getModel('sync/form'));
100
- }
101
-
102
- public function initialSyncAction() {
103
- try {
104
- Mage::getModel('sync/observer')->startInitialSync();
105
- } catch (Exception $e){
106
- Mage::log("TagalysControllerException".print_r($e->getMessage()), null, "tagalys-exception.log");
107
- }
108
- return $this->_redirectReferer();
109
- }
110
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/controllers/FeedController.php DELETED
@@ -1,124 +0,0 @@
1
- <?php
2
- class Tagalys_Sync_FeedController extends Mage_Core_Controller_Front_Action
3
- {
4
-
5
- public function deleteAction() {
6
- try {
7
- $output = $this->getRequest()->getParams();
8
- $temp = explode("media\/tagalys\/", $output["completed"]);
9
- $feed = $temp[1];
10
- $this->_feed = Mage::helper("sync/tagalysFeedFactory");
11
- $this->_feed->deleteProductFeed($output["feed"]);
12
- return true;
13
- } catch (Exception $e) {
14
- return false;
15
- }
16
- }
17
-
18
- public function indexStatusAction() {
19
-
20
- try {
21
- $output = $this->getRequest()->getParams();
22
-
23
- if($output["identification"]["client_code"] == Mage::helper('tagalys_core')->getTagalysConfig('client_code')
24
- && $output["identification"]["api_key"] == Mage::helper('tagalys_core')->getTagalysConfig('private_api_key')) {
25
- Mage::helper('tagalys_core')->setTagalysConfig('search_index_'.$output["identification"]["store_id"], 1);
26
-
27
- $temp = explode("media/tagalys/", $output["completed"]);
28
- $feed = $temp[1];
29
- if (is_null($feed)){
30
- $temp = explode("media\/tagalys\/", $output["completed"]);
31
- $feed = $temp[1];
32
- }
33
- Mage::helper("sync/tagalysFeedFactory")->deleteProductFeed($feed);
34
-
35
-
36
- $type_file = explode("-", $feed);
37
- if( $type_file[1] == "dump") {
38
- Mage::helper('tagalys_core')->setTagalysConfig('product_sync_required_'.$output["identification"]["store_id"], 0);
39
- }
40
-
41
- unlink(Mage::getBaseDir("media"). DS ."tagalys" . DS."tagalys-sync-progress-".$output["identification"]["store_id"].".json");
42
-
43
- $plugin_to_be_activated = Mage::getStoreConfig('tagalys_endpoint/endpoint/plugin_to_be_activated');
44
- foreach (explode(",", $plugin_to_be_activated) as $key => $value) {
45
- Mage::helper('tagalys_core')->setTagalysConfig('is_'.$value.'_active', 1);
46
- }
47
- echo json_encode(array("installed_plugin" => Mage::getStoreConfig('tagalys_endpoint/endpoint/installed_plugin')));
48
- } else {
49
- return false;
50
- }
51
-
52
- } catch (Exception $e) {
53
- return false;
54
- }
55
-
56
- if(Mage::helper('tagalys_core')->setupCompelete()){
57
- Mage::helper('tagalys_core')->setTagalysConfig('setup_complete', 1);
58
- Mage::helper('tagalys_core')->setTagalysConfig('search_complete', 1);
59
-
60
- }
61
- }
62
-
63
- public function progressAction() {
64
- try {
65
- $output = $this->getRequest()->getParams();
66
- $storeId = (int)$output["store"];
67
- $this->_feed = Mage::helper("sync/tagalysFeedFactory");
68
- $dump_feed = $this->_feed->getFeedFile($storeId, "dump");
69
-
70
- if(!is_null($dump_feed)) {
71
- if($this->_feed->getFeedProgress($storeId, $dump_feed) == 0){
72
- $message = "Waiting for feed to be processed by cron.";
73
- } else {
74
- $message = $this->_feed->getFeedProgress($storeId, $dump_feed);
75
- }
76
-
77
- } else {
78
- if(Mage::helper("tagalys_core")->checkStoreInitSync($storeId)) {
79
- $message = "Completed" ;
80
- }else{
81
- $message = "Waiting for feed to be processed.";
82
- }
83
- }
84
-
85
- echo ($message);
86
- exit;
87
- } catch (Exception $e) {
88
- return false;
89
- }
90
- }
91
-
92
- public function searchStatusAction() {
93
- try {
94
- $output = $this->getRequest()->getParams();
95
- $storeId = (int)$output["store"];
96
- if(Mage::helper("tagalys_core")->checkStoreInitSync($storeId)) {
97
- $service = Mage::getSingleton("sync/client");
98
- $is_search_ready = ($service->is_tagalys_search_ready($storeId));//to-do
99
- if(isset($is_search_ready) && (int)$is_search_ready["completed"] > 0) {
100
- $percent = 100 - (((int)$is_search_ready["total"] - (int)$is_search_ready["completed"]) / ((int)$is_search_ready["total"])) * 100;
101
- $percent = number_format( (int)$percent, 0 );
102
- } else {
103
- $percent = "Waiting for response from Tagalys... ";
104
- }
105
-
106
- } else {
107
- $percent = "Waiting for feed creation to be completed.";
108
- }
109
-
110
- echo $percent;
111
-
112
- } catch (Exception $e) {
113
- return false;
114
- }
115
- }
116
-
117
- public function enableButtonAction() {
118
- echo (int)Mage::helper('tagalys_core')->getTagalysConfig('setup_complete') && Mage::helper('tagalys_core')->getTagalysConfig("search_complete");
119
- exit;
120
- }
121
-
122
-
123
- }
124
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/etc/config.xml DELETED
@@ -1,206 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <default>
4
- <tagalys_endpoint>
5
- <endpoint>
6
- <product_feed>/v1/products/sync_feed</product_feed>
7
- <sync_updates>/v1/products/sync_updates</sync_updates>
8
- <client_config>/v1/configuration</client_config>
9
- <sync_feed_progress>/v1/products/sync_feed_progress</sync_feed_progress>
10
- <api_auth>/v1/identification/check</api_auth>
11
- <installed_plugin>Merchandising Pages</installed_plugin>
12
- <plugin_to_be_activated>merchandising_page</plugin_to_be_activated>
13
- </endpoint>
14
- </tagalys_endpoint>
15
- </default>
16
- <modules>
17
- <Tagalys_Sync>
18
- <version>0.2.0</version>
19
- </Tagalys_Sync>
20
- </modules>
21
- <!-- Default Config Start-->
22
- <default>
23
- <sync>
24
- <product>
25
- <import_status>disable</import_status>
26
- </product>
27
- </sync>
28
- </default>
29
- <!-- Default Config End -->
30
- <frontend>
31
- <routers>
32
- <tagalys>
33
- <use>standard</use>
34
- <args>
35
- <module>Tagalys_Sync</module>
36
- <frontName>tagalys</frontName>
37
- </args>
38
- </tagalys>
39
- </routers>
40
- </frontend>
41
- <global>
42
- <helpers>
43
- <sync>
44
- <class>Tagalys_Sync_Helper</class>
45
- </sync>
46
- </helpers>
47
- <models>
48
- <sync>
49
- <class>Tagalys_Sync_Model</class>
50
- <resourceModel>sync_mysql4</resourceModel>
51
- </sync>
52
- <sync_mysql4>
53
- <class>Tagalys_Sync_Model_Mysql4</class>
54
- <entities>
55
- <queue>
56
- <table>tagalys_queue</table>
57
- </queue>
58
- </entities>
59
- </sync_mysql4>
60
- <dataflow>
61
- <rewrite>
62
- <convert_adapter_io>Tagalys_Sync_Model_Dataflow_Convert_Adapter_Io</convert_adapter_io>
63
- </rewrite>
64
- </dataflow>
65
- </models>
66
- <resources>
67
- <sync_setup>
68
- <setup>
69
- <module>Tagalys_Sync</module>
70
- </setup>
71
- <connection>
72
- <use>core_setup</use>
73
- </connection>
74
- </sync_setup>
75
- <sync_write>
76
- <connection>
77
- <use>core_write</use>
78
- </connection>
79
- </sync_write>
80
- <sync_read>
81
- <connection>
82
- <use>core_read</use>
83
- </connection>
84
- </sync_read>
85
- </resources>
86
- <events>
87
- <catalog_product_attribute_save_after>
88
- <observers>
89
- <catalog_product_attribute_update_after_handler>
90
- <type>singleton</type>
91
- <class>sync/observer</class>
92
- <method>test</method>
93
- <args></args>
94
- </catalog_product_attribute_update_after_handler>
95
- </observers>
96
- </catalog_product_attribute_save_after>
97
- <tagalys_event>
98
- <observers>
99
- <tagalys_event_handler>
100
- <type>singleton</type>
101
- <class>Tagalys_Sync_Model_Adminhtml_System_Config_Backend_Tagalys_Cron</class>
102
- <method>setCron</method>
103
- <args></args>
104
- </tagalys_event_handler>
105
- </observers>
106
- </tagalys_event>
107
- <catalog_product_import_finish_before>
108
- <observers>
109
- <tagalys_catalog_product_import_finish_before_handler>
110
- <type>singleton</type>
111
- <class>sync/observer</class>
112
- <method>productsImported</method>
113
- <args></args>
114
- </tagalys_catalog_product_import_finish_before_handler>
115
- </observers>
116
- </catalog_product_import_finish_before>
117
- <catalog_product_save_after>
118
- <observers>
119
- <tagalys_catalog_product_save_after_handler>
120
- <type>singleton</type>
121
- <class>sync/observer</class>
122
- <method>productUpdate</method>
123
- <args></args>
124
- </tagalys_catalog_product_save_after_handler>
125
- </observers>
126
- </catalog_product_save_after>
127
- <catalog_product_delete_before>
128
- <observers>
129
- <tagalys_catalog_product_delete_before_handler>
130
- <type>singleton</type>
131
- <class>sync/observer</class>
132
- <method>productDelete</method>
133
- <args></args>
134
- </tagalys_catalog_product_delete_before_handler>
135
- </observers>
136
- </catalog_product_delete_before>
137
- <catalog_product_delete_commit_after>
138
- <observers>
139
- <tagalys_catalog_product_delete_commit_after_handler>
140
- <type>singleton</type>
141
- <class>sync/observer</class>
142
- <method>productDelete</method>
143
- <args></args>
144
- </tagalys_catalog_product_delete_commit_after_handler>
145
- </observers>
146
- </catalog_product_delete_commit_after>
147
- <catalog_product_import_profile_after>
148
- <observers>
149
- <catalog_product_import_after_handler>
150
- <type>singleton</type>
151
- <class>sync/observer</class>
152
- <method>productImportByDataFlow</method>
153
- <args></args>
154
- </catalog_product_import_after_handler>
155
- </observers>
156
- </catalog_product_import_profile_after>
157
- <sales_order_payment_place_end>
158
- <observers>
159
- <tagalys_sales_order_payment_place_end_handler>
160
- <type>singleton</type>
161
- <class>sync/observer</class>
162
- <method>saleOrderComplete</method>
163
- <args></args>
164
- </tagalys_sales_order_payment_place_end_handler>
165
- </observers>
166
- </sales_order_payment_place_end>
167
- </events>
168
- </global>
169
- <admin>
170
- <routers>
171
- <adminhtml>
172
- <args>
173
- <modules>
174
- <Tagalys_Sync before="Mage_Adminhtml">Tagalys_Sync_Adminhtml</Tagalys_Sync>
175
- </modules>
176
- </args>
177
- </adminhtml>
178
- </routers>
179
- </admin>
180
- <depends>
181
- <Mage_Catalog />
182
- </depends>
183
- <crontab>
184
- <jobs>
185
- <tagalys_cron>
186
- <schedule>
187
- <cron_expr>*/1 * * * *</cron_expr>
188
- </schedule>
189
- <run>
190
- <model>sync/observer::createProductFeed</model>
191
- </run>
192
- </tagalys_cron>
193
- <!-- to-do based on client dropdown -->
194
- <tagalys_updates_cron>
195
- <run>
196
- <model>sync/observer::updatesCron</model>
197
- </run>
198
- </tagalys_updates_cron>
199
- <tagalys_resync_cron>
200
- <run>
201
- <model>sync/observer::resyncCron</model>
202
- </run>
203
- </tagalys_resync_cron>
204
- </jobs>
205
- </crontab>
206
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/etc/wsdl.xml DELETED
@@ -1,53 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
3
- xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
4
- name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
5
- <types>
6
- <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
7
- <import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
8
- <complexType name="fieldInfo">
9
- <sequence>
10
- <element name="entity_id" type="xsd:string"/>
11
- <element name="name" type="xsd:string"/>
12
- </sequence>
13
- </complexType>
14
- <complexType name="fieldInfoArray">
15
- <complexContent>
16
- <restriction base="soapenc:Array">
17
- <attribute ref="soapenc:arrayType" wsdl:arrayType="typens:fieldInfo[]" />
18
- </restriction>
19
- </complexContent>
20
- </complexType>
21
- </schema>
22
- </types>
23
- <message name="syncProductRequest">
24
- <part name="sessionId" type="xsd:string" />
25
- </message>
26
- <message name="syncProductResponse">
27
- <part name="products" type="xsd:string" />
28
- </message>
29
- <portType name="{{var wsdl.handler}}PortType">
30
- <operation name="syncProduct">
31
- <documentation>List of products</documentation>
32
- <input message="typens:syncProductRequest" />
33
- <output message="typens:syncProductResponse" />
34
- </operation>
35
- </portType>
36
- <binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
37
- <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
38
- <operation name="syncProduct">
39
- <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
40
- <input>
41
- <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
42
- </input>
43
- <output>
44
- <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
45
- </output>
46
- </operation>
47
- </binding>
48
- <service name="{{var wsdl.name}}Service">
49
- <port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
50
- <soap:address location="{{var wsdl.url}}" />
51
- </port>
52
- </service>
53
- </definitions>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/sql/sync_setup/mysql4-install-0.1.0.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- $installer = $this;
3
- $installer->startSetup();
4
- $tagalys_queue = $installer->getConnection()->newTable($installer->getTable('tagalys_queue'))
5
- ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
6
- 'unsigned' => true,
7
- 'nullable' => false,
8
- 'primary' => true,
9
- 'identity' => true,
10
- ), 'ID')
11
- ->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 50, array(
12
- 'nullable' => false,
13
- 'default' => '0',
14
- ), 'Product ID')
15
- ->setComment('Tagalys Product Queue Table');
16
- $installer->getConnection()->createTable($tagalys_queue);
17
- $installer->endSetup();
18
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/sql/sync_setup/mysql4-install-0.2.0.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- $installer = $this;
3
- $installer->startSetup();
4
- $tagalys_queue = $installer->getConnection()->newTable($installer->getTable('tagalys_queue'))
5
- ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
6
- 'unsigned' => true,
7
- 'nullable' => false,
8
- 'primary' => true,
9
- 'identity' => true,
10
- ), 'ID')
11
- ->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 50, array(
12
- 'nullable' => false,
13
- 'default' => '0',
14
- ), 'Product ID')
15
- ->setComment('Tagalys Product Queue Table');
16
- $installer->getConnection()->createTable($tagalys_queue);
17
- $installer->endSetup();
18
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Sync/sql/sync_setup/mysql4-upgrade-0.1.0-0.2.0.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- $installer = $this;
3
- $installer->startSetup();
4
- $installer->run("
5
-
6
- -- DROP TABLE IF EXISTS {$this->getTable('tagalys_queue')};
7
- CREATE TABLE {$this->getTable('tagalys_queue')} (
8
- `product_id` varchar(50) NOT NULL default 'general'
9
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
10
- $installer->run("
11
- ALTER TABLE {$this->getTable('tagalys_queue')}
12
- MODIFY `product_id` varchar(50) NULL;
13
- ");
14
-
15
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Block/Catalog/Layer/Filter/Attribute.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
-
3
- if (Mage::helper('tsearch')->is_fme_active()) {
4
- class MiddleManBlockAttributeClass extends FME_Layerednav_Block_Layer_Filter_Attribute { }
5
- } else {
6
- class MiddleManBlockAttributeClass extends Mage_Catalog_Block_Layer_Filter_Attribute { }
7
- }
8
-
9
- class Tagalys_Tsearch_Block_Catalog_Layer_Filter_Attribute extends MiddleManBlockAttributeClass
10
- {
11
- /**
12
- * Defines specific filter model name.
13
- *
14
- * @see Tagalys_Tsearch_Model_Catalog_Layer_Filter_Attribute
15
- */
16
- public function __construct()
17
- {
18
- parent::__construct();
19
-
20
- $this->_filterModelName = 'tsearch/catalog_layer_filter_attribute';
21
- }
22
- /**
23
- * Prepares filter model.
24
- *
25
- * @return Tagalys_Tsearch_Block_Catalog_Layer_Filter_Attribute
26
- */
27
- protected function _prepareFilter()
28
- {
29
- $this->_filter->setAttributeModel($this->getAttributeModel());
30
- return $this;
31
- }
32
- /**
33
- * Adds facet condition to filter.
34
- *
35
- * @see Tagalys_Tsearch_Model_Catalog_Layer_Filter_Attribute::addFacetCondition()
36
- * @return Tagalys_Tsearch_Block_Catalog_Layer_Filter_Attribute
37
- */
38
- public function addFacetCondition()
39
- {
40
- $this->_filter->addFacetCondition();
41
- return $this;
42
- }
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Block/Catalog/Layer/Filter/Category.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
-
3
- if (Mage::helper('tsearch')->is_fme_active()) {
4
- class MiddleManBlockCategoryClass extends FME_Layerednav_Block_Layer_Filter_Category { }
5
- } else {
6
- class MiddleManBlockCategoryClass extends Mage_Catalog_Block_Layer_Filter_Category { }
7
- }
8
-
9
- class Tagalys_Tsearch_Block_Catalog_Layer_Filter_Category extends MiddleManBlockCategoryClass
10
- {
11
- /**
12
- * Defines specific filter model name.
13
- *
14
- * @see Tagalys_Tsearch_Model_Catalog_Layer_Filter_Category
15
- */
16
- public function __construct()
17
- {
18
- parent::__construct();
19
- $this->_filterModelName = 'tsearch/catalog_layer_filter_category';
20
- }
21
-
22
- /**
23
- * Adds facet condition to filter.
24
- *
25
- * @see Tagalys_Tsearch_Model_Catalog_Layer_Filter_Category::addFacetCondition()
26
- * @return Tagalys_Tsearch_Block_Catalog_Layer_Filter_Attribute
27
- */
28
- public function addFacetCondition()
29
- {
30
- $this->_filter->addFacetCondition();
31
-
32
- return $this;
33
- }
34
-
35
-
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Block/Catalog/Layer/Filter/Price.php DELETED
@@ -1,66 +0,0 @@
1
- <?php
2
-
3
- if (Mage::helper('tsearch')->is_fme_active()) {
4
- class MiddleManBlockPriceClass extends FME_Layerednav_Block_Layer_Filter_Price { }
5
- } else {
6
- class MiddleManBlockPriceClass extends Mage_Catalog_Block_Layer_Filter_Price { }
7
- }
8
-
9
- class Tagalys_Tsearch_Block_Catalog_Layer_Filter_Price extends Mage_Catalog_Block_Layer_Filter_Price
10
- {
11
- /**
12
- * Defines specific filter model name.
13
- *
14
- * @see Tagalys_Tsearch_Model_Catalog_Layer_Filter_Price
15
- */
16
- public function __construct()
17
- {
18
- parent::__construct();
19
- $this->_filterModelName = 'tsearch/catalog_layer_filter_price';
20
- }
21
-
22
- /**
23
- * Prepares filter model.
24
- *
25
- * @return Tagalys_Tsearch_Block_Catalog_Layer_Filter_Price
26
- */
27
- protected function _prepareFilter()
28
- {
29
- $this->_filter->setAttributeModel($this->getAttributeModel());
30
-
31
- return $this;
32
- }
33
-
34
- /**
35
- * Adds facet condition to filter.
36
- *
37
- * @see Tagalys_Tsearch_Model_Catalog_Layer_Filter_Price::addFacetCondition()
38
- * @return Tagalys_Tsearch_Block_Catalog_Layer_Filter_Price
39
- */
40
- public function addFacetCondition()
41
- {
42
- if (!$this->getRequest()->getParam('price')) {
43
- $this->_filter->addFacetCondition();
44
- }
45
-
46
- return $this;
47
- }
48
-
49
- public function setNewPrices() {
50
- $tagalys = Mage::helper('tsearch')->getTagalysSearchData();
51
- $filters = $tagalys["filters"];
52
- foreach ($filters as $filter) {
53
-
54
- if ($filter['prefix'] == 'price') {
55
- $filterType = $filter["type"];
56
- if($filterType == "range")
57
- $this->_minPrice = $filter["min"];
58
- $this->_maxPrice = $filter["max"];
59
- }
60
- }
61
- return $this;
62
- }
63
-
64
-
65
-
66
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Block/Catalog/Layer/State.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- class Tagalys_Tsearch_Block_Catalog_Layer_State extends Mage_Catalog_Block_Layer_State
3
- {
4
-
5
- public function getActiveFilters()
6
- {
7
- $filters = $this->getLayer()->getFilters();
8
- if (!is_array($filters)) {
9
- $filters = array();
10
- }
11
- // $filters = array();
12
- return $filters;
13
- }
14
-
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Block/Catalog/Layer/View.php DELETED
@@ -1,119 +0,0 @@
1
- <?php
2
- /**
3
- * Overrides default layer view process to define custom filter blocks.
4
- *
5
- * @package Tagalys_Tsearch
6
- * @subpackage Tagalys_Tsearch_Block
7
- * @author Tagalys
8
- */
9
- class Tagalys_Tsearch_Block_Catalog_Layer_View extends Mage_Catalog_Block_Layer_View
10
- {
11
- /**
12
- * Boolean block name.
13
- *
14
- * @var string
15
- */
16
- protected $_booleanFilterBlockName;
17
-
18
- /**
19
- * Registers current layer in registry.
20
- *
21
- * @see Mage_Catalog_Block_Product_List::getLayer()
22
- */
23
- protected function _construct()
24
- {
25
- parent::_construct();
26
- Mage::unregister('current_layer');
27
- Mage::register('current_layer', $this->getLayer());
28
- }
29
-
30
- /**
31
- * Modifies default block names to specific ones if engine is active.
32
- */
33
- protected function _initBlocks()
34
- {
35
- parent::_initBlocks();
36
- if (Mage::helper('tsearch')->isTagalysActive()) {
37
- $this->_categoryBlockName = 'tsearch/catalog_layer_filter_category';
38
- $this->_attributeFilterBlockName = 'tsearch/catalog_layer_filter_attribute';
39
- $this->_priceFilterBlockName = 'tsearch/catalog_layer_filter_price';
40
- // $this->_booleanFilterBlockName = 'tsearch/catalog_layer_filter_boolean';
41
- }
42
- }
43
-
44
- /**
45
- * Prepares layout if engine is active.
46
- * Difference between parent method is addFacetCondition() call on each created block.
47
- *
48
- * @return Tagalys_Tsearch_Block_Catalog_Layer_View
49
- */
50
- protected function _prepareLayout()
51
- {
52
- if (Mage::helper('tsearch')->isTagalysActive()) {
53
- $stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)
54
- ->setLayer($this->getLayer());
55
-
56
- $categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)
57
- ->setLayer($this->getLayer())
58
- ->init();
59
-
60
- $this->setChild('layer_state', $stateBlock);
61
- $this->setChild('category_filter', $categoryBlock->addFacetCondition());
62
-
63
- $filterableAttributes = $this->_getFilterableAttributes();
64
- $filters = array();
65
- foreach ($filterableAttributes as $attribute) {
66
- if ($attribute->getAttributeCode() == 'price') {
67
- $filterBlockName = $this->_priceFilterBlockName;
68
- } elseif ($attribute->getBackendType() == 'decimal') {
69
- $filterBlockName = $this->_decimalFilterBlockName;
70
- } elseif ($attribute->getSourceModel() == 'eav/entity_attribute_source_boolean') {
71
- $filterBlockName = $this->_booleanFilterBlockName;
72
- } else {
73
- $filterBlockName = $this->_attributeFilterBlockName;
74
- }
75
-
76
- $filters[$attribute->getAttributeCode() . '_filter'] = $this->getLayout()->createBlock($filterBlockName)
77
- ->setLayer($this->getLayer())
78
- ->setAttributeModel($attribute)
79
- ->init();
80
- }
81
-
82
- foreach ($filters as $filterName => $block) {
83
- $this->setChild($filterName, $block->addFacetCondition());
84
- }
85
-
86
- $this->getLayer()->apply();
87
- $this->getLayer()->getProductCollection()->load();
88
- } else {
89
- parent::_prepareLayout();
90
-
91
- }
92
-
93
- return $this;
94
- }
95
-
96
-
97
- public function getRequest(){
98
- $controller = Mage::app()->getFrontController();
99
- if ($controller) {
100
- $this->_request = $controller->getRequest();
101
- } else {
102
- throw new Exception(Mage::helper('core')->__("Can't retrieve request object"));
103
- }
104
- return $this->_request;
105
- }
106
-
107
- /**
108
- * Returns current catalog layer.
109
- *
110
- * @return Tagalys_Tsearch_Model_Catalog_Layer|Mage_Catalog_Model_Layer
111
- */
112
- public function getLayer()
113
- {
114
- if (Mage::helper('tsearch')->isTagalysActive()) {
115
- return Mage::getSingleton('tsearch/catalogsearch');
116
- }
117
- return parent::getLayer();
118
- }
119
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Block/Catalog/Product/.DS_Store DELETED
Binary file
app/code/local/Tagalys/Tsearch/Block/Catalog/Product/List.php DELETED
@@ -1,42 +0,0 @@
1
- <?php
2
- class Tagalys_Tsearch_Block_Catalog_Product_List extends Mage_Catalog_Block_Product_List
3
- {
4
-
5
- protected function _getProductCollection()
6
- {
7
- try {
8
- $tagalys = Mage::helper("tsearch")->getTagalysSearchData();
9
-
10
- if($tagalys == false) {
11
-
12
- return parent::_getProductCollection();
13
- } else {
14
- $searchResult = $tagalys;
15
- if(empty($searchResult)) {
16
- return parent::_getProductCollection();
17
- }
18
-
19
- $collection = $this->_productCollection = Mage::getModel('catalog/product')
20
- ->getCollection()
21
- ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
22
- ->setStore(Mage::app()->getStore())
23
- ->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
24
- ->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED))
25
- ->addAttributeToFilter( 'entity_id', array( 'in' => $searchResult['results']) );
26
-
27
- $orderString = array('CASE e.entity_id');
28
-
29
- foreach($searchResult['results'] as $i => $productId) {
30
- $orderString[] = 'WHEN '.$productId.' THEN '.$i;
31
- }
32
- $orderString[] = 'END';
33
- $orderString = implode(' ', $orderString);
34
- $collection->getSelect()->order(new Zend_Db_Expr($orderString));
35
- return $this->_productCollection;
36
- }
37
- } catch(Exception $e) {
38
- return parent::_getProductCollection();
39
- }
40
- }
41
-
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Block/Catalog/Product/List/Toolbar.php DELETED
@@ -1,92 +0,0 @@
1
- <?php
2
- class Tagalys_Tsearch_Block_Catalog_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar {
3
- public function getAvailableOrders()
4
- {
5
- $tagalysData = Mage::helper("tsearch")->getTagalysSearchData();
6
- if($tagalysData == false) {
7
- return $this->_availableOrder;
8
- } else {
9
- $sort_options = array();
10
- foreach ($tagalysData['sort_options'] as $key => $sort) {
11
- foreach ($sort as $key => $value) {
12
- foreach ($value as $field => $val) {
13
- $sort_options[$val["id"]] = $val['label'];
14
- }
15
- }
16
- }
17
- $sort_options = array();
18
- foreach ($tagalysData['sort_options'] as $key => $sort) {
19
- $sort_options[$sort["id"]] =$sort["label"];
20
- }
21
- $this->_availableOrder = $sort_options;
22
- return $this->_availableOrder;
23
- }
24
- }
25
- public function getLastPageNum() {
26
- $this->_pageSize = $this->getLimit();
27
- $tagalysData = Mage::helper("tsearch")->getTagalysSearchData();
28
- if($tagalysData == false) {
29
- return parent::getLastPageNum();
30
- } else {
31
- $collectionSize = (int) $tagalysData["total"];
32
- if (0 === $collectionSize) {
33
- return 1;
34
- }
35
- elseif($this->_pageSize) {
36
- return ceil($collectionSize/$this->_pageSize);
37
- }
38
- else{
39
- return 1;
40
- }
41
- }
42
- }
43
-
44
- public function getTotalNum() {
45
- $tagalysData = Mage::helper("tsearch")->getTagalysSearchData();
46
- if($tagalysData == false) {
47
- return parent::getTotalNum();
48
- } else {
49
- return (int) $tagalysData["total"];
50
- }
51
- }
52
-
53
- public function getLimit() {
54
- $current_list_mode = Mage::app()->getLayout()->createBlock('catalog/product_list_toolbar')->getCurrentMode();
55
-
56
- if( $current_list_mode == "grid" || $current_list_mode == "grid-list") {
57
- $defaultLimit = Mage::getStoreConfig('catalog/frontend/grid_per_page');
58
-
59
- } else if($current_list_mode == "list" || $current_list_mode == "list-grid") {
60
- $defaultLimit = Mage::getStoreConfig('catalog/frontend/list_per_page');
61
- }
62
- $session_limit = $this->getRequest()->getParam($this->getLimitVarName(), $this->getDefaultPerPageValue());
63
-
64
- !empty($session_limit) ? $session_limit : $defaultLimit;
65
- return !empty($session_limit) ? $session_limit : $defaultLimit;
66
- }
67
-
68
- public function getFirstNum()
69
- {
70
- $tagalysData = Mage::helper("tsearch")->getTagalysSearchData();
71
- if($tagalysData == false) {
72
- return parent::getFirstNum();
73
- } else {
74
- $this->_pageSize = $this->getLimit();
75
- return $this->_pageSize*($this->getCurrentPage()-1)+1;
76
- }
77
- }
78
- public function getLastNum()
79
- {
80
- $tagalysData = Mage::helper("tsearch")->getTagalysSearchData();
81
- if($tagalysData == false) {
82
- return parent::getLastNum();
83
- } else {
84
- $this->_pageSize = $this->getLimit();
85
- $blind_last_num = $this->getFirstNum() + $this->_pageSize - 1;
86
- $actual_last_num = min($blind_last_num, $tagalysData["total"]);
87
- return $actual_last_num;
88
- }
89
- }
90
-
91
-
92
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Block/Catalogsearch/Layer.php DELETED
@@ -1,32 +0,0 @@
1
-
2
-
3
- <?php
4
-
5
- class Tagalys_Tsearch_Block_Catalogsearch_Layer extends Tagalys_Tsearch_Block_Catalogsearch_Layer_View {
6
-
7
- protected function _initBlocks()
8
- {
9
- parent::_initBlocks();
10
-
11
- }
12
- public function canShowBlock() {
13
-
14
- $availableResCount = (int) Mage::app()->getStore()
15
- ->getConfig(Mage_CatalogSearch_Model_Layer::XML_PATH_DISPLAY_LAYER_COUNT);
16
-
17
- if (!$availableResCount || ($availableResCount >= $this->getLayer()->getProductCollection()->getSize())) {
18
- return parent::canShowBlock();
19
- }
20
- return false;
21
- }
22
-
23
- protected function createCategoriesBlock() {
24
-
25
- $categoryBlock = $this->getLayout()
26
- ->createBlock('tsearch/catalog_layer_filter_category')
27
- ->setLayer($this->getLayer())
28
- ->init();
29
- $this->setChild('category_filter', $categoryBlock);
30
- }
31
-
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Block/Catalogsearch/Layer/Filter/Attribute.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- /**
3
- * Handles attribute filtering in layered navigation in a query search context.
4
- *
5
- * @package Unbxd_Search
6
- * @subpackage Unbxd_Search_Block
7
- * @author Tagalys
8
- */
9
- class Tagalys_Tsearch_Block_Catalogsearch_Layer_Filter_Attribute extends Mage_Catalog_Block_Layer_Filter_Attribute
10
- {
11
- /**
12
- * Set filter model name
13
- *
14
- */
15
- public function __construct()
16
- {
17
- parent::__construct();
18
- $this->_filterModelName = 'tsearch/catalogsearch_layer_filter_attribute';
19
-
20
- }
21
- protected function _prepareFilter()
22
- {
23
- $this->_filter->setAttributeModel($this->getAttributeModel());
24
-
25
- return $this;
26
- }
27
-
28
- /**
29
- * Adds facet condition to filter.
30
- *
31
- * @see Tagalys_Tsearch_Model_Catalog_Layer_Filter_Attribute::addFacetCondition()
32
- * @return Tagalys_Tsearch_Block_Catalogsearch_Layer_Filter_Attribute
33
- */
34
- public function addFacetCondition()
35
- {
36
- $this->_filter->addFacetCondition();
37
- return $this;
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Block/Catalogsearch/Layer/View.php DELETED
@@ -1,145 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Tsearch_Block_Catalogsearch_Layer_View extends Mage_Catalog_Block_Layer_View {
4
-
5
- protected $_filterBlocks = null;
6
- protected $_helper = null;
7
- //to-do
8
- public function __construct() {
9
- parent::__construct();
10
- // $this->_helper = Mage::helper('layerednav');
11
-
12
- if (Mage::helper('tsearch')->isTagalysActive()) {
13
-
14
- $this->_categoryBlockName = 'tsearch/catalog_layer_filter_category';
15
- $this->_attributeFilterBlockName = 'tsearch/catalog_layer_filter_attribute';
16
- $this->_priceFilterBlockName = 'tsearch/catalog_layer_filter_price';
17
- // $this->_decimalFilterBlockName = 'tsearch/catalog_layer_filter_decimal';
18
- // $this->_booleanFilterBlockName = 'tsearch/catalog_layer_filter_boolean';
19
- } else {
20
- $this->_categoryBlockName = 'catalog/layer_filter_category';
21
- $this->_attributeFilterBlockName = 'catalog/layer_filter_attribute';
22
- $this->_priceFilterBlockName = 'catalog/layer_filter_price';
23
- }
24
- }
25
-
26
-
27
- public function getClearUrl()
28
- {
29
-
30
- $params['_current'] = true;
31
- $params['_use_rewrite'] = true;
32
- $params['_query'] = "q=".Mage::helper('catalogsearch')->getQuery()->getQueryText();
33
- $params['_escape'] = true;
34
-
35
- return Mage::getUrl('*/*/*', $params );
36
- }
37
-
38
- protected function _prepareLayout() {
39
- // $_hlp = $this->_helper;
40
- // Return an object of current category
41
- $category = Mage::registry('current_category');
42
-
43
- if ($category) {
44
- $currentCategoryID = $category->getId();
45
- } else {
46
- $currentCategoryID = null;
47
- }
48
-
49
- // Return session object
50
- $sessionObject = Mage::getSingleton('catalog/session');
51
- if ($sessionObject AND $lastCategoryID = $sessionObject->getLastCatgeoryID()) {
52
- if ($currentCategoryID != $lastCategoryID) {
53
- Mage::register('new_category', true);
54
- }
55
- }
56
- $sessionObject->setLastCatgeoryID($currentCategoryID);
57
-
58
- //Create Category Blocks
59
- $stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)
60
- ->setLayer($this->getLayer());
61
-
62
- $categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)
63
- ->setLayer($this->getLayer())
64
- ->init();
65
-
66
-
67
- $this->setChild('layer_state', $stateBlock);
68
- $this->setChild('category_filter', $categoryBlock);
69
- // $this->createCategoriesBlock();
70
-
71
- // preload setting
72
- // $this->setIsRemoveLinks($_hlp->removeLinks());
73
-
74
- //Get $this->_getFilterableAttributes() Mage_Catalog_Block_Layer_View
75
- $filterableAttributes = $this->_getFilterableAttributes();
76
-
77
-
78
- $blocks = array();
79
- foreach ($filterableAttributes as $attribute) {
80
-
81
- $blockType = $this->_attributeFilterBlockName;
82
-
83
- if ($attribute->getAttributeCode() == 'price') {
84
- $blockType = $this->_priceFilterBlockName;
85
- }
86
-
87
- $name = $attribute->getAttributeCode() . '_filter';
88
-
89
- $blocks[$name] = $this->getLayout()->createBlock($blockType)
90
- ->setLayer($this->getLayer())
91
- ->setAttributeModel($attribute);
92
-
93
- $this->setChild($name, $blocks[$name]);
94
- }
95
-
96
- foreach ($blocks as $name => $block) {
97
- $block->init();
98
- }
99
- $this->getLayer()->apply();
100
- return Mage_Core_Block_Template::_prepareLayout();
101
- }
102
-
103
-
104
- public function getLayer() {
105
- if (!Mage::helper('tsearch')->isTagalysActive()) {
106
- return Mage::getSingleton('catalogsearch/layer');
107
- }
108
- return parent::getLayer();
109
- }
110
-
111
- protected function createCategoriesBlock() {
112
-
113
-
114
-
115
- $categoryBlock = $this->getLayout()
116
- ->createBlock("tsearch/catalog_layer_filter_category")
117
- ->setLayer($this->getLayer())
118
- ->init();
119
- $this->setChild('category_filter', $categoryBlock);
120
- }
121
-
122
- public function getFilters() {
123
- if (is_null($this->_filterBlocks)) {
124
- $this->_filterBlocks = parent::getFilters();
125
- }
126
- return $this->_filterBlocks;
127
- }
128
-
129
- protected function _toHtml() {
130
- $html = parent::_toHtml();
131
- if (!Mage::app()->getRequest()->isXmlHttpRequest()) {
132
- $html = '<div id="catalog-filters">' . $html . '</div>';
133
- }
134
- return $html;
135
- }
136
- protected function _getFilterableAttributes(){
137
- if (Mage::helper('tsearch')->isTagalysActive()) {
138
- $attributeModel = Mage::getResourceModel('catalog/product_attribute_collection')->getItems();
139
- return $attributeModel;
140
- }
141
- return parent::_getFilterableAttributes();
142
- }
143
-
144
- }
145
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Block/Catalogsearch/Result.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
-
3
-
4
- class Tagalys_Tsearch_Block_Catalogsearch_Result extends Mage_CatalogSearch_Block_Result
5
- {
6
-
7
- public function setListCollection()
8
- {
9
- $this->getListBlock()
10
- ->setCollection($this->_getProductCollection());
11
- return $this;
12
- }
13
- /**
14
- * Retrieve loaded category collection
15
- *
16
- * @return Mage_CatalogSearch_Model_Mysql4_Fulltext_Collection
17
- */
18
- protected function _getProductCollection()
19
- {
20
-
21
- if (is_null($this->_productCollection)) {
22
- //$this->_productCollection = $this->getListBlock()->getLoadedProductCollection();
23
- $this->_productCollection = Mage::getSingleton('catalogsearch/layer')->getProductCollection();
24
- }
25
-
26
- return $this->_productCollection;
27
- }
28
-
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Block/Page/.DS_Store DELETED
Binary file
app/code/local/Tagalys/Tsearch/Block/Page/Html/Pager.php DELETED
@@ -1,155 +0,0 @@
1
- <?php
2
- class Tagalys_Tsearch_Block_Page_Html_Pager extends Mage_Page_Block_Html_Pager {
3
-
4
- public function getLastPageNum() {
5
- $this->_pageSize = $this->getLimit();
6
- $tagalysData = Mage::helper("tsearch")->getTagalysSearchData();
7
- if($tagalysData == false) {
8
- return parent::getLastPageNum();
9
- } else {
10
- $collectionSize = (int) $tagalysData["total"];
11
-
12
- if (0 === $collectionSize) {
13
- return 1;
14
- }
15
- elseif($this->_pageSize) {
16
- return ceil($collectionSize/$this->_pageSize);
17
- }
18
- else {
19
- return 1;
20
- }
21
- }
22
- }
23
-
24
- public function getTotalNum() {
25
- $tagalysData = Mage::helper("tsearch")->getTagalysSearchData();
26
- if($tagalysData == false) {
27
- return parent::getTotalNum();
28
- } else {
29
- return (int) $tagalysData["total"];
30
- }
31
- }
32
-
33
- public function getLimit() {
34
- $current_list_mode = Mage::app()->getLayout()->createBlock('catalog/product_list_toolbar')->getCurrentMode();
35
-
36
- if( $current_list_mode == "grid" || $current_list_mode == "grid-list") {
37
- $defaultLimit = Mage::getStoreConfig('catalog/frontend/grid_per_page');
38
-
39
- } else if($current_list_mode == "list" || $current_list_mode == "list-grid") {
40
- $defaultLimit = Mage::getStoreConfig('catalog/frontend/list_per_page');
41
- }
42
-
43
- $session_limit = $this->getRequest()->getParam($this->getLimitVarName(), $this->getDefaultPerPageValue());
44
-
45
- !empty($session_limit) ? $session_limit : $defaultLimit;
46
- return !empty($session_limit) ? $session_limit : $defaultLimit;
47
- }
48
-
49
- public function getPages()
50
- {
51
- $collection = $this->getCollection();
52
-
53
- $pages = array();
54
- if ($this->getLastPageNum() <= $this->_displayPages) {
55
- $pages = range(1, $this->getLastPageNum());
56
- }
57
- else {
58
- $half = ceil($this->_displayPages / 2);
59
- if ($collection->getCurPage() >= $half
60
- && $collection->getCurPage() <= $this->getLastPageNum() - $half
61
- ) {
62
- $start = ($collection->getCurPage() - $half) + 1;
63
- $finish = ($start + $this->_displayPages) - 1;
64
- }
65
- elseif ($collection->getCurPage() < $half) {
66
- $start = 1;
67
- $finish = $this->_displayPages;
68
- }
69
- elseif ($collection->getCurPage() > ($this->getLastPageNum() - $half)) {
70
- $finish = $this->getLastPageNum();
71
- $start = $finish - $this->_displayPages + 1;
72
- }
73
-
74
- $pages = range($start, $finish);
75
- }
76
- return $pages;
77
- }
78
-
79
- protected function _initFrame()
80
- {
81
- if (!$this->isFrameInitialized()) {
82
- $start = 0;
83
- $end = 0;
84
-
85
- //$collection = $this->getCollection();
86
- if ($this->getLastPageNum() <= $this->getFrameLength()) {
87
- $start = 1;
88
- $end = $this->getLastPageNum();
89
- }
90
- else {
91
- $half = ceil($this->getFrameLength() / 2);
92
- if ($this->getCurrentPage() >= $half && $this->getCurrentPage() <= $this->getLastPageNum() - $half) {
93
- $start = ($this->getCurrentPage() - $half) + 1;
94
- $end = ($start + $this->getFrameLength()) - 1;
95
- }
96
- elseif ($this->getCurrentPage() < $half) {
97
- $start = 1;
98
- $end = $this->getFrameLength();
99
- }
100
- elseif ($this->getCurrentPage() > ($this->getLastPageNum() - $half)) {
101
- $end = $this->getLastPageNum();
102
- $start = $end - $this->getFrameLength() + 1;
103
- }
104
- //$start = 1;
105
- //$end = $this->getLastPageNum() - abs($this->getLastPageNum() - $this->getFrameLength());
106
-
107
- }
108
- $this->_frameStart = $start;
109
- $this->_frameEnd = $end;
110
-
111
- $this->_setFrameInitialized(true);
112
- }
113
-
114
- return $this;
115
- }
116
-
117
-
118
- public function getFramePages()
119
- {
120
- $start = $this->getFrameStart();
121
- $end = $this->getFrameEnd();
122
- return range($start, $end);
123
- }
124
-
125
- public function getCurrentPage()
126
- {
127
- return (int) $this->getRequest()->getParam($this->getPageVarName(), 1);
128
- }
129
-
130
- public function getPreviousPageUrl()
131
- {
132
- return $this->getPageUrl($this->getCurrentPage() - 1);
133
- }
134
-
135
- public function getNextPageUrl()
136
- {
137
- return $this->getPageUrl($this->getCurrentPage() + 1);
138
- }
139
- public function getFirstPageUrl()
140
- {
141
- return $this->getPageUrl($this->getLastPageNum());
142
- }
143
- public function getLastPageUrl()
144
- {
145
- return $this->getPageUrl($this->getLastPageNum());
146
- }
147
- public function isFirstPage()
148
- {
149
- return $this->getCurrentPage() == 1;
150
- }
151
- public function isLastPage()
152
- {
153
- return $this->getCurrentPage() == $this->getLastPageNum();
154
- }
155
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Helper/Data.php DELETED
@@ -1,120 +0,0 @@
1
- <?php
2
- class Tagalys_Tsearch_Helper_Data extends Mage_Core_Helper_Abstract {
3
-
4
- public function getTagalysSearchData() {
5
- $controllerModule = Mage::app()->getRequest()->getControllerModule();
6
- if($controllerModule == 'Tagalys_MerchandisingPage') {
7
- $service = Mage::getSingleton("merchandisingpage/client");
8
- } else {
9
- $service = Mage::getSingleton("tsearch/client_connector");
10
- }
11
- // $service = Mage::getSingleton("tsearch/client_connector");
12
- if($this->isTagalysActive()) {
13
- $searchResult = $service->getSearchResult();
14
- if ($searchResult == null) {
15
- return false;
16
- } else {
17
- return $searchResult;
18
- }
19
- } else {
20
- return false;
21
- }
22
- }
23
-
24
- public function isTagalysActive() {
25
-
26
- $status = Mage::helper('tagalys_core')->getTagalysConfig("is_tsearch_active");
27
- $query = Mage::app()->getRequest()->getParam('q');
28
-
29
- if ($status && !empty($query)) {
30
- $service = Mage::getSingleton("tsearch/client_connector");
31
- $tagalys = $service->isRequestSuccess();
32
- if($tagalys) {
33
- return $service;
34
- } else {
35
- return false;
36
- }
37
- } else {
38
- return false;
39
- }
40
- }
41
-
42
- public function getTagalysFilter() {
43
- $result = Mage::helper('tsearch')->getTagalysSearchData();
44
- if ($result) {
45
- $data = $result;
46
- $filters = (!empty($data['filters'])) ? $data['filters'] : null ;
47
- return $filters;
48
- }
49
- return false;
50
- }
51
-
52
- public function getAttributeFieldName($attribute, $localeCode = null)
53
- {
54
- // Mage::log($attribute,null,'debug.log');
55
- if (is_string($attribute)) {
56
- $this->getSearchableAttributes(); // populate searchable attributes if not already set
57
- if (!isset($this->_searchableAttributes[$attribute])) {
58
- return $attribute;
59
- }
60
- $attribute = $this->_searchableAttributes[$attribute];
61
- }
62
- $attributeCode = $attribute->getAttributeCode();
63
- $backendType = $attribute->getBackendType();
64
-
65
- return $attributeCode;
66
- }
67
-
68
-
69
- public function is_fme_active() {
70
- return Mage::helper('core')->isModuleEnabled('FME_Layerednav');
71
- }
72
-
73
- public function dynamic_class_name() {
74
-
75
- if(Mage::helper('core')->isModuleEnabled('FME_Layerednav')) {
76
- return "FME_Layerednav";
77
- } elseif (Mage::helper('core')->isModuleEnabled('Magehouse_Slider')) {
78
- return "Magehouse_Slider";
79
- }
80
- return "Mage_Catalog";
81
- }
82
-
83
- public function getSearchParam($attribute, $value)
84
- {
85
- if (empty($value) ||
86
- (isset($value['from']) && empty($value['from']) &&
87
- isset($value['to']) && empty($value['to']))) {
88
- return false;
89
- }
90
-
91
- $field = $this->getAttributeFieldName($attribute);
92
- $backendType = $attribute->getBackendType();
93
- if ($backendType == 'datetime') {
94
- $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
95
- if (is_array($value)) {
96
- foreach ($value as &$val) {
97
- if (!is_empty_date($val)) {
98
- $date = new Zend_Date($val, $format);
99
- $val = $date->toString(Zend_Date::ISO_8601) . 'Z';
100
- }
101
- }
102
- unset($val);
103
- } else {
104
- if (!is_empty_date($value)) {
105
- $date = new Zend_Date($value, $format);
106
- $value = $date->toString(Zend_Date::ISO_8601) . 'Z';
107
- }
108
- }
109
- }
110
-
111
- if ($attribute->usesSource()) {
112
- $attribute->setStoreId(Mage::app()->getStore()->getId());
113
- }
114
-
115
- return array($field => $value);
116
- }
117
- }
118
-
119
-
120
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Model/Catalog/Layer.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- /**
3
- * Overrides default layer model to handle custom product collection filtering.
4
- *
5
- * @package Tagalys_Tsearch
6
- * @subpackage Tagalys_Tsearch_Model
7
- * @author Tagalys
8
- */
9
- class Tagalys_Tsearch_Model_Catalog_Layer extends Mage_Catalog_Model_Layer
10
- {
11
- /**
12
- * Returns product collection for current category.
13
- *
14
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
15
- */
16
- public function getProductCollection()
17
- {
18
- /** @var $category Mage_Catalog_Model_Category */
19
- $category = $this->getCurrentCategory();
20
- /** @var $collection Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection */
21
- if (isset($this->_productCollections[$category->getId()])) {
22
- $collection = $this->_productCollections[$category->getId()];
23
- } else {
24
- $collection = Mage::getResourceModel('catalog/product')
25
- ->getResultCollection()
26
- ->setStoreId($category->getStoreId())
27
- ->addCategoryId($category->getId())
28
- ->setQueryType('browse')
29
- ->addFqFilter(array('store_id' => $category->getStoreId()));
30
-
31
- $this->prepareProductCollection($collection);
32
- $this->_productCollections[$category->getId()] = $collection;
33
- }
34
-
35
- return $collection;
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Model/Catalog/Layer/Filter/Attribute.php DELETED
@@ -1,157 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Tsearch_Model_Catalog_Layer_Filter_Attribute extends Mage_Catalog_Model_Layer_Filter_Attribute {
4
- const OPTIONS_ONLY_WITH_RESULTS = 1;
5
- const MULTI_SELECT_FACET_SPLIT = '-';
6
-
7
- public function addFacetCondition() {
8
- $this->getLayer()
9
- ->getProductCollection()
10
- ->addFacetCondition($this->_getFilterField());
11
- return $this;
12
- }
13
-
14
- public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
15
- {
16
- $filter = $request->getParam($this->_requestVar);
17
- //aadi
18
-
19
- $request = Mage::app()->getRequest()->getParams();
20
- if (!empty($request["qf"])) {
21
- foreach (explode("~", $request["qf"]) as $key => $value) {
22
-
23
- $temp = explode("-", $value);
24
- if($temp[0] == $this->_requestVar) {
25
-
26
- $temp_val = explode("-", $value);
27
- $filter = $temp_val[1];
28
-
29
- }
30
- # code...
31
- }
32
- }
33
- //aadi end
34
- if (is_array($filter)) {
35
- return $this;
36
- }
37
- $text = $this->_getOptionText($filter);
38
- if ($filter && strlen($text)) {
39
- $this->_getResource()->applyFilterToCollection($this, $filter);
40
- $this->getLayer()->getState()->addFilter($this->_createItem($text, $filter));
41
- $this->_items = array();
42
- }
43
- return $this;
44
- }
45
-
46
- public function applyFilterToCollection($filter, $value) {
47
- if(!is_array($value)) {
48
- return $this;
49
- }
50
- $attribute = $filter->getAttributeModel();
51
- $param = Mage::helper('tsearch')->getSearchParam($attribute, $value);
52
-
53
- $this->getLayer()
54
- ->getProductCollection();
55
- return $this;
56
- }
57
-
58
- /**
59
- * Returns facets data of current attribute.
60
- *
61
- * @return array
62
- */
63
- protected function _getFacets() {
64
- /** @var $productCollection Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection */
65
- $productCollection = $this->getLayer()->getProductCollection();
66
- $fieldName = $this->_getFilterField();
67
- $facets = $productCollection;
68
- return $facets;
69
- }
70
-
71
-
72
- public function getMaxPriceInt() {
73
- $priceStat = Mage::getSingleton('tagalys_tsearch/catalog_layer')->getProductCollection()->getStats('price');
74
- $productCollection = $this->getLayer()->getProductCollection();
75
- return isset($priceStat["max"])?$priceStat["max"]:0;
76
- }
77
-
78
-
79
- /**
80
- * Returns attribute field name.
81
- *
82
- * @return string
83
- */
84
- protected function _getFilterField() {
85
- /** @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
86
- // Mage::log("Tagalys_Tsearch_Model_Catalog_Layer_Filter_Attribute::_getFilterField()",null,'debug.log');
87
- $attribute = $this->getAttributeModel();
88
- $fieldName = Mage::helper('tsearch')->getAttributeFieldName($attribute);
89
-
90
- return $fieldName;
91
- }
92
-
93
- /**
94
- * Retrieves current items data.
95
- *
96
- * @return array
97
- */
98
-
99
- protected function _getItemsData() {
100
- $attribute = $this->getAttributeModel();
101
- $this->_requestVar = $attribute->getAttributeCode();
102
- $key = $this->getLayer()->getStateKey().'_'.$this->_requestVar;
103
- $data = $this->getLayer()->getAggregator()->getCacheData($key);
104
- if ($data === null) {
105
- // $filters = $attribute->getFrontend()->getSelectOptions();
106
- $tagalys = Mage::helper('tsearch')->getTagalysSearchData();
107
- $filters = $tagalys["filters"];
108
- $optionsCount = count($filters);
109
- $data = array();
110
- foreach ($filters as $filter) {
111
- if (!empty($filter['items'])) {
112
- // Check filter type
113
- if ($this->_getIsFilterableAttribute($attribute) == self::OPTIONS_ONLY_WITH_RESULTS && $this->_requestVar == $filter['id'] ) {
114
- foreach ($filter["items"] as $filterItem) {
115
- if ($filterItem["count"]) {
116
- $data[] = array(
117
- 'label' => $filterItem["name"],
118
- 'value' => $filterItem["id"], //$filterItem["id"],
119
- 'count' => $filterItem["count"],
120
- );
121
- }
122
- }
123
- }
124
- }
125
- }
126
-
127
- $tags = array(
128
- Mage_Eav_Model_Entity_Attribute::CACHE_TAG.':'.$attribute->getId()
129
- );
130
-
131
- $tags = $this->getLayer()->getStateTags($tags);
132
- $this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
133
- }
134
- return $data;
135
- }
136
-
137
- protected function _getOptionText($optionId) {
138
- if ($this->getAttributeModel()->getFrontendInput() == 'text') {
139
- return $optionId;
140
- }
141
-
142
- return parent::_getOptionText($optionId);
143
- }
144
-
145
- protected function getLabel($optionId) {
146
- if ($this->getAttributeModel()->getFrontendInput() == 'text') {
147
- return $optionId;
148
- }
149
-
150
- return parent::_getOptionText($optionId);
151
- }
152
-
153
- protected function _isValidFilter($filter) {
154
- return !empty($filter);
155
- }
156
-
157
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Model/Catalog/Layer/Filter/Category.php DELETED
@@ -1,100 +0,0 @@
1
- <?php
2
- /**
3
- * Handles category filtering in layered navigation.
4
- *
5
- * @package Tagalys_Tsearch
6
- * @subpackage Tagalys_Tsearch_Model
7
- * @author Tagalys
8
- */
9
- class Tagalys_Tsearch_Model_Catalog_Layer_Filter_Category extends Mage_Catalog_Model_Layer_Filter_Category
10
- {
11
- /**
12
- * Adds category filter to product collection.
13
- *
14
- * @param Mage_Catalog_Model_Category $category
15
- * @return Tagalys_Tsearch_Model_Catalog_Layer_Filter_Category
16
- */
17
- public function addCategoryFilter($category)
18
- {
19
- $value = array(
20
- 'categories' => $category->getId()
21
- );
22
- $this->getLayer()->getProductCollection()
23
- ->addFqFilter($value);
24
-
25
- return $this;
26
- }
27
-
28
- /**
29
- * Adds facet condition to product collection.
30
- *
31
- * @see Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection::addFacetCondition()
32
- * @return Tagalys_Tsearch_Model_Catalog_Layer_Filter_Category
33
- */
34
- public function addFacetCondition()
35
- {
36
- /** @var $category Mage_Catalog_Model_Category */
37
- $category = $this->getCategory();
38
- $childrenCategories = $category->getChildrenCategories();
39
-
40
- $useFlat = (bool) Mage::getStoreConfig('catalog/frontend/flat_catalog_category');
41
- $categories = ($useFlat)
42
- ? array_keys($childrenCategories)
43
- : array_keys($childrenCategories->toArray());
44
-
45
- $this->getLayer()->getProductCollection();
46
-
47
- return $this;
48
- }
49
-
50
-
51
-
52
- protected function _getItemsData()
53
- {
54
- $key = $this->getLayer()->getStateKey().'_SUBCATEGORIES';
55
- $data = $this->getLayer()->getAggregator()->getCacheData($key);
56
-
57
- if ($data === null) {
58
- $data = Mage::helper('tsearch')->getTagalysSearchData();
59
- $tagalys = $data["filters"];
60
- foreach ($tagalys as $filters) {
61
- if($filters["id"] == "__categories"){
62
- $tagalys_categories = $filters;
63
- }
64
- }
65
-
66
-
67
- $data = array();
68
-
69
- foreach ($tagalys_categories["items"] as $category) {
70
- if($category["selected"] == true) {
71
- foreach ($category["items"] as $sub_category) {
72
- $data[] = array(
73
- 'label' => $sub_category["name"],
74
- 'value' => $sub_category["id"],
75
- 'count' => $sub_category["count"],
76
- );
77
- }
78
-
79
- $tags = $this->getLayer()->getStateTags();
80
- $this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
81
- return $data;
82
-
83
- } else {
84
- if (true || $category->getIsActive()) {
85
- $data[] = array(
86
- 'label' => $category["name"],
87
- 'value' => $category["id"],
88
- 'count' => $category["count"],
89
- );
90
- }
91
- }
92
- //check if active
93
-
94
- }
95
- $tags = $this->getLayer()->getStateTags();
96
- $this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
97
- }
98
- return $data;
99
- }
100
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Model/Catalog/Layer/Filter/Price.php DELETED
@@ -1,175 +0,0 @@
1
- <?php
2
-
3
- if (Mage::Helper('tsearch')->is_fme_active()) {
4
- class MiddleManModelPriceClass extends FME_Layerednav_Model_Layer_Filter_Price { }
5
- } else {
6
- class MiddleManModelPriceClass extends Mage_Catalog_Model_Layer_Filter_Price { }
7
- }
8
-
9
- class Tagalys_Tsearch_Model_Catalog_Layer_Filter_Price extends MiddleManModelPriceClass
10
- {
11
- const CACHE_TAG = 'MAXPRICE';
12
-
13
- const DELIMITER = '-';
14
-
15
- /**
16
- * Returns cache tag.
17
- *
18
- * @return string
19
- */
20
- public function getCacheTag()
21
- {
22
- return self::CACHE_TAG;
23
- }
24
-
25
- /**
26
- * Retrieves max price for ranges definition.
27
- *
28
- * @return float
29
- */
30
- public function getMaxPriceMod()
31
- {
32
- $priceStat = Mage::getSingleton('tagalys_tsearch/catalog_layer')->getProductCollection()->getStats('price');
33
- $productCollection = $this->getLayer()->getProductCollection();
34
- return isset($priceStat["max"])?(int)$priceStat["max"]:0;
35
- }
36
-
37
-
38
-
39
- /**
40
- * Retrieves min price for ranges definition.
41
- *
42
- * @return float
43
- */
44
- public function getMinPriceMod()
45
- {
46
- $priceStat = Mage::getSingleton('tagalys_tsearch/catalog_layer')->getProductCollection()->getStats('price');
47
- $productCollection = $this->getLayer()->getProductCollection();
48
- return isset($priceStat["min"])?(int)$priceStat["min"]:0;
49
- }
50
-
51
- /**
52
- * Returns price field according to current customer group and website.
53
- *
54
- * @return string
55
- */
56
- protected function _getFilterField()
57
- {
58
- $websiteId = Mage::app()->getStore()->getWebsiteId();
59
- $customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
60
- $priceField = 'price' ;
61
-
62
- return $priceField;
63
- }
64
-
65
- /**
66
- * Retrieves current items data.
67
- *
68
- * @return array
69
- */
70
- protected function _getItemsData()
71
- {
72
- if (Mage::app()->getStore()->getConfig(self::XML_PATH_RANGE_CALCULATION) == self::RANGE_CALCULATION_IMPROVED) {
73
- return $this->_getCalculatedItemsData();}
74
- if ($this->getInterval()) {
75
- return array();
76
- }
77
-
78
- $data = array();
79
- // $facets = $this->getLayer()->getFacetedData($this->_getFilterField()); ref addy
80
- $tagalys = Mage::helper('tsearch')->getTagalysSearchData();
81
- $filters = $tagalys["filters"];
82
- foreach ($filters as $filter) {
83
-
84
- if ($filter['id'] == 'price' ) {
85
- $filterType = $filter["type"];
86
- foreach ($filter["items"] as $filterItem) {
87
- if ($filterItem["count"]) {
88
- $facets[] = $filterItem;
89
- }
90
- }
91
- }
92
-
93
- }
94
-
95
- if (!empty($facets)) {
96
- $i = 0;
97
- foreach ($facets as $key => $price) {
98
- $i++;
99
-
100
- preg_match('/^(\S*)-(\S*)$/', $price["id"], $rangeKey);
101
- $fromPrice = $rangeKey[1];
102
- $toPrice = $rangeKey[2];
103
- if($filterType == "checkbox"){
104
-
105
- $data[] = array(
106
- // 'label' => $this->_renderRangeLabel($fromPrice, $toPrice),
107
- 'label' => $price["name"],
108
- 'value' => $price["id"],
109
- 'count' => $price["count"]
110
- );
111
- }
112
-
113
- }
114
- } elseif ($filterType == "range") {
115
- $data[] = array(
116
- 'label' => $this->_renderRangeLabel($fromPrice, $toPrice),
117
- 'value' => 10,200,
118
- 'count' => $price["count"]
119
- );
120
- }
121
- return $data;
122
- }
123
-
124
-
125
- /**
126
- * Adds facet condition to product collection.
127
- *
128
- * @see Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection::addFacetCondition()
129
- * @return Tagalys_Tsearch_Model_Catalog_Layer_Filter_Attribute
130
- */
131
- public function addFacetCondition()
132
- {
133
- $this->getLayer()
134
- // ->getProductCollection()
135
- ->addFacetCondition($this->_getFilterField());
136
-
137
- return $this;
138
- }
139
-
140
-
141
- // public function apply(Zend_Controller_Request_Abstract $request, $filterBlock){
142
-
143
- // $filter = $request->getParam($this->_requestVar);
144
- // if(null == $filter){
145
- // return $this;
146
- // }
147
- // $filter =explode(self::DELIMITER, $filter);
148
- // if (!is_array($filter) || null === $filter || sizeof($filter)<2 ) {
149
- // return $this;
150
- // }
151
- // $this->applyFilterToCollection($this, $filter);
152
- // $this->_items = null;
153
- // return $this;
154
- // }
155
-
156
-
157
- function applyFilterToCollection($filter,$filterValue){
158
- $field = $this->_getFilterField();
159
- $value = array(
160
- $field => array(
161
- 'include_upper' => 0
162
- )
163
- );
164
-
165
- if($filterValue[0]< $filterValue[1]){
166
- $value[$field]['from'] = $filterValue[0];
167
- $value[$field]['to'] = $filterValue[1];
168
- }else{
169
- $value[$field]['from'] = $filterValue[1];
170
- $value[$field]['to'] = $filterValue[0];
171
- }
172
- $this->getLayer()->getProductCollection();
173
- return $this;
174
- }
175
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Model/Catalog/Product/List.php DELETED
@@ -1,8 +0,0 @@
1
- <?php
2
- class Tagalys_Tsearch_Block_Catalog_Product_List extends Mage_Catalog_Block_Product_List
3
- {
4
-
5
- protected function _getProductCollection()
6
- {
7
- return parent::_getProductCollection();
8
- }
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Model/Catalogsearch/Layer.php DELETED
@@ -1,59 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Tsearch_Model_Catalogsearch_Layer extends Mage_Catalog_Model_Layer
4
- {
5
-
6
- protected $_facetsConditions = array();
7
-
8
- public function getProductCollection()
9
- {
10
- try {
11
- $tagalysSearchResults = Mage::helper('tsearch')->getTagalysSearchData();
12
-
13
- if($tagalysSearchResults == false) {
14
- return parent::getProductCollection();
15
- } else {
16
- if(empty($tagalysSearchResults)) {
17
- return parent::getProductCollection();
18
- }
19
-
20
- $collection = $this->_productCollection = Mage::getModel('catalog/product')
21
- ->getCollection()
22
- ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
23
- ->setStore(Mage::app()->getStore())
24
- ->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
25
- ->addAttributeToFilter( 'entity_id', array( 'in' => $tagalysSearchResults['results'] ) );
26
-
27
- $orderString = array('CASE e.entity_id');
28
-
29
- foreach($tagalysSearchResults['results'] as $i => $productId) {
30
- $orderString[] = 'WHEN '.$productId.' THEN '.$i;
31
- }
32
- $orderString[] = 'END';
33
- $orderString = implode(' ', $orderString);
34
-
35
- $collection->getSelect()->order(new Zend_Db_Expr($orderString));
36
- return $this->_productCollection;
37
-
38
- }
39
- } catch(Exception $e) {
40
-
41
- return parent::getProductCollection();
42
- }
43
- }
44
-
45
- public function addFacetCondition($field, $condition = null)
46
- {
47
- if (array_key_exists($field, $this->_facetsConditions)) {
48
- if (!empty($this->_facetsConditions[$field])){
49
- $this->_facetsConditions[$field] = array($this->_facetsConditions[$field]);
50
- }
51
- $this->_facetsConditions[$field][] = $condition;
52
- } else {
53
- $this->_facetsConditions[$field] = $condition;
54
- }
55
-
56
- return $this;
57
- }
58
-
59
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Model/Client/Connector.php DELETED
@@ -1,251 +0,0 @@
1
- <?php
2
-
3
- class Tagalys_Tsearch_Model_Client_Connector extends Mage_Core_Model_Abstract {
4
-
5
- protected $_api_key;
6
- protected $_api_server;
7
- protected $_create_or_update_ep;
8
- protected $_search_ep;
9
- protected $_delete_ep;
10
- protected $_search_suggestions_ep;
11
- protected $_merchandising_ep;
12
- protected $_similar_products_ep;
13
-
14
- protected $_search = array();
15
-
16
- protected $_error = false;
17
-
18
- protected $timeout = 5;
19
-
20
- protected $visitor;
21
-
22
-
23
- public function getSearchResult() {
24
- if(!empty($this->_search)) {
25
- return $this->_search;
26
- }
27
- return $this->_search;
28
- }
29
-
30
- protected function _construct() {
31
- $this->_config = Mage::helper('tagalys_core');
32
- $this->_api_server = $this->_config->getTagalysConfig("api_server");
33
- $this->_api_key = $this->_config->getTagalysConfig("private_api_key");
34
- $this->_client_code = $this->_config->getTagalysConfig("client_code");
35
- $this->_create_or_update_ep = Mage::getStoreConfig('tsearch/endpoint/create_or_update');
36
- $this->_search_ep = Mage::getStoreConfig('tsearch/endpoint/search');
37
- $this->_delete_ep = Mage::getStoreConfig('tsearch/endpoint/delete');
38
- $this->_search_suggestions_ep = Mage::getStoreConfig('tsearch/endpoint/search_suggestions');
39
- $this->_merchandising_ep = Mage::getStoreConfig('tsearch/endpoint/merchandising');
40
- $this->_similar_products_ep = Mage::getStoreConfig('tsearch/endpoint/similar_products');
41
- }
42
-
43
- protected function getUrl($e_type) {
44
- switch ($e_type) {
45
- case 'update':
46
- case 'create':
47
- $url = $this->_api_server.$this->_create_or_update_ep;
48
- return $url;
49
- break;
50
- case 'delete':
51
- $url =$this->_api_server.$this->_delete_ep;
52
- return $url;
53
- break;
54
- case 'search':
55
- $url =$this->_api_server.$this->_search_ep;
56
- return $url;
57
- break;
58
- case 'suggestions':
59
- $url = $this->_api_server.$this->_search_suggestions_ep;
60
- return $url;
61
- break;
62
- case 'merchandising':
63
- $url = $this->_api_server.$this->_merchandising_ep;
64
- return $url;
65
- break;
66
- case 'similar':
67
- $url = $this->_api_server.$this->_similar_products_ep;
68
- return $url;
69
- break;
70
- default:
71
- break;
72
- }
73
-
74
- }
75
-
76
- protected function createPayload($payload , $action) {
77
- if($action == 'search') {
78
- $request = array(
79
- 'client_code' => $this->_client_code,
80
- 'api_key' => $this->_api_key,
81
- 'store_id' => Mage::app()->getStore()->getStoreId(),
82
- 'currency' => Mage::getModel('core/cookie')->get('currency') ? Mage::getModel('core/cookie')->get('currency') : Mage::app()->getStore()->getBaseCurrencyCode()
83
- );
84
- } else if( $action == 'merchandising' || $action == 'similar') {
85
- $request = array(
86
- 'api_key' => $this->_api_key,
87
- 'payload' => $payload
88
- );
89
- } else {
90
- $request = array(
91
- 'api_key' => $this->_api_key,
92
- 'perform' => $action,
93
- 'payload' => $payload
94
- );
95
- }
96
- $payload["identification"] = $request;
97
- // $payloadData = json_encode($request);
98
- return json_encode($payload);
99
- }
100
-
101
- public function createProduct($payload) {
102
- try {
103
- $url = $this->getUrl('create');
104
- $payloadData = $this->createPayload($payload, $action = 'create_or_update');
105
- return $this->_payloadAgent($url, $payloadData);
106
- } catch(Exception $e) {
107
- }
108
- }
109
-
110
- public function updateProduct($payload) {
111
- try {
112
-
113
- $url = $this->getUrl('update');
114
- $payloadData = $this->createPayload($payload, $action = 'create_or_update');
115
- return $this->_payloadAgent($url, $payloadData);
116
-
117
- } catch(Exception $e) {
118
-
119
- }
120
- }
121
-
122
- public function deleteProduct($payload) {
123
- try {
124
- $url = $this->getUrl('delete');
125
- $payloadData = $this->createPayload($payload, $action = 'delete');
126
- return $this->_payloadAgent($url, $payloadData);
127
- } catch (Exception $e) {
128
- }
129
- }
130
-
131
- public function searchSuggestion($query = '') {
132
- try {
133
- $url = $this->getUrl('suggestions');
134
- $result = $this->_queryAgent($url, $query);
135
- return $result;
136
- } catch (Exception $e) {
137
- }
138
- }
139
-
140
- public function searchProduct($payload, $filter = false) {
141
-
142
- try {
143
- $url = $this->getUrl('search');
144
-
145
- $payloadData = $this->createPayload($payload, $action = 'search');
146
- //var_dump($payloadData);
147
- //die();
148
-
149
- $this->_search = $this->_payloadAgent($url, ($payloadData));
150
- // $this->_search = json_decode(file_get_contents('response-format.json'),true);
151
- return $this->_search;
152
- } catch (Exception $e) {
153
- }
154
- }
155
-
156
- public function similarProduct($sku) {
157
- try {
158
- $rawurl = $this->getUrl('similar');
159
- $url = str_replace(":sku", $sku, $rawurl);
160
- $request = array(
161
- 'api_key' => $this->_api_key,
162
- );
163
- $this->_search = $this->_payloadAgent($url, $request);
164
- } catch (Exception $e) {
165
- }
166
- }
167
-
168
- public function merchandisingPage($payload) {
169
- try {
170
- $url = $this->getUrl('merchandising');
171
- $payload['api_key'] = $this->_api_key;
172
- $payload['filters'] = true;
173
- $url = str_replace(":name-of-merchandising-page",$payload['q'],$url);
174
- return $this->_search;
175
- // $this->_search = $this->_payloadAgent($url,json_encode($payload));
176
- } catch (Exception $e) {
177
-
178
- }
179
- }
180
-
181
- private function _getAgent($url) {
182
- $agent = curl_init($url);
183
- return $agent;
184
- }
185
-
186
- private function _queryAgent($url, $query) {
187
- $q_url = $url;
188
- $q_url .= '?q='.$query;
189
- $q_url .= '&api_key='.$this->_api_key;
190
- $agent = $this->_getAgent($url);
191
- curl_setopt($agent, CURLOPT_SSL_VERIFYPEER, 0);
192
- curl_setopt( $agent, CURLOPT_RETURNTRANSFER, true );
193
- curl_setopt($agent, CURLOPT_TIMEOUT, $this->timeout);
194
-
195
- $result = curl_exec($agent);
196
- $info = curl_getinfo($agent);
197
-
198
- if(curl_errno($agent)) {
199
-
200
- if (curl_error($agent) === "name lookup timed out") {
201
- for($i = 0; $i <=2 ; $i++) {
202
- $this->_queryAgent($url, $query);
203
- }
204
- }
205
- } else {
206
- if (empty($result)) {
207
- $this->_error = false;
208
-
209
- }
210
- return $result;
211
- }
212
- //end of curl error log
213
- curl_close($agent);
214
- }
215
-
216
- private function _payloadAgent($url, $payload) {
217
- $agent = $this->_getAgent($url);
218
- curl_setopt( $agent, CURLOPT_POSTFIELDS, $payload );
219
- curl_setopt($agent, CURLOPT_POST,1);
220
- curl_setopt( $agent, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
221
- curl_setopt( $agent, CURLOPT_RETURNTRANSFER, true );
222
- curl_setopt( $agent, CURLOPT_SSL_VERIFYPEER, 0 );
223
- curl_setopt($agent, CURLOPT_TIMEOUT, $this->timeout);
224
- $result = curl_exec($agent);
225
- $info = curl_getinfo($agent);
226
-
227
- if(curl_errno($agent)) {
228
- $this->_error = true;
229
-
230
- } else {
231
- if (empty($result)) {
232
- $this->_error = true;
233
-
234
- }
235
- }
236
- curl_close($agent);
237
- if (!$this->_error) {
238
- $decoded = json_decode($result, true);
239
- return $decoded;
240
- } else {
241
- return null;
242
- }
243
- }
244
-
245
- public function isRequestSuccess() {
246
- if( $this->_error == true || empty($this->_search) || $this->_search["status"] != "OK" ) {
247
- return false; //ref addy
248
- }
249
- return true;
250
- }
251
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Model/Engine.php DELETED
@@ -1,96 +0,0 @@
1
- <?php
2
- class Tagalys_Tsearch_Model_Engine extends Mage_Core_Model_Abstract {
3
-
4
- private function _makeTagalysRequest() {
5
- try {
6
- $current_list_mode = Mage::app()->getLayout()->createBlock('catalog/product_list_toolbar')->getCurrentMode();
7
-
8
- if( $current_list_mode == "grid" || $current_list_mode == "grid-list") {
9
- $defaultLimit = Mage::getStoreConfig('catalog/frontend/grid_per_page');
10
-
11
- } else if($current_list_mode == "list" || $current_list_mode == "list-grid") {
12
- $defaultLimit = Mage::getStoreConfig('catalog/frontend/list_per_page');
13
- }
14
-
15
- $service = Mage::getSingleton("tsearch/client_connector");
16
- $query = Mage::app()->getRequest()->getParam('q');
17
-
18
- $request = array();
19
- $payload = array();
20
- $filters = array();
21
- $request = Mage::app()->getRequest()->getParams();
22
- $entity = 'catalog_product';
23
-
24
- foreach ($request as $key => $value) {
25
- $code = $key;
26
- $attr = Mage::getResourceModel('catalog/eav_attribute')
27
- ->loadByCode($entity,$code);
28
-
29
- if ($attr->getId()) {
30
- $filters[$key] = array($request[$key]);
31
- }
32
-
33
- }
34
- if(isset($request["cat"])) {
35
- $filters["__categories"] = array($request["cat"]);
36
- // $payload["f"] = $category;
37
- }
38
- if(isset($request["qf"])) {
39
- foreach(explode("~",$request["qf"]) as $qf ) {
40
- list($k, $v) = explode('-', $qf);
41
- if($k == "cat") {
42
- $result[ "__categories" ] = array($v);
43
- } else {
44
- $result[ $k ] = array($v);
45
- }
46
- }
47
- $payload["qf"] = $result;
48
- }
49
- if(isset($request["min"]) && isset($request["max"])) {
50
- $filters["price"] = array("min" => $request["min"], "max" => $request["max"] );
51
- }
52
- if(!empty($filters)) {
53
- $payload["f"] = ($filters);
54
- }
55
-
56
- //$payload['filters'] = true;
57
- $payload['request'] = array("results","total","filters","sort_options");
58
- $payload['q'] = $query;
59
- $session_limit = $request["limit"]; //Mage::getSingleton('catalog/session')->getLimitPage();
60
-
61
- $payload['per_page'] = (!empty($session_limit) ? $session_limit : $defaultLimit);
62
- $payload['page'] = (empty($request["p"]) ? 1 : $request["p"]);
63
-
64
-
65
- //by aaditya
66
- if(isset($request['order'])) {
67
- $payload['sort'] = $request['order']."-".$request['dir'];
68
- // $payload['order'] = $request['dir'];
69
- } else {
70
- $payload['sort'] = $payload['sort']; //Mage::getSingleton('catalog/session')->getSortOrder();
71
- }
72
- $user_id = "";
73
- $request["seed"] = "";
74
- if (Mage::getSingleton('customer/session')->isLoggedIn()) {
75
- $customer = Mage::getSingleton('customer/session')->getCustomer();
76
- $user_id = $customer->getID();
77
- }
78
-
79
- $device_id = Mage::getModel('core/cookie')->get('__ta_device');
80
- $visitor_id = Mage::getModel('core/cookie')->get('__ta_visit');
81
-
82
- if (isset($payload)) {
83
- $payload['user'] = (array("ip" => Mage::helper('core/http')->getRemoteAddr(), "snapshot" => $request["snapshot"] , "visitor_id" => $visitor_id, "user_id" => $user_id , "device_id" => $device_id));
84
- }
85
-
86
- $response = $service->searchProduct($payload);
87
- } catch (Exception $e) {
88
- Mage::log('Tagalys_Tsearch_Model_Engine::Tagalys Request Error: '.$e->getMessage(), null, 'tagalys.log');
89
- }
90
- }
91
-
92
- public function getCatalogSearchResult() {
93
- $this->_makeTagalysRequest();
94
- }
95
-
96
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Model/Observer.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
- class Tagalys_Tsearch_Model_Observer {
3
-
4
- public function createSearchResultPage(Varien_Event_Observer $observer) {
5
- if(Mage::helper('tagalys_core')->getTagalysConfig('is_tsearch_active')) {
6
- return Mage::getModel("tsearch/engine")->getCatalogSearchResult();
7
- }
8
- }
9
-
10
- }
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Model/Resource/Catalog/Product/Collection.php DELETED
@@ -1,368 +0,0 @@
1
- <?php
2
- /**
3
- * Custom catalog product collection model.
4
- *
5
- * @package Tagalys_Tsearch
6
- * @subpackage Tagalys_Tsearch_Model
7
- * @author Tagalys
8
- */
9
- class Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection extends Mage_Catalog_Model_Resource_Product_Collection
10
- {
11
- /**
12
- * @var Tagalys_Tsearch_Model_Resource_Engine_Abstract Search engine.
13
- */
14
- protected $_engine;
15
-
16
- /**
17
- * @var array Faceted data.
18
- */
19
- protected $_facetedData = array();
20
-
21
- /**
22
- * @var array Facets conditions.
23
- */
24
- protected $_facetsConditions = array();
25
-
26
- /**
27
- * @var array General default query.
28
- */
29
- protected $_generalDefaultQuery = array('*' => '*');
30
-
31
- /**
32
- * @var string Search query text.
33
- */
34
- protected $_searchQueryText = '';
35
-
36
- /**
37
- * @var array Search query filters.
38
- */
39
- protected $_searchQueryFilters = array();
40
-
41
- protected $_searchCategoryFilters =array();
42
-
43
- /**
44
- * @var array Search query range filters.
45
- */
46
- protected $_searchQueryRangeFilters = array();
47
-
48
- /**
49
- * @var array Search entity ids.
50
- */
51
- protected $_searchedEntityIds = array();
52
-
53
- /**
54
- * @var array Sort by definition.
55
- */
56
- protected $_sortBy = array();
57
-
58
- protected $qt = 'search';
59
-
60
- protected $stats =array();
61
-
62
- /**
63
- * Adds facet condition to current collection.
64
- *
65
- * @param string $field
66
- * @param mixed $condition
67
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
68
- */
69
- public function addFacetCondition($field, $condition = null)
70
- {
71
- if (array_key_exists($field, $this->_facetsConditions)) {
72
- if (!empty($this->_facetsConditions[$field])){
73
- $this->_facetsConditions[$field] = array($this->_facetsConditions[$field]);
74
- }
75
- $this->_facetsConditions[$field][] = $condition;
76
- } else {
77
- $this->_facetsConditions[$field] = $condition;
78
- }
79
-
80
- return $this;
81
- }
82
-
83
- /**
84
- * Stores filter query.
85
- *
86
- * @param array $params
87
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
88
- */
89
- public function addFqFilter($params)
90
- {
91
- if (is_array($params)) {
92
- foreach ($params as $field => $value) {
93
- $this->_searchQueryFilters[$field] = $value;
94
- }
95
- }
96
-
97
- return $this;
98
- }
99
-
100
- /**
101
- * Stores filter query.
102
- *
103
- * @param array $params
104
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
105
- */
106
- public function addCategoryId($id)
107
- {
108
- $this->_searchCategoryFilters = $id;
109
-
110
- return $this;
111
- }
112
-
113
- /**
114
- * setting the query type
115
- */
116
- public function setQueryType($qt = 'search'){
117
- $this->qt = $qt;
118
- return $this;
119
- }
120
-
121
- /**
122
- * Stores range filter query.
123
- *
124
- * @param array $params
125
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
126
- */
127
- public function addFqRangeFilter($params)
128
- {
129
- if (is_array($params)) {
130
- foreach ($params as $field => $value) {
131
- $this->_searchQueryRangeFilters[$field] = $value;
132
- }
133
- }
134
-
135
- return $this;
136
- }
137
-
138
- /**
139
- * Stores query text filter.
140
- *
141
- * @param $query
142
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
143
- */
144
- public function addSearchFilter($query)
145
- {
146
- $this->_searchQueryText = $query;
147
-
148
- return $this;
149
- }
150
-
151
- /**
152
- * Stores search query filter.
153
- *
154
- * @param mixed $param
155
- * @param null $value
156
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
157
- */
158
- public function addSearchQfFilter($param, $value = null)
159
- {
160
- if (is_array($param)) {
161
- foreach ($param as $field => $value) {
162
- $this->addSearchQfFilter($field, $value);
163
- }
164
- } elseif (isset($value)) {
165
- if (isset($this->_searchQueryFilters[$param]) && !is_array($this->_searchQueryFilters[$param])) {
166
- $this->_searchQueryFilters[$param] = array($this->_searchQueryFilters[$param]);
167
- $this->_searchQueryFilters[$param][] = $value;
168
- } else {
169
- $this->_searchQueryFilters[$param] = $value;
170
- }
171
- }
172
-
173
- return $this;
174
- }
175
-
176
- /**
177
- * Aggregates search query filters.
178
- *
179
- * @return array
180
- */
181
- public function getExtendedSearchParams()
182
- {
183
- $result = $this->_searchQueryFilters;
184
- $result['query_text'] = $this->_searchQueryText;
185
-
186
- return $result;
187
- }
188
-
189
- /**
190
- * Returns faceted data.
191
- *
192
- * @param string $field
193
- * @return array
194
- */
195
- public function getFacetedData($field)
196
- {
197
-
198
- if (array_key_exists($field, $this->_facetedData)) {
199
- return $this->_facetedData[$field];
200
- }
201
-
202
- return array();
203
- }
204
-
205
- /**
206
- * Returns collection size.
207
- *
208
- * @return int
209
- */
210
- public function getSize()
211
- {
212
- if (is_null($this->_totalRecords)) {
213
- $query = $this->_getQuery();
214
- $params = $this->_getParams();
215
- $params['limit'] = 1;
216
- //$this->_engine->getIdsByQuery($query, $params);
217
- $this->_totalRecords = 1;
218
- //$this->_totalRecords = $this->_engine->getLastNumFound();
219
- }
220
-
221
- return $this->_totalRecords;
222
- }
223
-
224
- /**
225
- * Retrieves current collection stats.
226
- * Used for max price.
227
- *
228
- * @param $fields
229
- * @return mixed
230
- */
231
- public function getStats($field)
232
- {
233
- return isset($this->stats[$field])?$this->stats[$field]:array();
234
- }
235
-
236
- /**
237
- * Defines current search engine.
238
- *
239
- * @param Tagalys_Tsearch_Model_Resource_Engine_Abstract $engine
240
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
241
- */
242
- public function setEngine(Tagalys_Tsearch_Model_Resource_Engine_Abstract $engine)
243
- {
244
- $this->_engine = $engine;
245
-
246
- return $this;
247
- }
248
-
249
- /**
250
- * Stores sort order.
251
- *
252
- * @param string $attribute
253
- * @param string $dir
254
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
255
- */
256
- public function setOrder($attribute, $dir = self::SORT_ORDER_DESC)
257
- {
258
- $this->_sortBy[] = array($attribute => $dir);
259
-
260
- return $this;
261
- }
262
-
263
- /**
264
- * Handles collection filtering by ids retrieves from search engine.
265
- * Will also stores faceted data and total records.
266
- *
267
- * @return Mage_Catalog_Model_Resource_Product_Collection
268
- */
269
- protected function _beforeLoad()
270
- {
271
- if ($this->_engine) {
272
- $result = $this->_engine->getIdsByQuery($this->qt, $this->_getParams());
273
- $this->_facetedData = isset($result['faceted_data']) ? $result['faceted_data'] : array();
274
- $this->_totalRecords = isset($result['total_count']) ? $result['total_count'] : null;
275
- $this->stats = isset($result["stats"])?$result["stats"] :array();
276
- $this->results = isset($result["results"]) ? $result["results"] : array();
277
- }
278
- foreach($this->results as $result){
279
- $product = new Mage_Catalog_Model_Product();
280
- $result['id'] = $result['uniqueId'];
281
- $product->addData($result);
282
- $this->_items[$result['id']]=$product;
283
- }
284
-
285
- return parent::_beforeLoad();
286
- }
287
-
288
-
289
-
290
- /**
291
- * Load collection data into object items
292
- *
293
- * @return Mage_Eav_Model_Entity_Collection_Abstract
294
- */
295
- public function load($printQuery = false, $logQuery = false)
296
- {
297
- if ($this->isLoaded()) {
298
- return $this;
299
- }
300
- Varien_Profiler::start('__EAV_COLLECTION_BEFORE_LOAD__');
301
- Mage::dispatchEvent('eav_collection_abstract_load_before', array('collection' => $this));
302
- $this->_beforeLoad();
303
- Varien_Profiler::stop('__EAV_COLLECTION_BEFORE_LOAD__');
304
-
305
-
306
- Varien_Profiler::start('__EAV_COLLECTION_LOAD_ENT__');
307
- // $this->_loadEntities($printQuery, $logQuery);
308
- Varien_Profiler::stop('__EAV_COLLECTION_LOAD_ENT__');
309
- Varien_Profiler::start('__EAV_COLLECTION_LOAD_ATTR__');
310
- // $this->_loadAttributes($printQuery, $logQuery);
311
- Varien_Profiler::stop('__EAV_COLLECTION_LOAD_ATTR__');
312
-
313
- Varien_Profiler::start('__EAV_COLLECTION_ORIG_DATA__');
314
- /*
315
- foreach ($this->_items as $item) {
316
- $item->setOrigData();
317
- }*/
318
- Varien_Profiler::stop('__EAV_COLLECTION_ORIG_DATA__');
319
-
320
- $this->_setIsLoaded();
321
- Varien_Profiler::start('__EAV_COLLECTION_AFTER_LOAD__');
322
- $this->_afterLoad();
323
- Varien_Profiler::stop('__EAV_COLLECTION_AFTER_LOAD__');
324
- return $this;
325
- }
326
-
327
- /**
328
- * Retrieves parameters.
329
- *
330
- * @return array
331
- */
332
- protected function _getParams()
333
- {
334
- $store = Mage::app()->getStore($this->getStoreId());
335
- $params = array();
336
- $params['locale_code'] = $store->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE);
337
- $params['filters'] = $this->_searchQueryFilters;
338
- $params['category'] = $this->_searchCategoryFilters;
339
- $params['range_filters'] = $this->_searchQueryRangeFilters;
340
-
341
- if (!empty($this->_sortBy)) {
342
- $params['sort_by'] = $this->_sortBy;
343
- }
344
-
345
- if ($this->_pageSize !== false) {
346
- $page = ($this->_curPage > 0) ? (int) $this->_curPage : 1;
347
- $rowCount = ($this->_pageSize > 0) ? (int) $this->_pageSize : 1;
348
- $params['offset'] = $rowCount * ($page - 1);
349
- $params['limit'] = $rowCount;
350
- }
351
-
352
- if (!empty($this->_facetsConditions)) {
353
- $params['facets'] = $this->_facetsConditions;
354
- }
355
-
356
- return $params;
357
- }
358
-
359
- /**
360
- * Returns stored text query.
361
- *
362
- * @return string
363
- */
364
- protected function _getQuery()
365
- {
366
- return $this->_searchQueryText;
367
- }
368
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/Model/Resource/Catalog/Product/testCollection.php DELETED
@@ -1,368 +0,0 @@
1
- <?php
2
- /**
3
- * Custom catalog product collection model.
4
- *
5
- * @package Tagalys_Tsearch
6
- * @subpackage Tagalys_Tsearch_Model
7
- * @author Tagalys
8
- */
9
- class Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection extends Mage_Catalog_Model_Resource_Product_Collection
10
- {
11
- /**
12
- * @var Tagalys_Tsearch_Model_Resource_Engine_Abstract Search engine.
13
- */
14
- protected $_engine;
15
-
16
- /**
17
- * @var array Faceted data.
18
- */
19
- protected $_facetedData = array();
20
-
21
- /**
22
- * @var array Facets conditions.
23
- */
24
- protected $_facetsConditions = array();
25
-
26
- /**
27
- * @var array General default query.
28
- */
29
- protected $_generalDefaultQuery = array('*' => '*');
30
-
31
- /**
32
- * @var string Search query text.
33
- */
34
- protected $_searchQueryText = '';
35
-
36
- /**
37
- * @var array Search query filters.
38
- */
39
- protected $_searchQueryFilters = array();
40
-
41
- protected $_searchCategoryFilters =array();
42
-
43
- /**
44
- * @var array Search query range filters.
45
- */
46
- protected $_searchQueryRangeFilters = array();
47
-
48
- /**
49
- * @var array Search entity ids.
50
- */
51
- protected $_searchedEntityIds = array();
52
-
53
- /**
54
- * @var array Sort by definition.
55
- */
56
- protected $_sortBy = array();
57
-
58
- protected $qt = 'search';
59
-
60
- protected $stats =array();
61
-
62
- /**
63
- * Adds facet condition to current collection.
64
- *
65
- * @param string $field
66
- * @param mixed $condition
67
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
68
- */
69
- public function addFacetCondition($field, $condition = null)
70
- {
71
- if (array_key_exists($field, $this->_facetsConditions)) {
72
- if (!empty($this->_facetsConditions[$field])){
73
- $this->_facetsConditions[$field] = array($this->_facetsConditions[$field]);
74
- }
75
- $this->_facetsConditions[$field][] = $condition;
76
- } else {
77
- $this->_facetsConditions[$field] = $condition;
78
- }
79
-
80
- return $this;
81
- }
82
-
83
- /**
84
- * Stores filter query.
85
- *
86
- * @param array $params
87
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
88
- */
89
- public function addFqFilter($params)
90
- {
91
- if (is_array($params)) {
92
- foreach ($params as $field => $value) {
93
- $this->_searchQueryFilters[$field] = $value;
94
- }
95
- }
96
-
97
- return $this;
98
- }
99
-
100
- /**
101
- * Stores filter query.
102
- *
103
- * @param array $params
104
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
105
- */
106
- public function addCategoryId($id)
107
- {
108
- $this->_searchCategoryFilters = $id;
109
-
110
- return $this;
111
- }
112
-
113
- /**
114
- * setting the query type
115
- */
116
- public function setQueryType($qt = 'search'){
117
- $this->qt = $qt;
118
- return $this;
119
- }
120
-
121
- /**
122
- * Stores range filter query.
123
- *
124
- * @param array $params
125
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
126
- */
127
- public function addFqRangeFilter($params)
128
- {
129
- if (is_array($params)) {
130
- foreach ($params as $field => $value) {
131
- $this->_searchQueryRangeFilters[$field] = $value;
132
- }
133
- }
134
-
135
- return $this;
136
- }
137
-
138
- /**
139
- * Stores query text filter.
140
- *
141
- * @param $query
142
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
143
- */
144
- public function addSearchFilter($query)
145
- {
146
- $this->_searchQueryText = $query;
147
-
148
- return $this;
149
- }
150
-
151
- /**
152
- * Stores search query filter.
153
- *
154
- * @param mixed $param
155
- * @param null $value
156
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
157
- */
158
- public function addSearchQfFilter($param, $value = null)
159
- {
160
- if (is_array($param)) {
161
- foreach ($param as $field => $value) {
162
- $this->addSearchQfFilter($field, $value);
163
- }
164
- } elseif (isset($value)) {
165
- if (isset($this->_searchQueryFilters[$param]) && !is_array($this->_searchQueryFilters[$param])) {
166
- $this->_searchQueryFilters[$param] = array($this->_searchQueryFilters[$param]);
167
- $this->_searchQueryFilters[$param][] = $value;
168
- } else {
169
- $this->_searchQueryFilters[$param] = $value;
170
- }
171
- }
172
-
173
- return $this;
174
- }
175
-
176
- /**
177
- * Aggregates search query filters.
178
- *
179
- * @return array
180
- */
181
- public function getExtendedSearchParams()
182
- {
183
- $result = $this->_searchQueryFilters;
184
- $result['query_text'] = $this->_searchQueryText;
185
-
186
- return $result;
187
- }
188
-
189
- /**
190
- * Returns faceted data.
191
- *
192
- * @param string $field
193
- * @return array
194
- */
195
- public function getFacetedData($field)
196
- {
197
-
198
- if (array_key_exists($field, $this->_facetedData)) {
199
- return $this->_facetedData[$field];
200
- }
201
-
202
- return array();
203
- }
204
-
205
- /**
206
- * Returns collection size.
207
- *
208
- * @return int
209
- */
210
- public function getSize()
211
- {
212
- if (is_null($this->_totalRecords)) {
213
- $query = $this->_getQuery();
214
- $params = $this->_getParams();
215
- $params['limit'] = 1;
216
- //$this->_engine->getIdsByQuery($query, $params);
217
- $this->_totalRecords = 1;
218
- //$this->_totalRecords = $this->_engine->getLastNumFound();
219
- }
220
-
221
- return $this->_totalRecords;
222
- }
223
-
224
- /**
225
- * Retrieves current collection stats.
226
- * Used for max price.
227
- *
228
- * @param $fields
229
- * @return mixed
230
- */
231
- public function getStats($field)
232
- {
233
- return isset($this->stats[$field])?$this->stats[$field]:array();
234
- }
235
-
236
- /**
237
- * Defines current search engine.
238
- *
239
- * @param Tagalys_Tsearch_Model_Resource_Engine_Abstract $engine
240
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
241
- */
242
- public function setEngine(Tagalys_Tsearch_Model_Resource_Engine_Abstract $engine)
243
- {
244
- $this->_engine = $engine;
245
-
246
- return $this;
247
- }
248
-
249
- /**
250
- * Stores sort order.
251
- *
252
- * @param string $attribute
253
- * @param string $dir
254
- * @return Tagalys_Tsearch_Model_Resource_Catalog_Product_Collection
255
- */
256
- public function setOrder($attribute, $dir = self::SORT_ORDER_DESC)
257
- {
258
- $this->_sortBy[] = array($attribute => $dir);
259
-
260
- return $this;
261
- }
262
-
263
- /**
264
- * Handles collection filtering by ids retrieves from search engine.
265
- * Will also stores faceted data and total records.
266
- *
267
- * @return Mage_Catalog_Model_Resource_Product_Collection
268
- */
269
- protected function _beforeLoad()
270
- {
271
- if ($this->_engine) {
272
- $result = $this->_engine->getIdsByQuery($this->qt, $this->_getParams());
273
- $this->_facetedData = isset($result['faceted_data']) ? $result['faceted_data'] : array();
274
- $this->_totalRecords = isset($result['total_count']) ? $result['total_count'] : null;
275
- $this->stats = isset($result["stats"])?$result["stats"] :array();
276
- $this->results = isset($result["results"]) ? $result["results"] : array();
277
- }
278
- foreach($this->results as $result){
279
- $product = new Mage_Catalog_Model_Product();
280
- $result['id'] = $result['uniqueId'];
281
- $product->addData($result);
282
- $this->_items[$result['id']]=$product;
283
- }
284
-
285
- return parent::_beforeLoad();
286
- }
287
-
288
-
289
-
290
- /**
291
- * Load collection data into object items
292
- *
293
- * @return Mage_Eav_Model_Entity_Collection_Abstract
294
- */
295
- public function load($printQuery = false, $logQuery = false)
296
- {
297
- if ($this->isLoaded()) {
298
- return $this;
299
- }
300
- Varien_Profiler::start('__EAV_COLLECTION_BEFORE_LOAD__');
301
- Mage::dispatchEvent('eav_collection_abstract_load_before', array('collection' => $this));
302
- $this->_beforeLoad();
303
- Varien_Profiler::stop('__EAV_COLLECTION_BEFORE_LOAD__');
304
-
305
-
306
- Varien_Profiler::start('__EAV_COLLECTION_LOAD_ENT__');
307
- // $this->_loadEntities($printQuery, $logQuery);
308
- Varien_Profiler::stop('__EAV_COLLECTION_LOAD_ENT__');
309
- Varien_Profiler::start('__EAV_COLLECTION_LOAD_ATTR__');
310
- // $this->_loadAttributes($printQuery, $logQuery);
311
- Varien_Profiler::stop('__EAV_COLLECTION_LOAD_ATTR__');
312
-
313
- Varien_Profiler::start('__EAV_COLLECTION_ORIG_DATA__');
314
- /*
315
- foreach ($this->_items as $item) {
316
- $item->setOrigData();
317
- }*/
318
- Varien_Profiler::stop('__EAV_COLLECTION_ORIG_DATA__');
319
-
320
- $this->_setIsLoaded();
321
- Varien_Profiler::start('__EAV_COLLECTION_AFTER_LOAD__');
322
- $this->_afterLoad();
323
- Varien_Profiler::stop('__EAV_COLLECTION_AFTER_LOAD__');
324
- return $this;
325
- }
326
-
327
- /**
328
- * Retrieves parameters.
329
- *
330
- * @return array
331
- */
332
- protected function _getParams()
333
- {
334
- $store = Mage::app()->getStore($this->getStoreId());
335
- $params = array();
336
- $params['locale_code'] = $store->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE);
337
- $params['filters'] = $this->_searchQueryFilters;
338
- $params['category'] = $this->_searchCategoryFilters;
339
- $params['range_filters'] = $this->_searchQueryRangeFilters;
340
-
341
- if (!empty($this->_sortBy)) {
342
- $params['sort_by'] = $this->_sortBy;
343
- }
344
-
345
- if ($this->_pageSize !== false) {
346
- $page = ($this->_curPage > 0) ? (int) $this->_curPage : 1;
347
- $rowCount = ($this->_pageSize > 0) ? (int) $this->_pageSize : 1;
348
- $params['offset'] = $rowCount * ($page - 1);
349
- $params['limit'] = $rowCount;
350
- }
351
-
352
- if (!empty($this->_facetsConditions)) {
353
- $params['facets'] = $this->_facetsConditions;
354
- }
355
-
356
- return $params;
357
- }
358
-
359
- /**
360
- * Returns stored text query.
361
- *
362
- * @return string
363
- */
364
- protected function _getQuery()
365
- {
366
- return $this->_searchQueryText;
367
- }
368
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tagalys/Tsearch/etc/config.xml DELETED
@@ -1,98 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <default>
4
- <tsearch>
5
- <endpoint>
6
- <search>/v1/search</search>
7
- </endpoint>
8
- </tsearch>
9
- </default>
10
- <modules>
11
- <Tagalys_Tsearch>
12
- <version>0.2.0</version>
13
- </Tagalys_Tsearch>
14
- </modules>
15
- <frontend>
16
- <layout> <!-- layout declaration -->
17
- <updates>
18
- <tagalys_tsearch>
19
- <file>Tagalys/tsearch.xml</file>
20
- </tagalys_tsearch>
21
- </updates>
22
- </layout>
23
- </frontend>
24
- <global>
25
- <helpers>
26
- <tsearch>
27
- <class>Tagalys_Tsearch_Helper</class>
28
- </tsearch>
29
- </helpers>
30
- <blocks>
31
- <tsearch>
32
- <class>Tagalys_Tsearch_Block</class>
33
- </tsearch>
34
- <catalog>
35
- <rewrite>
36
- <product_list>Tagalys_Tsearch_Block_Catalog_Product_List</product_list>
37
- <product_list_toolbar>Tagalys_Tsearch_Block_Catalog_Product_List_Toolbar</product_list_toolbar>
38
- </rewrite>
39
- </catalog>
40
- <page>
41
- <rewrite>
42
- <html_pager>Tagalys_Tsearch_Block_Page_Html_Pager</html_pager>
43
- </rewrite>
44
- </page>
45
- <!-- <catalogsearch>
46
- <rewrite>
47
- <result>Tagalys_Tsearch_Block_Catalogsearch_Result</result>
48
- </rewrite>
49
- </catalogsearch> -->
50
- <catalogsearch>
51
- <rewrite>
52
- <layer>Tagalys_Tsearch_Block_Catalogsearch_Layer_View</layer>
53
- </rewrite>
54
- </catalogsearch>
55
- <!-- <catalog>
56
- <rewrite>
57
- <state>Mage_Catalog_Block_Layer_State</state>
58
- </rewrite>
59
- </catalog> -->
60
- </blocks>
61
- <models>
62
- <tsearch>
63
- <class>Tagalys_Tsearch_Model</class>
64
- </tsearch>
65
- <tsearch>
66
- <resourceModel>tsearch_resource</resourceModel>
67
- </tsearch>
68
- <tsearch_resource>
69
- <class>Tagalys_Tsearch_Model_Resource</class>
70
- </tsearch_resource>
71
- <catalog>
72
- <rewrite>
73
- <layer>Tagalys_Tsearch_Model_Catalogsearch_Layer</layer>
74
- </rewrite>
75
- </catalog>
76
- </models>
77
- <!-- <resources>
78
- <tsearch_setup>
79
- <setup>
80
- <module>Tagalys_Tsearch</module>
81
- <class>Mage_Core_Model_Resource_Setup</class>
82
- </setup>
83
- </tsearch_setup>
84
- </resources> -->
85
- <events>
86
- <controller_action_predispatch_catalogsearch_result_index>
87
- <observers>
88
- <controller_action_predispatch_catalogsearch_result_handler>
89
- <type>model</type>
90
- <class>tsearch/observer</class>
91
- <method>createSearchResultPage</method>
92
- <args></args>
93
- </controller_action_predispatch_catalogsearch_result_handler>
94
- </observers>
95
- </controller_action_predispatch_catalogsearch_result_index>
96
- </events>
97
- </global>
98
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/layout/Tagalys_core.xml DELETED
@@ -1,22 +0,0 @@
1
- <?xml version="1.0"?>
2
- <layout version="0.1.0">
3
- <adminhtml_tagalys_index>
4
- <reference name="head">
5
- <action method="addCss"><name>css/tagalys-core.css</name></action>
6
- <action method="addJs"><script>tagalys/tagalys-core.js</script></action>
7
- </reference>
8
- <reference name="left">
9
- <block type="tagalys_core/adminhtml_tagalys_edit_tabs" name="tagalys_settings_tabs"/>
10
- </reference>
11
- <reference name="content">
12
- <block type="tagalys_core/adminhtml_tagalys_edit" name="tagalys_settings"/>
13
- </reference>
14
- <block type="core/template" name="tagalys_progress" output="toHtml" template="tagalys/progressbar.phtml"/>
15
- </adminhtml_tagalys_index>
16
- <default>
17
- <reference name="notifications">
18
- <block type="tagalys_core/adminhtml_tagalys_notifications" name="notifications_tagalys" output="toHtml" />
19
- </reference>
20
- </default>
21
- </layout>
22
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/layout/tagalys_core.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <adminhtml_tagalys_index>
4
+ <reference name="head">
5
+ <action method="addCss"><name>css/tagalys/tagalys-configuration.css</name></action>
6
+ <action method="addJs"><script>tagalys-configuration.js</script></action>
7
+ </reference>
8
+ <reference name="left">
9
+ <block type="tagalys_core/adminhtml_tagalys_edit_tabs" name="tagalys_settings_tabs"/>
10
+ </reference>
11
+ <reference name="content">
12
+ <block type="tagalys_core/adminhtml_tagalys_edit" name="tagalys_settings"/>
13
+ </reference>
14
+ </adminhtml_tagalys_index>
15
+ </layout>
16
+
app/design/adminhtml/default/default/template/tagalys/progressbar.phtml DELETED
@@ -1,159 +0,0 @@
1
- <script type="text/javascript">
2
-
3
- var sync = function(transport) {
4
- // var e = "#sync_store_"+transport.request.parameters.store+" "+".status";
5
-
6
- try {
7
- var status = "#sync_store_"+transport.request.parameters.store+" "+".status";
8
-
9
- var message = "#sync_msg_"+transport.request.parameters.store;
10
- if ($$(status).length > 0)
11
- $$(status)[0].update('Loading ..');
12
- if ($$(message).length > 0)
13
- $$(message)[0].update('');
14
- if(/^\d+$/.test(transport.responseText)) {
15
- if(transport.responseText == 100) {
16
- // clearInterval(f);
17
- }
18
- if ($$(status).length > 0)
19
- $$(status)[0].update(transport.responseText+"%");
20
- } else {
21
-
22
- if ($$(message).length > 0)
23
- if ($$(message).length == "Completed") {
24
- $$(status)[0].update('Completed');
25
- $$(message)[0].update('');
26
- }
27
- else
28
- $$(status)[0].update(transport.responseText);
29
- }
30
-
31
- } catch (e) {
32
- clearInterval(s);
33
- console.log(e);
34
- }
35
-
36
- };
37
-
38
- var searchStatus = function(transport) {
39
-
40
- try {
41
- var status = "#search_store_"+transport.request.parameters.store+" "+".status";
42
- var message = "#search_msg_"+transport.request.parameters.store;
43
- if ($$(status).length > 0)
44
- $$(status)[0].update('Loading ..');
45
- if ($$(message).length > 0)
46
- $$(message)[0].update('');
47
- if(/^\d+$/.test(transport.responseText)) {
48
- if(Number(transport.responseText) == 100) {
49
- // clearInterval(s);
50
- }
51
- if ($$(status).length > 0)
52
- $$(status)[0].update(transport.responseText+"%");
53
- } else {
54
-
55
- if ($$(message).length > 0)
56
- if ($$(message).length == "Completed") {
57
- $$(status)[0].update('Completed');
58
- $$(message)[0].update('');
59
- }
60
- else
61
- $$(status)[0].update(transport.responseText);
62
- }
63
- } catch (e) {
64
- clearInterval(f);
65
- console.log(e);
66
- }
67
-
68
- };
69
-
70
-
71
-
72
- function feed_auto_load(storeId) {
73
- new Ajax.Request(
74
- "<?php echo Mage::helper('adminhtml')->getUrl('tagalys/feed/progress/'); ?>",
75
- {
76
- method: 'GET',
77
- loaderArea: false,
78
- parameters: {"store":storeId},
79
- onSuccess : sync
80
- // onFailure : failure
81
- }
82
- );
83
- }
84
-
85
- function search_auto_load(storeId) {
86
- new Ajax.Request(
87
- "<?php echo Mage::helper('adminhtml')->getUrl('tagalys/feed/searchStatus/'); ?>",
88
- {
89
- method: 'GET',
90
- loaderArea: false,
91
- parameters: {"store":storeId},
92
- onSuccess : searchStatus
93
- // onFailure : failure
94
- }
95
- );
96
-
97
- }
98
-
99
- function button_auto_load(){
100
-
101
- new Ajax.Request(
102
- "<?php echo Mage::helper('adminhtml')->getUrl('tagalys/feed/enableButton/'); ?>",
103
- {
104
- method: 'GET',
105
- loaderArea: false,
106
- onSuccess : function(transport) {
107
- if(transport.responseText == "1") {
108
- $$("#admin_tagalys_reload")[0].show();
109
- clearInterval(btn);
110
- } else {
111
- $$("#admin_tagalys_reload")[0].hide();
112
- }
113
- }
114
-
115
- }
116
- );
117
-
118
- }
119
-
120
- function fauto_load() {
121
- <?php foreach (Mage::helper("sync/data")->getSelectedStore() as $key => $value): ?>
122
- <?php $resync = Mage::helper('tagalys_core')->getTagalysConfig('resync'); ?>
123
- <?php if(!(int) Mage::helper('tagalys_core')->getTagalysConfig('search_index_'.$value) || !empty($resync)): ?>
124
-
125
- feed_auto_load('<?php echo $value ?>');
126
- <?php endif ?>
127
- <?php endforeach ?>
128
- }
129
- function sauto_load() {
130
- <?php foreach (Mage::helper("sync/data")->getSelectedStore() as $key => $value): ?>
131
- <?php $resync = Mage::helper('tagalys_core')->getTagalysConfig('resync'); ?>
132
- <?php if(!(int) Mage::helper('tagalys_core')->getTagalysConfig('search_index_'.$value) || !empty($resync)): ?>
133
-
134
- search_auto_load('<?php echo $value ?>');
135
- <?php endif ?>
136
- <?php endforeach ?>
137
- }
138
-
139
-
140
- document.addEventListener("DOMContentLoaded", function(event) {
141
- <?php if(Mage::helper('tagalys_core')->getTagalysConfig('search_complete')): ?>
142
- $$("#admin_tagalys_reload")[0].show();
143
- <?php else: ?>
144
- $$("#admin_tagalys_reload")[0].hide();
145
- <?php endif ?>
146
- <?php foreach (Mage::helper("sync/data")->getSelectedStore() as $key => $value): ?>
147
-
148
- search_auto_load('<?php echo $value ?>');
149
- feed_auto_load('<?php echo $value ?>');
150
-
151
- <?php endforeach ?>
152
-
153
- });
154
-
155
- //Refresh auto_load() function after 10000 milliseconds
156
- f = setInterval(fauto_load,5000);
157
- s = setInterval(sauto_load,5000);
158
- btn = setInterval(button_auto_load, 1000);
159
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/layout/tagalys/ss.xml DELETED
@@ -1,7 +0,0 @@
1
- <?xml version="1.0"?>
2
- <layout version="0.1.0">
3
- <default>
4
- <block type="core/template" name="tagalys_ss" output="toHtml" template="tagalys/tagalys_ss.phtml"/>
5
- </default>
6
- </layout>
7
-
 
 
 
 
 
 
 
app/design/frontend/base/default/layout/tagalys_merchandising.xml DELETED
@@ -1,79 +0,0 @@
1
- <?xml version="1.0"?>
2
-
3
- <layout version="0.1.0">
4
- <merchandisingpage_index_index translate="label">
5
- <!-- Set title -->
6
- <reference name="head">
7
- <action method="setTitle">
8
- <title>Merchandising</title>
9
- </action>
10
-
11
- </reference>
12
- <!-- Switch root template to 1 column -->
13
- <reference name="root">
14
- <action method="setTemplate">
15
- <template>page/2columns-left.phtml</template>
16
- </action>
17
- <block type="page/html_breadcrumbs" as="breadcrumbs" name="mp_template" template="tagalys_merchandising_page/mp_template.phtml"></block>
18
- <block type="core/template" name="mp_template" template="tagalys_merchandising_page/mp_template.phtml"></block>
19
- </reference>
20
-
21
- <!-- <update handle="catalog_category_layered"/>
22
-
23
- Remove Magento layered navigation
24
- <remove name="catalog.leftnav"/> -->
25
-
26
- <!-- Add MPage Specific Layered navigation -->
27
-
28
- <reference name="left">
29
- <block type="catalog/layer" name="prduct_filter" template="catalog/layer/view.phtml">
30
- <block type="core/text_list" name="catalog.leftnav.state.renderers" as="state_renderers" />
31
- </block>
32
- </reference>
33
-
34
- <reference name="content">
35
- <!-- Ajax Scroll-->
36
- <!-- <block type="core/template" name="ajaxscroll_js" template="ajaxscroll/ajaxscroll.phtml" after="-" /> -->
37
- <!-- End Ajax Scroll -->
38
-
39
- <!-- Add product list to content -->
40
- <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
41
-
42
- <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
43
-
44
- <!-- Add pager to toolbar -->
45
- <block type="page/html_pager" name="product_list_toolbar_pager"/>
46
- </block>
47
-
48
- <!-- Specify toolbar block name -->
49
- <action method="setToolbarBlockName">
50
- <name>product_list_toolbar</name>
51
- </action>
52
-
53
- <!-- Use custom product collection -->
54
- <!-- <action method="setCollection">
55
- <value helper="merchandisingpage/getProductCollection" />
56
- </action> -->
57
-
58
- <!-- Use custom available sort by orders -->
59
- <action method="setAvailableOrders">
60
- <value helper="merchandisingpage/getAvailableOrders" />
61
- </action>
62
-
63
- <!-- Set the default sort by order -->
64
- <!-- <action method="setSortBy">
65
- <value>price</value>
66
- </action> -->
67
-
68
- <!-- Set default direction to ascending -->
69
- <!-- <action method="setDefaultDirection">
70
- <value>asc</value>
71
- </action> -->
72
-
73
- <!-- <action method="setColumnCount">
74
- <coulumn>5</coulumn>
75
- </action> -->
76
- </block>
77
- </reference>
78
- </merchandisingpage_index_index>
79
- </layout>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/layout/tagalys_search_suggestions.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="content">
5
+ <block type="core/template" template="tagalys_search_suggestions/search_suggestions.phtml" name="tagalys_search_suggestions" />
6
+ </reference>
7
+ </default>
8
+ </layout>
app/design/frontend/base/default/template/tagalys/tagalys_ss.phtml DELETED
@@ -1,128 +0,0 @@
1
-
2
- <?php
3
- if(Mage::helper('tagalys_core')->getTagalysConfig('setup_complete') && Mage::helper('tagalys_core')->getTagalysConfig('search_complete') && Mage::helper('tagalys_core')->getTagalysConfig('is_tsearchsuggestion_active')): ?>
4
- <script type="text/javascript" src="https://s3-ap-southeast-1.amazonaws.com/tagalys-assets/ss-v4.js"></script>
5
- <script type="text/javascript">
6
-
7
- <?php
8
- if( Mage::helper('core')->isModuleEnabled('Tagalys_Tsearch') ){
9
- if(Mage::helper('core')->isModuleEnabled('Tagalys_Tsearch') && Mage::helper('tagalys_core')->getTagalysConfig('is_tsearch_active')){
10
- $tagalys_enabled = true;
11
- } else {
12
- $tagalys_enabled = false;
13
- }
14
- }
15
- ?>
16
- tagalys_base_url = "<?php echo Mage::helper('catalogsearch')->getResultUrl(""); ?>";
17
- base_url = "<?php echo Mage::getBaseUrl(); ?>";
18
- function load_script_asyncronously(url, callback) {
19
- var script = document.createElement("script");
20
- script.type = "text/javascript";
21
- script.async = true;
22
- if (script.readyState) {
23
- script.onreadystatechange = function () {
24
- if (script.readyState == "loaded" || script.readyState == "complete") {
25
- script.onreadystatechange = null;
26
- if (callback && typeof callback === "function") {
27
- callback();
28
- }
29
- }
30
- };
31
- } else {
32
- script.onload = function () {
33
- if (callback && typeof callback === "function") {
34
- callback();
35
- }
36
- };
37
- }
38
- script.src = url;
39
- (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(script);
40
- }
41
- try {
42
- (function( $ ) {
43
- console.log("Loading tagalys search suggestions");
44
-
45
- $.fn.tagalys_search_suggestions.search_link = function( q, qf, qin ) {
46
- var cat_base_url = base_url+"catalog/category/view/id/";
47
- var search_url_base = tagalys_base_url;
48
- if (typeof(qf) == 'undefined' || $.isEmptyObject(qf)) {
49
- return (search_url_base + encodeURIComponent(q));
50
- } else {
51
- <?php
52
- if($tagalys_enabled): ?> //{
53
- str = Object.keys(qf).map(function(key){
54
- if(key == "__categories")
55
- keyword = "cat";
56
- else
57
- keyword = key;
58
- return encodeURIComponent(keyword) + "-"+ encodeURIComponent(qf[key]);
59
- }).join('~');
60
- qf_param = encodeURIComponent("qf") + '=' + str;
61
-
62
- return tagalys_base_url.concat(encodeURIComponent(q) +"&"+qf_param);
63
- //}
64
- <?php else: ?> //{
65
- if (typeof(qin) == "undefined" ) {
66
- if (typeof(qf) != "undefined" && qf.hasOwnProperty("__categories")) {
67
- return cat_base_url+Number(qf["__categories"]);
68
- }
69
- }
70
- var str = Object.keys(qf).map(function(key){
71
- if(key == "__categories")
72
- keyword = "cat";
73
- else
74
- keyword = key;
75
- return encodeURIComponent(keyword) + '=' + encodeURIComponent(qf[key]);
76
- }).join('&');
77
- return tagalys_base_url.concat(encodeURIComponent(q) +"&"+str);
78
- // }
79
- <?php endif ?>
80
- }
81
-
82
- };
83
-
84
- $.fn.tagalys_search_suggestions.popular_searches = function() {
85
-
86
- <?php $popular_searches = (file_get_contents(Mage::getBaseDir("media"). DS ."tagalys" . DS."tagalys-popularsearches-".Mage::app()->getStore()->getStoreId().".json")); ?>
87
- var popular_searches = '<?php echo $popular_searches ?>';
88
- return popular_searches.length > 0 ? JSON.parse(popular_searches) : JSON.parse('[]');
89
- };
90
-
91
- $.fn.tagalys_public_api = {
92
- server: '<?php echo Mage::helper("tagalys_core")->getTagalysConfig("api_server") ?>',
93
- identification: {"client_code":'<?php echo Mage::helper("tagalys_core")->getTagalysConfig("client_code") ?>',"api_key":'<?php echo Mage::helper("tagalys_core")->getTagalysConfig("public_api_key") ?>',"store_id":'<?php echo Mage::app()->getStore()->getStoreId() ?>'}
94
- }
95
-
96
- $('<?php echo Mage::helper("tagalys_core")->getTagalysConfig("search_box") ?>').tagalys_search_suggestions({
97
- align_to_parent: '<?php echo Mage::helper("tagalys_core")->getTagalysConfig("search_box_container") ?>',
98
- api: {
99
- server: '<?php echo Mage::helper("tagalys_core")->getTagalysConfig("api_server") ?>',
100
- identification: {
101
- client_code: '<?php echo Mage::helper("tagalys_core")->getTagalysConfig("client_code") ?>',
102
- api_key: '<?php echo Mage::helper("tagalys_core")->getTagalysConfig("public_api_key") ?>',
103
- store_id: '<?php echo Mage::app()->getStore()->getStoreId() ?>'
104
- }
105
- },
106
- currency: {
107
- <?php $currency = Mage::helper('search_suggestions')->getCurrentCurrency(); ?>
108
- label: "<?php echo $currency[0]['label']; ?>",
109
- exchange_rate: "<?php echo $currency[0]['exchange_rate']; ?>",
110
- fractional_digits:"<?php echo $currency[0]['fractional_digits']; ?>"
111
- },
112
- callbacks: {
113
- click_search: function($a) {
114
- $.fn.tagalys_analytics.track_asynchronously('search', $a.data('tagalys-search'), 'tagalys-search-suggestions');
115
- return true;
116
- }
117
- }
118
- });
119
-
120
- }( jQuery ));
121
- } catch(err) { //We can also throw from try block and catch it here
122
- console.log(err);
123
- }
124
- </script>
125
- <?php endif ?>
126
-
127
-
128
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/tagalys_merchandising_page/mp_template.phtml DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- $helper = Mage::helper('tagalys_core');
3
- // $html = str_get_html($helper->getTagalysConfig('merchandising_page_template'));
4
-
5
- // $html->find('h1')->innertext = "Merchandising Page";
6
-
7
- // var_dump($this->getVariable('res'));
8
-
9
- $service = Mage::helper("merchandisingpage");
10
- $res = $service->getTagalysSearchData();
11
- // var_dump($res);
12
-
13
- $html = $helper->getTagalysConfig('merchandising_page_template');
14
-
15
- $html = str_replace("{{title}}", isset($res['name']) ? $res['name'] : "" , $html);
16
- $html = str_replace("{{description}}", isset($res['variables']['description']) ? $res['variables']['description'] : "", $html);
17
- $html = str_replace("{{banner_image_url}}", isset($res['variables']['banner_image_url']) ? $res['variables']['banner_image_url'] : "", $html);
18
-
19
- echo $html;
20
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/tagalys_mpages/index.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="tagalys-namespace" id="tagalys-namespace">
2
+
3
+ </div>
4
+
5
+ <script type="text/javascript">
6
+ <?php
7
+ $api_credentials = json_decode(Mage::getModel('tagalys_core/config')->getTagalysConfig("api_credentials"), true);
8
+ $currency = Mage::helper('search_suggestions')->getCurrentCurrency();
9
+ ?>
10
+ (function( $ ) {
11
+ $('body').tagalys_context({
12
+ api_server: '<?php echo $api_credentials['api_server'] ?>',
13
+ api_identification: {"client_code":"<?php echo $api_credentials['client_code'] ?>","api_key":"<?php echo $api_credentials['public_api_key'] ?>","store_id":"<?php echo Mage::app()->getStore()->getStoreId() ?>","currency":"<?php echo $currency[0]['id']; ?>"},
14
+ currency: {
15
+ label: "<?php echo $currency[0]['label']; ?>",
16
+ exchange_rate: "<?php echo $currency[0]['exchange_rate']; ?>",
17
+ fractional_digits:"<?php echo $currency[0]['fractional_digits']; ?>"
18
+ }
19
+ });
20
+ <?php $params = Mage::app()->getRequest()->getParams(); ?>
21
+ $('#tagalys-namespace').tagalys_mpage({ name: '<?php echo $params['mpage'] ?>' });
22
+ }(jQuery));
23
+ </script>
app/design/frontend/base/default/template/tagalys_search/index.phtml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="tagalys-namespace" id="tagalys-namespace">
2
+
3
+ </div>
4
+
5
+ <script type="text/javascript">
6
+ <?php
7
+ $api_credentials = json_decode(Mage::getModel('tagalys_core/config')->getTagalysConfig("api_credentials"), true);
8
+ $currency = Mage::helper('search_suggestions')->getCurrentCurrency();
9
+ ?>
10
+ (function( $ ) {
11
+ $('body').tagalys_context({
12
+ api_server: '<?php echo $api_credentials['api_server'] ?>',
13
+ api_identification: {"client_code":"<?php echo $api_credentials['client_code'] ?>","api_key":"<?php echo $api_credentials['public_api_key'] ?>","store_id":"<?php echo Mage::app()->getStore()->getStoreId() ?>","currency":"<?php echo $currency[0]['id']; ?>"},
14
+ currency: {
15
+ label: "<?php echo $currency[0]['label']; ?>",
16
+ exchange_rate: "<?php echo $currency[0]['exchange_rate']; ?>",
17
+ fractional_digits:"<?php echo $currency[0]['fractional_digits']; ?>"
18
+ }
19
+ });
20
+ $('#tagalys-namespace').tagalys_search_results();
21
+ }(jQuery));
22
+ </script>
app/design/frontend/base/default/template/tagalys_search_suggestions/search_suggestions.phtml ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if(Mage::helper('tagalys_core')->isTagalysModuleEnabled('search_suggestions') || Mage::helper('tagalys_core')->isTagalysModuleEnabled('search') || Mage::helper('tagalys_core')->isTagalysModuleEnabled('mpages')): ?>
2
+ <script src='https://s3-ap-southeast-1.amazonaws.com/tagalys-assets/tagalys-plugins-v2.js' type='text/javascript'></script>
3
+ <?php endif; ?>
4
+ <?php if(Mage::helper('tagalys_core')->isTagalysModuleEnabled('search_suggestions')): ?>
5
+ <?php
6
+ if (Mage::helper('tagalys_core')->isTagalysModuleEnabled('search') ){
7
+ $tagalys_search_enabled = true;
8
+ } else {
9
+ $tagalys_search_enabled = false;
10
+ }
11
+ ?>
12
+
13
+ <script>
14
+ (function( $ ) {
15
+ $.fn.tagalys_search_suggestions.search_link = function( q, qf, qin ) {
16
+ var categories_base_url = "<?php echo Mage::getBaseUrl(); ?>catalog/category/view/id/";
17
+ var tagalys_search_base_url = "<?php echo Mage::getUrl('tsearch'); ?>?q=";
18
+ var magento_search_base_url = "<?php echo Mage::helper('catalogsearch')->getResultUrl(""); ?>";
19
+ if (typeof(qf) == 'undefined' || $.isEmptyObject(qf)) {
20
+ <?php if($tagalys_search_enabled): ?>
21
+ return (tagalys_search_base_url + encodeURIComponent(q));
22
+ <?php else: ?>
23
+ return (magento_search_base_url + encodeURIComponent(q));
24
+ <?php endif; ?>
25
+ } else {
26
+ <?php if($tagalys_search_enabled): ?>
27
+ str = Object.keys(qf).map(function(key){
28
+ return encodeURIComponent(key) + "-"+ encodeURIComponent(qf[key]);
29
+ }).join('~');
30
+ qf_param = encodeURIComponent("qf") + '=' + str;
31
+
32
+ return tagalys_search_base_url.concat(encodeURIComponent(q) +"&"+qf_param);
33
+ <?php else: ?>
34
+ if (typeof(qin) == "undefined" ) {
35
+ if (typeof(qf) != "undefined" && qf.hasOwnProperty("__categories")) {
36
+ return categories_base_url+Number(qf["__categories"]);
37
+ }
38
+ }
39
+ var str = Object.keys(qf).map(function(key){
40
+ if(key == "__categories")
41
+ keyword = "cat";
42
+ else
43
+ keyword = key;
44
+ return encodeURIComponent(keyword) + '=' + encodeURIComponent(qf[key]);
45
+ }).join('&');
46
+ return magento_search_base_url.concat(encodeURIComponent(q) +"&"+str);
47
+ <?php endif ?>
48
+ }
49
+ };
50
+ $.fn.tagalys_search_suggestions.popular_searches = function() {
51
+ <?php
52
+ try {
53
+ $popular_searches = Mage::getModel('tagalys_core/config')->getTagalysConfig('store:'.Mage::app()->getStore()->getId().':popular_searches');
54
+ if ($popular_searches) {
55
+ echo 'return ' . $popular_searches . ';';
56
+ } else {
57
+ echo 'return [];';
58
+ }
59
+ } catch (Exception $e) {
60
+ echo 'return [];';
61
+ }
62
+ ?>
63
+ };
64
+ <?php
65
+ $api_credentials = json_decode(Mage::getModel('tagalys_core/config')->getTagalysConfig("api_credentials"), true);
66
+ ?>
67
+ $.fn.tagalys_public_api.server = '<?php echo $api_credentials['api_server'] ?>';
68
+ $.fn.tagalys_public_api.identification = {"client_code":"<?php echo $api_credentials['client_code'] ?>","api_key":"<?php echo $api_credentials['public_api_key'] ?>","store_id":"<?php echo Mage::app()->getStore()->getStoreId() ?>"};
69
+ <?php
70
+ $currency = Mage::helper('search_suggestions')->getCurrentCurrency();
71
+ ?>
72
+ $('#search').tagalys_search_suggestions({
73
+ currency: {
74
+ label: "<?php echo $currency[0]['label']; ?>",
75
+ exchange_rate: "<?php echo $currency[0]['exchange_rate']; ?>",
76
+ fractional_digits:"<?php echo $currency[0]['fractional_digits']; ?>"
77
+ },
78
+ track: 'asynchronous'
79
+ });
80
+ }( jQuery ));
81
+ </script>
82
+ <?php endif ?>
app/etc/modules/Tagalys_Core.xml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version = "1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Tagalys_Core>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <version>0.3.0</version>
8
+ </Tagalys_Core>
9
+ </modules>
10
+ </config>
11
+
app/etc/modules/Tagalys_MerchandisingPage.xml DELETED
@@ -1,14 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Tagalys_MerchandisingPage>
5
- <active>true</active>
6
- <codePool>local</codePool>
7
- <version>0.1.0</version>
8
- <depends>
9
-
10
- <Tagalys_Tsearch />
11
- </depends>
12
- </Tagalys_MerchandisingPage>
13
- </modules>
14
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/etc/modules/Tagalys_Mpages.xml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version = "1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Tagalys_Mpages>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <version>0.1.0</version>
8
+ </Tagalys_Mpages>
9
+ </modules>
10
+ </config>
11
+
app/etc/modules/Tagalys_Search.xml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version = "1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Tagalys_Search>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <version>0.1.0</version>
8
+ </Tagalys_Search>
9
+ </modules>
10
+ </config>
11
+
app/etc/modules/Tagalys_SearchSuggestions.xml CHANGED
@@ -1,26 +1,11 @@
1
- <?xml version = "1.0"?>
2
- <config>
3
- <modules>
4
- <Tagalys_SearchSuggestions>
5
- <active>true</active>
6
- <codePool>local</codePool>
7
- <version>1.0.0</version>
8
- </Tagalys_SearchSuggestions>
9
- <Tagalys_PopularSearches>
10
- <active>true</active>
11
- <codePool>local</codePool>
12
- <version>1.0.0</version>
13
- </Tagalys_PopularSearches>
14
- <Tagalys_Core>
15
- <active>true</active>
16
- <codePool>local</codePool>
17
- <version>0.2.0</version>
18
- </Tagalys_Core>
19
- <Tagalys_Sync>
20
- <active>true</active>
21
- <codePool>local</codePool>
22
- <version>0.2.0</version>
23
- </Tagalys_Sync>
24
- </modules>
25
- </config>
26
-
1
+ <?xml version = "1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Tagalys_SearchSuggestions>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <version>0.1.0</version>
8
+ </Tagalys_SearchSuggestions>
9
+ </modules>
10
+ </config>
11
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/etc/modules/Tagalys_Tsearch.xml DELETED
@@ -1,10 +0,0 @@
1
- <?xml version = "1.0"?>
2
- <config>
3
- <modules>
4
- <Tagalys_Tsearch>
5
- <active>true</active>
6
- <codePool>local</codePool>
7
- <version>1.0.0</version>
8
- </Tagalys_Tsearch>
9
- </modules>
10
- </config>
 
 
 
 
 
 
 
 
 
 
js/tagalys-configuration.js ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ document.addEventListener("DOMContentLoaded", function (e) {
2
+ if(typeof($$("#tagalys_admin_core_agree_start_sync")[0]) != "undefined") {
3
+ $$("#tagalys_admin_core_agree_start_sync")[0].on("change", function () {
4
+ // alert($$("#tagalys_admin_core_agree_start_sync")[0].value);
5
+ document.getElementById('tagalys_admin_core_submit').disabled = !document.getElementById('tagalys_admin_core_submit').disabled;
6
+ });
7
+ }
8
+ });
js/tagalys/tagalys-core.js DELETED
@@ -1,9 +0,0 @@
1
- document.addEventListener("DOMContentLoaded", function (e) {
2
- if(typeof($$("#admin_checkbox")[0]) != "undefined") {
3
- $$("#admin_checkbox")[0].on("change", function() {
4
- // alert($$("#admin_checkbox")[0].value);
5
- document.getElementById('admin_submit').disabled = !document.getElementById('admin_submit').disabled
6
- });
7
- }
8
-
9
- });
 
 
 
 
 
 
 
 
 
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>visual-merchandising-product-listing-campaign-creator</name>
4
- <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license>Tagalys</license>
7
  <channel>community</channel>
@@ -11,10 +11,10 @@
11
  &#xD;
12
  Visual Merchandising allows you to to create, modify or delete product listing pages that can be used from campaigns in SEO, SEM, Social Media and show collections at your online store. Visual Merchandisers do not require any assistance from IT or Tech teams allowing them to focus on managing the platform.</description>
13
  <notes>Any questions or concerns, please email cs@tagalys.com and we will get back to you in less than 24 hours. </notes>
14
- <authors><author><name>Aaditya</name><user>Aaditya</user><email>antony@tagalys.com</email></author></authors>
15
- <date>2017-02-23</date>
16
- <time>10:47:28</time>
17
- <contents><target name="magelocal"><dir><dir name="Tagalys"><dir name="SearchSuggestions"><dir name="Block"><dir name="Catalog"><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="4a1d6c59a119e36f06a9227b4a648f77"/><file name="Category.php" hash="322d606ca40b6c7a976ec09f5080281a"/></dir></dir><file name="Layer.php" hash="4e72f2b2b8788ba0dce51aa38575e313"/></dir></dir><dir name="Helper"><file name="Data.php" hash="91941f034f7fedd5c84ab7cd5c66471e"/></dir><dir name="Model"><dir name="Catalog"><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="897b2f76ab974edea9e4dffa176662f7"/><file name="Category.php" hash="c2c91bcd957559e5b4cb0c0ad9268a7f"/></dir></dir></dir></dir><dir name="controllers"><file name="AutoSuggestController.php" hash="8ef45554e5cc780b7e9f020cd19e28c5"/></dir><dir name="etc"><file name="config.xml" hash="854e13ce3dad489f9da4ae63cadf7512"/></dir></dir><dir name="Core"><dir name="Block"><dir name="Adminhtml"><dir name="Tagalys"><dir name="Edit"><file name="Form.php" hash="f03082a193308464a70ddb12929f6445"/><dir name="Tab"><file name="Credentials.php" hash="ed600b42a2fe12222ef352a9a6b0dbd7"/><file name="Debug.php" hash="300e99069b08e1c7f4ec3d3a7c056ae2"/><file name="Merchandisingpage.php" hash="2fad4e4db56eb1999e421770bbdd70c9"/><file name="Setup.php" hash="8a5b190544b9e26e7d29716b8e3946dd"/><file name="Signup.php" hash="db50f6b1f8fe7c10eba8996adaab5b46"/><file name="Similarproducts.php" hash="336f1e8c7a86babf681ee6b2ff643406"/><file name="Sync.php" hash="df41344ec4ec924ccc34ad3e8b93c8f2"/><file name="Tsearch.php" hash="0f8d06abb0058aa63bb7619d96b54986"/><file name="Tsearchsuggestion.php" hash="66ba155f8119a448ee2c2fdb6e5777d5"/></dir><file name="Tabs.php" hash="334a9a7af439df186e3bf7e73fe92ca6"/></dir><file name="Edit.php" hash="b6ed0a6d60ed8437013316ea2bf4ae8c"/><file name="Notifications.php" hash="a8a462e420cffb43dcc9a3501114e01b"/><file name="Progress.php" hash="9de974b3672b91e25f5062d6d76c350d"/><file name="SearchReady.php" hash="9e58736e1eb8cba32ee0b84b19ee7b6c"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="0a045aa8949d1f1d6b4c299cf2f5579e"/></dir><dir name="Model"><file name="Config.php" hash="6b1fc527b6ee9b6386669d91ada6c0cb"/><dir name="Mysql4"><dir name="Config"><file name="Collection.php" hash="ea729baf00ac3f73ea70eb36cf182699"/></dir><file name="Config.php" hash="f96196b73e2e9bd2ceaf4b6ba8befb1a"/></dir><file name="Observer.php" hash="c3619b4cd7264290bc7f1a34e293ac18"/></dir><dir name="etc"><file name="adminhtml.xml" hash="7be928fd40cff7dda724457e84736624"/><file name="config.xml" hash="7b26e95fe97248975edd7f2c1c75cb80"/></dir><dir name="sql"><dir name="tagalys_core_setup"><file name="mysql4-install-0.2.0.php" hash="50451682b52f41e0e5a2b656b4ed222f"/></dir></dir></dir><dir name="Sync"><dir name="Helper"><file name="Data.php" hash="f6dbd08edafe1f615818e8ea73d412fd"/><file name="Inventory.php" hash="61a553020607ff202ddb6ea32593cc36"/><file name="Service.php" hash="41751ee2f1b4280c9885d448789d5d4d"/><file name="TagalysFeedFactory.php" hash="6b3c3c94042fb25c350ca9dba74ec8ed"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Tagalys"><file name="Cron.php" hash="497ea5cee9239e97275b87743a4341a8"/></dir></dir></dir></dir></dir><file name="Client.php" hash="8040286126ba95b02b6fe52f98668657"/><dir name="Dataflow"><dir name="Convert"><dir name="Adapter"><file name="Io.php" hash="e1796293468adb1340d6336fd37e4a43"/></dir></dir></dir><dir name="Mysql4"><dir name="Queue"><file name="Collection.php" hash="d0228354a318338e31d85e25960b9f5c"/></dir><file name="Queue.php" hash="8c192d482dbbaa48c703f00ef5cf1a73"/></dir><file name="Observer.php" hash="2642389de90e5d5092a12bd9f1f58a20"/><file name="ProductDetails.php" hash="340acb5c3aea7928b71c8d33ff735f11"/><file name="Queue.php" hash="c48db47089e3ca175017c409768aefe5"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ImportController.php" hash="3e0e0d36cb252768a7ccbb823d404752"/><dir name="System"><dir name="Convert"><file name="GuiController.php" hash="0a7755e0004a1db8c3fbfdfee717cdcc"/></dir></dir><file name="TagalysController.php" hash="75b22f6cf00e1d0c55af420d0ea430ce"/></dir><file name="FeedController.php" hash="50795b468dab2326c9695ea8526ee0b8"/></dir><dir name="etc"><file name="config.xml" hash="4e31084dd880f2053e017bebb04b689e"/><file name="wsdl.xml" hash="1479803fedcad805ae6420f0eff141ad"/></dir><dir name="sql"><dir name="sync_setup"><file name="mysql4-install-0.1.0.php" hash="756c821858436db88487a3b121531d0e"/><file name="mysql4-install-0.2.0.php" hash="756c821858436db88487a3b121531d0e"/><file name="mysql4-upgrade-0.1.0-0.2.0.php" hash="1e1fdc5770389a9123a3079e354ad822"/></dir></dir></dir><dir name="PopularSearches"><dir name="Model"><file name="Observer.php" hash="3c4a9c3cb5d23ce28f856620f9f7b0ca"/></dir><dir name="etc"><file name="config.xml" hash="4089d29d49ff24d49446c8fed7c153b5"/></dir></dir><dir name="Tsearch"><dir name="Block"><dir name="Catalog"><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="8d0f3d1786e1350dd3b050dac907f382"/><file name="Category.php" hash="084bd8b9a22699c867902f774eeb7f72"/><file name="Price.php" hash="2db28591e437f65cd52506906ee96663"/></dir><file name="State.php" hash="8dadc65a747943cb9973747495d3a090"/><file name="View.php" hash="28966b74d8cf4d2dd79155c546d4aa51"/></dir><dir name="Product"><dir name="List"><file name="Toolbar.php" hash="f69cedcd9a979c27a18d5fdb2e17084c"/></dir><file name="List.php" hash="360faadf31bc8a3606f789f634ea101b"/><file name=".DS_Store" hash="e4a40ba7f202895bf09cdcf734b701c5"/></dir></dir><dir name="Catalogsearch"><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="3a858ada3f75cf0aa8c327d27daa616b"/></dir><file name="View.php" hash="28c09e321dc22fdbb03b48f057e8ae1b"/></dir><file name="Layer.php" hash="576c376ec352ce14e7f10c7e77fb8b59"/><file name="Result.php" hash="382a1f850d62de8e86617f149244db93"/></dir><dir name="Page"><dir name="Html"><file name="Pager.php" hash="0656951942409b6eb2517ddb2d45b612"/></dir><file name=".DS_Store" hash="1e3895ec3ef0a8efa77b64def497589b"/></dir><file name=".DS_Store" hash="666944fd0d46dafe20060ea2fbca5797"/></dir><dir name="Helper"><file name="Data.php" hash="eb41f6c65c50d6d2d647f434d870018f"/></dir><dir name="Model"><dir name="Catalog"><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="46c0b60daaa32fadba95971faae4e512"/><file name="Category.php" hash="0dfb591ee8a64759177aa93bc2ffbed7"/><file name="Price.php" hash="8c630bc151659d718f7217709ca73808"/></dir></dir><file name="Layer.php" hash="5d005f705e43fc61ce548da82b22a3df"/><dir name="Product"><file name="List.php" hash="8bd460c476e4630149c7e11cb8f50a9c"/></dir></dir><dir name="Catalogsearch"><file name="Layer.php" hash="b32c1e8c132ba771bd0e0490ed97c853"/></dir><dir name="Client"><file name="Connector.php" hash="bb8622863b8e2493bdc78aa0801f99fe"/></dir><file name="Engine.php" hash="785fd4b9e9a98fdfd60b9380233107c2"/><file name="Observer.php" hash="eb77033417011509be021fba2028d018"/><dir name="Resource"><dir name="Catalog"><dir name="Product"><file name="Collection.php" hash="a0bcbb601025bc0af84ee3c11ef6e531"/><file name="testCollection.php" hash="a0bcbb601025bc0af84ee3c11ef6e531"/></dir></dir></dir><file name=".DS_Store" hash="2df909e9d680df01a6532e4b2c6acf8a"/></dir><dir name="etc"><file name="config.xml" hash="544eca65364af5532209fec42770094e"/></dir><file name=".DS_Store" hash="95f3072052f3f15a2b2aca99ce72e737"/></dir><dir name="MerchandisingPage"><dir name="Block"><dir name="Catalog"><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="3c15fec74b97727a980b7ce9e73454e8"/><file name="Category.php" hash="f6d038cbcce24ed67a7a44a30578ba51"/><file name="Price.php" hash="4cd0f3a20102d469e9acbe9cdbe45ec5"/></dir><file name="State.php" hash="34a5c0d451f856e3a4af701c478fbe17"/><file name="View.php" hash="408a7d4e74f1c7e77584d0c0f318fd30"/></dir><dir name="Product"><dir name="List"><file name="Toolbar.php" hash="f36fb9f0654508631bc3f3c8c5e31ad2"/></dir><file name="List.php" hash="35110b9d4cce21669b3febce14343bd1"/></dir></dir><dir name="Catalogsearch"><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="3a858ada3f75cf0aa8c327d27daa616b"/><file name="Attribute.php" hash="3a858ada3f75cf0aa8c327d27daa616b"/></dir><file name="View.php" hash="f978e5be20a3f12db9abc1f0c9872ba5"/><file name="View.php" hash="f978e5be20a3f12db9abc1f0c9872ba5"/></dir><file name="Layer.php" hash="576c376ec352ce14e7f10c7e77fb8b59"/><file name="Result.php" hash="382a1f850d62de8e86617f149244db93"/><file name="Layer.php" hash="576c376ec352ce14e7f10c7e77fb8b59"/><file name="Result.php" hash="382a1f850d62de8e86617f149244db93"/></dir><file name="Filter.php" hash="ed4acfa073dfefdfbc15c705125f3764"/><dir name="Page"><dir name="Html"><file name="Pager.php" hash="323a99730a43b8bce5f887feb3c048b6"/><file name="Pager.php" hash="323a99730a43b8bce5f887feb3c048b6"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="d7898db41504b194f8db736d24a62078"/></dir><dir name="Model"><dir name="Catalog"><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="0d30a7ef909de52c6aa2e029553674db"/><file name="Category.php" hash="cabe459e05ea13a36fecb30504c553da"/><file name="Price.php" hash="fab3c242664308df823e9908a0c9e246"/></dir></dir><file name="Layer.php" hash="df0e410b742028a1d95ab01d832dff0e"/></dir><dir name="Catalogsearch"><file name="Layer.php" hash="b32c1e8c132ba771bd0e0490ed97c853"/><file name="Layer.php" hash="b32c1e8c132ba771bd0e0490ed97c853"/></dir><file name="Client.php" hash="49e737ea8b3ef93533860bbb220cb454"/><file name=".DS_Store" hash="2df909e9d680df01a6532e4b2c6acf8a"/></dir><dir name="controllers"><file name="IndexController.php" hash="4ce20576ad380f40acf82afbf03f1ad4"/></dir><dir name="etc"><file name="config.xml" hash="559815a9e1d450fe60bbd57015e8d52e"/></dir><file name=".DS_Store" hash="37c804674de1deaad059452b9393cb18"/></dir></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="tagalys"><file name="ss.xml" hash="9d62ce5a9ae20f67f8f6b5baa8c5a2b6"/></dir><file name="tagalys_merchandising.xml" hash="4cf865e3b8e1d9c5649681694359f127"/></dir><dir name="template"><dir name="tagalys"><file name="tagalys_ss.phtml" hash="24c92e0e3e7415dabfb1898105fd0347"/></dir><dir name="tagalys_merchandising_page"><file name="mp_template.phtml" hash="7bc29dd648ccbb3e2614d4379b16ef35"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="Tagalys_core.xml" hash="6385afae91af7bada73792120c378e65"/></dir><dir name="template"><dir name="tagalys"><file name="progressbar.phtml" hash="a54e328030c9f430a6022697f1431388"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="css"><file name="tagalys-core.css" hash="8d9ea54b6b1602cda702b4c55b4943a1"/></dir><dir name="images"><file name="logo-tagalys.png" hash="6b9eeda985cf02bfa23eeddcc64e422b"/></dir></dir></dir></dir></dir></target><target name="mage"><dir><dir name="js"><dir name="tagalys"><file name="tagalys-core.js" hash="09bba056df414ead8c8aea26a1fb8ed8"/></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Tagalys_SearchSuggestions.xml" hash="0b256e54d7f0344f70c4c4efd0473b61"/><file name="Tagalys_Tsearch.xml" hash="8986598b80306698d18983ef9a2926f9"/><file name="Tagalys_MerchandisingPage.xml" hash="bfbba4af51100c948ae2869b53691c2c"/></dir></dir></target></contents>
18
  <compatible/>
19
- <dependencies><required><php><min>5.3.0</min><max>5.6.0</max></php></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>visual-merchandising-product-listing-campaign-creator</name>
4
+ <version>1.1.0</version>
5
  <stability>stable</stability>
6
  <license>Tagalys</license>
7
  <channel>community</channel>
11
  &#xD;
12
  Visual Merchandising allows you to to create, modify or delete product listing pages that can be used from campaigns in SEO, SEM, Social Media and show collections at your online store. Visual Merchandisers do not require any assistance from IT or Tech teams allowing them to focus on managing the platform.</description>
13
  <notes>Any questions or concerns, please email cs@tagalys.com and we will get back to you in less than 24 hours. </notes>
14
+ <authors><author><name>Palani</name><user>Palani</user><email>pc@tagalys.com</email></author></authors>
15
+ <date>2017-04-19</date>
16
+ <time>16:36:28</time>
17
+ <contents><target name="mageetc"><dir><dir name="modules"><file name="Tagalys_Core.xml" hash="7576ed5aa125c580f0b791018f24a0e9"/><file name="Tagalys_SearchSuggestions.xml" hash="dbf6f4ff1859ef2df72560c9282af435"/><file name="Tagalys_Search.xml" hash="820b96f53d2f0e86cb49906a4dda7f41"/><file name="Tagalys_Mpages.xml" hash="6ccb4f45669c98fd746c6abd92ab32ca"/></dir></dir></target><target name="magecommunity"><dir><dir name="Tagalys"><dir name="Core"><dir name="Block"><dir name="Adminhtml"><dir name="Tagalys"><dir name="Edit"><file name="Form.php" hash="31cae34d1e9bd5cb0c881ae5a6fc03c0"/><dir name="Tab"><file name="Apicredentials.php" hash="9005c30790a51ad077cb4be46a07b766"/><file name="Mpages.php" hash="ba526eb77efd4000ae96404bd04aa638"/><file name="Search.php" hash="fef14680d0feb63bb4e928296c3b9032"/><file name="Searchsuggestions.php" hash="5c87af24ad22c663da17e0a1ffe9a655"/><file name="Support.php" hash="c68547cfe57cbccdcbcf7c3eb35ed6b3"/><file name="Sync.php" hash="849f7bb77ff568e7f29cf63d54e7faa8"/><file name="Syncsettings.php" hash="eecdbdee1c7b3a0e7b978f46b6879acc"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name="Tabs.php" hash="20d85d9037ba7a885c33030657900c88"/><file name=".DS_Store" hash="711f187349473a2c6e6d564d4a2faeb9"/></dir><file name="Edit.php" hash="9da04e9a4aec76ce5f5bd88c453390cd"/><file name=".DS_Store" hash="2f95379345a665b8fd261ff7c2f5a7af"/></dir><file name=".DS_Store" hash="96cf5cac0d87be80da73c36e96971923"/></dir><file name=".DS_Store" hash="8c5a4cb1f6f8e10ade87d78ff4d0bfe4"/></dir><dir name="Helper"><file name="Data.php" hash="9b1d43244175ebd78a57e983a831308b"/><file name="Service.php" hash="3eeaa766255db6636e352f7be47876f5"/><file name="SyncFile.php" hash="5b60934e482b5d2332e7eae44c907a72"/></dir><dir name="Model"><file name="Client.php" hash="30e1a58406d31c97bc249acc8ebeee9c"/><file name="Config.php" hash="784ee62e5d029503f915bfdaf9cff003"/><dir name="Mysql4"><dir name="Config"><file name="Collection.php" hash="0967ac6ac1a049d9e09288641d2b4a58"/></dir><file name="Config.php" hash="3562b9ffdf260e34945f9e7830facc1b"/><dir name="Queue"><file name="Collection.php" hash="db01d5b412ca3f8cbc1cbbe8b1ed3d0d"/></dir><file name="Queue.php" hash="50fd814880c6adf02dcb9babe5874811"/><file name=".DS_Store" hash="d3dec31675796dca442be9f6076210df"/></dir><file name="Observer.php" hash="9197f6fb573484db244c141607872b95"/><file name="ProductDetails.php" hash="0e06fa7061b325734554b05f81673201"/><file name="Queue.php" hash="459a74e66f2a7ccd146f480701574464"/><file name=".DS_Store" hash="3db11e65f616ba2524ebf71cf1300fa5"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="TagalysController.php" hash="ae3d1b6cc8d229e98130704b8e010e17"/></dir><file name="SyncfilesController.php" hash="1b8476cbb4d02ec87b7742e4dc9fff4b"/><file name=".DS_Store" hash="db462bf5da1a15c73197a0fefd3f5b51"/></dir><dir name="etc"><file name="config.xml" hash="268ec165bea0aa481d5bb7c773288ae3"/></dir><dir name="sql"><dir name="tagalys_core_setup"><file name="mysql4-install-0.3.0.php" hash="fca9f934db6850d950dfdcd71dba7dcd"/><file name="mysql4-upgrade-0.1.0-0.3.0.php" hash="1eb2da3bdf0753b6f4904f1fd62af32f"/><file name="mysql4-upgrade-0.2.0-0.3.0.php" hash="1eb2da3bdf0753b6f4904f1fd62af32f"/></dir><file name=".DS_Store" hash="d87f0e93ae82377a5ceeda9bd58740e8"/></dir><file name=".DS_Store" hash="d1024e81b6252a3d102a906452f53021"/></dir><dir name="SearchSuggestions"><dir name="Helper"><file name="Data.php" hash="a88adfc9f92bb01b4fdb851ea4f265d3"/></dir><dir name="Model"><file name="Observer.php" hash="73e90449054eac498e3b4dfd55db33f1"/></dir><dir name="etc"><file name="config.xml" hash="1e1ee26e326c03473e5854f5dae06c59"/></dir></dir><dir name="Search"><dir name="controllers"><file name="IndexController.php" hash="baaeb347db3b8d32d09a83d3369388a8"/></dir><dir name="etc"><file name="config.xml" hash="5e5a0a2d2de927241c1e97f435a382f7"/></dir><file name=".DS_Store" hash="822777d708619165d544d3256174adc2"/></dir><dir name="Mpages"><dir name="controllers"><file name="IndexController.php" hash="1d80e73a3e3d2a51cff12ebbe1b1364e"/></dir><dir name="etc"><file name="config.xml" hash="80d1b3c82d4da93c271376881f663db5"/></dir><file name=".DS_Store" hash="822777d708619165d544d3256174adc2"/></dir></dir></dir></target><target name="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="tagalys_core.xml" hash="a0875951441399a46dfb5cb3d346b7d8"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="tagalys_search_suggestions.xml" hash="fc80c019c80782d9b956553c56f236e1"/></dir><dir name="template"><dir name="tagalys_search_suggestions"><file name="search_suggestions.phtml" hash="b55dbbb4f333ca8351772a3c4f2102ea"/></dir><dir name="tagalys_search"><file name="index.phtml" hash="45947e71dd01470b5d1664a7e7eaa5bd"/></dir><dir name="tagalys_mpages"><file name="index.phtml" hash="8ad2aeed80bc1d9b86649ac34e5eaa2f"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="css"><dir name="tagalys"><file name="tagalys-configuration.css" hash="fa3b8f3a4d1bebbbcef261f10e4652b7"/></dir></dir><dir name="images"><dir name="tagalys"><file name="tagalys-logo.png" hash="b26278b173e29b21edc16ddd06ca0192"/></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir><dir name="js"><file name="tagalys-configuration.js" hash="310c28a4b52225884d06a9e596758053"/></dir></dir></target></contents>
18
  <compatible/>
19
+ <dependencies><required><php><min>5.3.0</min><max>7.0.10</max></php></required></dependencies>
20
  </package>
skin/adminhtml/default/default/css/{tagalys-core.css → tagalys/tagalys-configuration.css} RENAMED
@@ -1,36 +1,41 @@
1
- .tagalys-progress-bar{
2
- float:left;width:0;height:100%;font-size:12px;line-height:20px;color:#fff;text-align:center;background-color:#337ab7;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,.15);-webkit-transition:width .6s ease;-o-transition:width .6s ease;transition:width .6s ease
3
- }
4
- .tagalys-progress-bar{
5
- background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);-webkit-background-size:40px 40px;background-size:40px 40px
6
- }
7
- #admin_tagalys_sync_feed_fieldset , th, td {
8
- padding: 3px;
9
- }
10
- .tagalys-btn {
11
- border-width: 1px;
12
- border-style: solid;
13
- border-color: #ed6502 #a04300 #a04300 #ed6502;
14
- padding: 1px 7px 2px 7px;
15
- background: #ffac47 url(../images/btn_bg.gif) repeat-x 0 100%;
16
- color: #fff;
17
- font: bold 12px arial, helvetica, sans-serif;
18
- cursor: pointer;
19
- text-align: center !important;
20
- white-space: nowrap;
21
- }
22
-
23
- .tagalys-btn:disabled {
24
- background: #dddddd;
25
- }
26
-
27
- .tagalys-progress-inline {
28
- display: inline-table;
29
- float: left;
30
- width: 47%;
31
- }
32
-
33
- .tagalys-progress .row {
34
- min-height: 50px;
35
- height: auto;
 
 
 
 
 
36
  }
1
+ .tagalys-progress-bar{
2
+ float:left;width:0;height:100%;font-size:12px;line-height:20px;color:#fff;text-align:center;background-color:#337ab7;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,.15);-webkit-transition:width .6s ease;-o-transition:width .6s ease;transition:width .6s ease
3
+ }
4
+ .tagalys-progress-bar{
5
+ background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);-webkit-background-size:40px 40px;background-size:40px 40px
6
+ }
7
+ #admin_tagalys_sync_feed_fieldset , th, td {
8
+ padding: 3px;
9
+ }
10
+ .tagalys-btn {
11
+ border-width: 1px;
12
+ border-style: solid;
13
+ border-color: #ed6502 #a04300 #a04300 #ed6502;
14
+ padding: 1px 7px 2px 7px;
15
+ background: #ffac47 url(../../images/btn_bg.gif) repeat-x 0 100%;
16
+ color: #fff;
17
+ font: bold 12px arial, helvetica, sans-serif;
18
+ cursor: pointer;
19
+ text-align: center !important;
20
+ white-space: nowrap;
21
+ text-decoration: none;
22
+ }
23
+ .tagalys-btn:hover {
24
+ color: #fff;
25
+ text-decoration: none;
26
+ }
27
+
28
+ .tagalys-btn:disabled {
29
+ background: #dddddd;
30
+ }
31
+
32
+ .tagalys-progress-inline {
33
+ display: inline-table;
34
+ float: left;
35
+ width: 47%;
36
+ }
37
+
38
+ .tagalys-progress .row {
39
+ min-height: 50px;
40
+ height: auto;
41
  }
skin/adminhtml/default/default/images/logo-tagalys.png DELETED
Binary file
skin/adminhtml/default/default/images/tagalys/tagalys-logo.png ADDED
Binary file