Personalized-localized-and-Intelligent-Site-Search - Version 1.0.17

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 Aaditya
Extension Personalized-localized-and-Intelligent-Site-Search
Version 1.0.17
Comparing to
See all releases


Code changes from version 1.0.16 to 1.0.17

Files changed (119) hide show
  1. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit.php +0 -41
  2. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Form.php +0 -20
  3. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Credentials.php +0 -119
  4. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Debug.php +0 -87
  5. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Merchandisingpage.php +0 -96
  6. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Setup.php +0 -169
  7. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Signup.php +0 -79
  8. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Similarproducts.php +0 -83
  9. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Sync.php +0 -145
  10. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Tsearch.php +0 -88
  11. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tab/Tsearchsuggestion.php +0 -121
  12. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Edit/Tabs.php +0 -120
  13. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Notifications.php +0 -17
  14. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/Progress.php +0 -31
  15. app/code/local/Tagalys/Core/Block/Adminhtml/Tagalys/SearchReady.php +0 -29
  16. app/code/local/Tagalys/Core/Helper/Data.php +0 -90
  17. app/code/local/Tagalys/Core/Model/Config.php +0 -10
  18. app/code/local/Tagalys/Core/Model/Mysql4/Config.php +0 -8
  19. app/code/local/Tagalys/Core/Model/Mysql4/Config/Collection.php +0 -8
  20. app/code/local/Tagalys/Core/Model/Observer.php +0 -144
  21. app/code/local/Tagalys/Core/etc/adminhtml.xml +0 -17
  22. app/code/local/Tagalys/Core/etc/config.xml +0 -160
  23. app/code/local/Tagalys/Core/sql/tagalys_core_setup/mysql4-install-0.2.0.php +0 -18
  24. app/code/local/Tagalys/MerchandisingPage/.DS_Store +0 -0
  25. app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Layer/Filter/Attribute.php +0 -49
  26. app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Layer/Filter/Category.php +0 -34
  27. app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Layer/Filter/Price.php +0 -48
  28. app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Layer/State.php +0 -15
  29. app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Layer/View.php +0 -135
  30. app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Product/List.php +0 -48
  31. app/code/local/Tagalys/MerchandisingPage/Block/Catalog/Product/List/Toolbar.php +0 -95
  32. app/code/local/Tagalys/MerchandisingPage/Block/Catalogsearch/Layer.php +0 -32
  33. app/code/local/Tagalys/MerchandisingPage/Block/Catalogsearch/Layer/Filter/Attribute.php +0 -39
  34. app/code/local/Tagalys/MerchandisingPage/Block/Catalogsearch/Layer/View.php +0 -145
  35. app/code/local/Tagalys/MerchandisingPage/Block/Catalogsearch/Result.php +0 -29
  36. app/code/local/Tagalys/MerchandisingPage/Block/Filter.php +0 -21
  37. app/code/local/Tagalys/MerchandisingPage/Block/Page/Html/Pager.php +0 -156
  38. app/code/local/Tagalys/MerchandisingPage/Helper/Data.php +0 -203
  39. app/code/local/Tagalys/MerchandisingPage/Model/.DS_Store +0 -0
  40. app/code/local/Tagalys/MerchandisingPage/Model/Catalog/Layer.php +0 -62
  41. app/code/local/Tagalys/MerchandisingPage/Model/Catalog/Layer/Filter/Attribute.php +0 -166
  42. app/code/local/Tagalys/MerchandisingPage/Model/Catalog/Layer/Filter/Category.php +0 -103
  43. app/code/local/Tagalys/MerchandisingPage/Model/Catalog/Layer/Filter/Price.php +0 -177
  44. app/code/local/Tagalys/MerchandisingPage/Model/Catalogsearch/Layer.php +0 -59
  45. app/code/local/Tagalys/MerchandisingPage/Model/Client.php +0 -146
  46. app/code/local/Tagalys/MerchandisingPage/controllers/IndexController.php +0 -37
  47. app/code/local/Tagalys/MerchandisingPage/etc/config.xml +0 -94
  48. app/code/local/Tagalys/PopularSearches/Model/Observer.php +0 -86
  49. app/code/local/Tagalys/PopularSearches/etc/config.xml +0 -40
  50. app/code/local/Tagalys/SearchSuggestions/Block/Catalog/Layer.php +0 -24
  51. app/code/local/Tagalys/SearchSuggestions/Block/Catalog/Layer/Filter/Attribute.php +0 -17
  52. app/code/local/Tagalys/SearchSuggestions/Block/Catalog/Layer/Filter/Category.php +0 -17
  53. app/code/local/Tagalys/SearchSuggestions/Helper/Data.php +0 -31
  54. app/code/local/Tagalys/SearchSuggestions/Model/Catalog/Layer/Filter/Attribute.php +0 -33
  55. app/code/local/Tagalys/SearchSuggestions/Model/Catalog/Layer/Filter/Category.php +0 -43
  56. app/code/local/Tagalys/SearchSuggestions/controllers/AutoSuggestController.php +0 -33
  57. app/code/local/Tagalys/SearchSuggestions/etc/config.xml +0 -61
  58. app/code/local/Tagalys/Sync/Helper/Data.php +0 -90
  59. app/code/local/Tagalys/Sync/Helper/Inventory.php +0 -35
  60. app/code/local/Tagalys/Sync/Helper/Service.php +0 -311
  61. app/code/local/Tagalys/Sync/Helper/TagalysFeedFactory.php +0 -463
  62. app/code/local/Tagalys/Sync/Model/Adminhtml/System/Config/Backend/Tagalys/Cron.php +0 -39
  63. app/code/local/Tagalys/Sync/Model/Client.php +0 -141
  64. app/code/local/Tagalys/Sync/Model/Dataflow/Convert/Adapter/Io.php +0 -17
  65. app/code/local/Tagalys/Sync/Model/Mysql4/Queue.php +0 -8
  66. app/code/local/Tagalys/Sync/Model/Mysql4/Queue/Collection.php +0 -10
  67. app/code/local/Tagalys/Sync/Model/Observer.php +0 -172
  68. app/code/local/Tagalys/Sync/Model/ProductDetails.php +0 -239
  69. app/code/local/Tagalys/Sync/Model/Queue.php +0 -12
  70. app/code/local/Tagalys/Sync/controllers/Adminhtml/ImportController.php +0 -51
  71. app/code/local/Tagalys/Sync/controllers/Adminhtml/System/Convert/GuiController.php +0 -29
  72. app/code/local/Tagalys/Sync/controllers/Adminhtml/TagalysController.php +0 -110
  73. app/code/local/Tagalys/Sync/controllers/FeedController.php +0 -124
  74. app/code/local/Tagalys/Sync/etc/config.xml +0 -206
  75. app/code/local/Tagalys/Sync/etc/wsdl.xml +0 -53
  76. app/code/local/Tagalys/Sync/sql/sync_setup/mysql4-install-0.1.0.php +0 -18
  77. app/code/local/Tagalys/Sync/sql/sync_setup/mysql4-install-0.2.0.php +0 -18
  78. app/code/local/Tagalys/Sync/sql/sync_setup/mysql4-upgrade-0.1.0-0.2.0.php +0 -15
  79. app/code/local/Tagalys/Tsearch/.DS_Store +0 -0
  80. app/code/local/Tagalys/Tsearch/Block/.DS_Store +0 -0
  81. app/code/local/Tagalys/Tsearch/Block/Catalog/Layer/Filter/Attribute.php +0 -43
  82. app/code/local/Tagalys/Tsearch/Block/Catalog/Layer/Filter/Category.php +0 -36
  83. app/code/local/Tagalys/Tsearch/Block/Catalog/Layer/Filter/Price.php +0 -66
  84. app/code/local/Tagalys/Tsearch/Block/Catalog/Layer/State.php +0 -15
  85. app/code/local/Tagalys/Tsearch/Block/Catalog/Layer/View.php +0 -119
  86. app/code/local/Tagalys/Tsearch/Block/Catalog/Product/.DS_Store +0 -0
  87. app/code/local/Tagalys/Tsearch/Block/Catalog/Product/List.php +0 -42
  88. app/code/local/Tagalys/Tsearch/Block/Catalog/Product/List/Toolbar.php +0 -92
  89. app/code/local/Tagalys/Tsearch/Block/Catalogsearch/Layer.php +0 -32
  90. app/code/local/Tagalys/Tsearch/Block/Catalogsearch/Layer/Filter/Attribute.php +0 -39
  91. app/code/local/Tagalys/Tsearch/Block/Catalogsearch/Layer/View.php +0 -145
  92. app/code/local/Tagalys/Tsearch/Block/Catalogsearch/Result.php +0 -29
  93. app/code/local/Tagalys/Tsearch/Block/Page/.DS_Store +0 -0
  94. app/code/local/Tagalys/Tsearch/Block/Page/Html/Pager.php +0 -155
  95. app/code/local/Tagalys/Tsearch/Helper/Data.php +0 -120
  96. app/code/local/Tagalys/Tsearch/Model/.DS_Store +0 -0
  97. app/code/local/Tagalys/Tsearch/Model/Catalog/Layer.php +0 -37
  98. app/code/local/Tagalys/Tsearch/Model/Catalog/Layer/Filter/Attribute.php +0 -157
  99. app/code/local/Tagalys/Tsearch/Model/Catalog/Layer/Filter/Category.php +0 -100
  100. app/code/local/Tagalys/Tsearch/Model/Catalog/Layer/Filter/Price.php +0 -175
  101. app/code/local/Tagalys/Tsearch/Model/Catalog/Product/List.php +0 -8
  102. app/code/local/Tagalys/Tsearch/Model/Catalogsearch/Layer.php +0 -59
  103. app/code/local/Tagalys/Tsearch/Model/Client/Connector.php +0 -251
  104. app/code/local/Tagalys/Tsearch/Model/Engine.php +0 -96
  105. app/code/local/Tagalys/Tsearch/Model/Observer.php +0 -10
  106. app/code/local/Tagalys/Tsearch/Model/Resource/Catalog/Product/Collection.php +0 -368
  107. app/code/local/Tagalys/Tsearch/Model/Resource/Catalog/Product/testCollection.php +0 -368
  108. app/code/local/Tagalys/Tsearch/etc/config.xml +0 -98
  109. app/design/adminhtml/default/default/layout/Tagalys_core.xml +22 -0
  110. app/design/adminhtml/default/default/template/tagalys/progressbar.phtml +152 -0
  111. app/design/frontend/base/default/layout/tagalys/ss.xml +7 -0
  112. app/design/frontend/base/default/layout/tagalys_merchandising.xml +0 -79
  113. app/design/frontend/base/default/template/tagalys/tagalys_ss.phtml +128 -0
  114. app/design/frontend/base/default/template/tagalys_merchandising_page/mp_template.phtml +0 -20
  115. app/etc/modules/Tagalys_MerchandisingPage.xml +0 -14
  116. app/etc/modules/Tagalys_SearchSuggestions.xml +0 -26
  117. app/etc/modules/Tagalys_Tsearch.xml +0 -10
  118. package.xml +3 -3
  119. skin/adminhtml/default/default/css/tagalys-core.css +0 -36
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/Mysql4/Config/Collection.php DELETED
@@ -1,8 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
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/.DS_Store DELETED
Binary file
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/.DS_Store DELETED
Binary file
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>Search</installed_plugin>
12
- <plugin_to_be_activated>tsearch,tsearchsuggestion</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/.DS_Store DELETED
Binary file
app/code/local/Tagalys/Tsearch/Block/.DS_Store DELETED
Binary file
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/.DS_Store DELETED
Binary file
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 ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/template/tagalys/progressbar.phtml ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ });
147
+
148
+ //Refresh auto_load() function after 10000 milliseconds
149
+ f = setInterval(fauto_load,5000);
150
+ s = setInterval(sauto_load,5000);
151
+ btn = setInterval(button_auto_load, 1000);
152
+ </script>
app/design/frontend/base/default/layout/tagalys/ss.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
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/template/tagalys/tagalys_ss.phtml ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/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_SearchSuggestions.xml DELETED
@@ -1,26 +0,0 @@
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
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>
 
 
 
 
 
 
 
 
 
 
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Personalized-localized-and-Intelligent-Site-Search</name>
4
- <version>1.0.16</version>
5
  <stability>stable</stability>
6
  <license>Tagalys</license>
7
  <channel>community</channel>
@@ -11,8 +11,8 @@
11
  <notes>Any questions or concerns, please email cs@tagalys.com and we will get back to you in less than 24 hours. </notes>
12
  <authors><author><name>Aaditya</name><user>Aaditya</user><email>antony@tagalys.com</email></author></authors>
13
  <date>2017-02-23</date>
14
- <time>12:29:31</time>
15
- <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="c3aab7b4bc00cb917a6fb4803087ec36"/><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"/><file name="Pager.php" hash="0656951942409b6eb2517ddb2d45b612"/></dir><file name=".DS_Store" hash="1e3895ec3ef0a8efa77b64def497589b"/><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"/></dir><file name="View.php" hash="f978e5be20a3f12db9abc1f0c9872ba5"/></dir><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"/></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"/></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=""/></dir><file name="tagalys_merchandising.xml" hash="4cf865e3b8e1d9c5649681694359f127"/></dir><dir name="template"><dir name="tagalys"><file name="tagalys_ss.phtml" hash=""/></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=""/></dir><dir name="template"><dir name="tagalys"><file name="progressbar.phtml" hash=""/></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=""/></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>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.0</min><max>7.0.10</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Personalized-localized-and-Intelligent-Site-Search</name>
4
+ <version>1.0.17</version>
5
  <stability>stable</stability>
6
  <license>Tagalys</license>
7
  <channel>community</channel>
11
  <notes>Any questions or concerns, please email cs@tagalys.com and we will get back to you in less than 24 hours. </notes>
12
  <authors><author><name>Aaditya</name><user>Aaditya</user><email>antony@tagalys.com</email></author></authors>
13
  <date>2017-02-23</date>
14
+ <time>12:57:14</time>
15
+ <contents><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=""/></dir><dir name="template"><dir name="tagalys"><file name="tagalys_ss.phtml" hash="24c92e0e3e7415dabfb1898105fd0347"/></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="fc4a358aba96e1a677c36fda7c831705"/></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=""/></dir><dir name="images"><file name="logo-tagalys.png" hash="d41d8cd98f00b204e9800998ecf8427e"/></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=""/><file name="Tagalys_Tsearch.xml" hash=""/><file name="Tagalys_MerchandisingPage.xml" hash=""/></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.0</min><max>7.0.10</max></php></required></dependencies>
18
  </package>
skin/adminhtml/default/default/css/tagalys-core.css DELETED
@@ -1,36 +0,0 @@
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
- }