Version Notes
* localhost missing ssl fix
* performance optimizations
Download this release
Release Info
Developer | Adar |
Extension | autocompleteplus_autosuggest |
Version | 3.0.0.11 |
Comparing to | |
See all releases |
Code changes from version 3.0.0.10 to 3.0.0.11
- app/code/local/Autocompleteplus/Autosuggest/Adminhtml/Model/Attributes.php +55 -55
- app/code/local/Autocompleteplus/Autosuggest/Adminhtml/Model/Button.php +78 -78
- app/code/local/Autocompleteplus/Autosuggest/Block/Adminhtml/Button.php +80 -80
- app/code/local/Autocompleteplus/Autosuggest/Block/Adminhtml/Process.php +31 -31
- app/code/local/Autocompleteplus/Autosuggest/Block/Adminhtml/Sync.php +78 -78
- app/code/local/Autocompleteplus/Autosuggest/Block/Autocomplete.php +57 -57
- app/code/local/Autocompleteplus/Autosuggest/Block/Autocorrection.php +28 -28
- app/code/local/Autocompleteplus/Autosuggest/Block/Inject.php +169 -169
- app/code/local/Autocompleteplus/Autosuggest/Block/Notifications.php +44 -44
- app/code/local/Autocompleteplus/Autosuggest/Controller/Abstract.php +15 -15
- app/code/local/Autocompleteplus/Autosuggest/Helper/Data.php +882 -877
- app/code/local/Autocompleteplus/Autosuggest/Model/Adminhtml/Attributes.php +58 -58
- app/code/local/Autocompleteplus/Autosuggest/Model/Api.php +50 -50
- app/code/local/Autocompleteplus/Autosuggest/Model/Api/V2.php +5 -5
- app/code/local/Autocompleteplus/Autosuggest/Model/Batches.php +9 -9
- app/code/local/Autocompleteplus/Autosuggest/Model/Catalog.php +374 -337
- app/code/local/Autocompleteplus/Autosuggest/Model/Catalogreport.php +113 -113
- app/code/local/Autocompleteplus/Autosuggest/Model/Checksum.php +9 -9
- app/code/local/Autocompleteplus/Autosuggest/Model/Config.php +389 -371
- app/code/local/Autocompleteplus/Autosuggest/Model/Layer.php +130 -130
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Batches.php +8 -8
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Batches/Collection.php +8 -8
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Checksum.php +8 -8
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Checksum/Collection.php +8 -8
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Fulltext/Collection.php +8 -8
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Notifications.php +8 -8
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Notifications/Collection.php +8 -8
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Pusher.php +8 -8
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Pusher/Collection.php +8 -8
- app/code/local/Autocompleteplus/Autosuggest/Model/Notifications.php +22 -22
- app/code/local/Autocompleteplus/Autosuggest/Model/Observer.php +549 -549
- app/code/local/Autocompleteplus/Autosuggest/Model/Pusher.php +9 -9
- app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Abstract.php +83 -83
- app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Batches.php +26 -26
- app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Catalog/Product.php +610 -573
- app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Batches.php +12 -12
- app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Batches/Collection.php +30 -30
- app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Checksum.php +12 -12
- app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Checksum/Collection.php +12 -12
- app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Fulltext/Collection.php +225 -225
- app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Notifications.php +40 -40
- app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Notifications/Collection.php +44 -44
- app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Pusher.php +16 -16
- app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Pusher/Collection.php +9 -9
- app/code/local/Autocompleteplus/Autosuggest/Model/Service.php +55 -55
- app/code/local/Autocompleteplus/Autosuggest/controllers/Adminhtml/Autocompleteplus/PushController.php +18 -18
- app/code/local/Autocompleteplus/Autosuggest/controllers/Adminhtml/Autocompleteplus/RedirectController.php +39 -39
- app/code/local/Autocompleteplus/Autosuggest/controllers/CatalogSearch/ResultController.php +21 -21
- app/code/local/Autocompleteplus/Autosuggest/controllers/CatalogsearchController.php +87 -87
- app/code/local/Autocompleteplus/Autosuggest/controllers/CategoriesController.php +116 -116
- app/code/local/Autocompleteplus/Autosuggest/controllers/LayeredController.php +129 -129
- app/code/local/Autocompleteplus/Autosuggest/controllers/ProductsController.php +560 -559
- app/code/local/Autocompleteplus/Autosuggest/controllers/ProductsbyidController.php +66 -66
- app/code/local/Autocompleteplus/Autosuggest/controllers/ResultController.php +7 -7
- app/code/local/Autocompleteplus/Autosuggest/controllers/SearchesController.php +109 -109
- app/code/local/Autocompleteplus/Autosuggest/data/autosuggest_setup/data-install-3.0.0.5.php +7 -7
- app/code/local/Autocompleteplus/Autosuggest/data/autosuggest_setup/data-upgrade-3.0.0.9-3.0.0.10.php +2 -2
- app/code/local/Autocompleteplus/Autosuggest/etc/adminhtml.xml +28 -28
- app/code/local/Autocompleteplus/Autosuggest/etc/cache.xml +10 -10
- app/code/local/Autocompleteplus/Autosuggest/etc/config.xml +213 -213
- app/code/local/Autocompleteplus/Autosuggest/etc/system.xml +73 -73
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-install-2.0.1.1.php +25 -25
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.1.3-2.0.2.2.php +32 -32
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.2.5-2.0.2.6.php +37 -37
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.4.6-2.0.4.7.php +41 -41
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.5.4-2.0.5.5.php +107 -107
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.7.0-2.0.7.1.php +8 -8
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.7.2-2.0.7.3.php +105 -105
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.8.8-3.0.0.0.php +37 -37
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-3.0.0.4-3.0.0.5.php +5 -5
- app/design/adminhtml/default/default/layout/autocompleteplus.xml +37 -37
- app/design/adminhtml/default/default/template/autocompleteplus/notifications.phtml +13 -13
- app/design/adminhtml/default/default/template/autocompleteplus/process.phtml +136 -136
- app/design/adminhtml/default/default/template/autocompleteplus/system/config/button.phtml +19 -19
- app/design/adminhtml/default/default/template/autocompleteplus/system/config/sync.phtml +20 -20
- app/design/frontend/base/default/layout/autocompleteplus.xml +39 -39
- app/design/frontend/base/default/template/autocompleteplus/catalog/layer/view.phtml +3 -3
- app/design/frontend/base/default/template/autocompleteplus/catalog/product/list.phtml +47 -47
- app/design/frontend/base/default/template/autocompleteplus/inject.phtml +2 -2
- app/etc/modules/Autocompleteplus_Autosuggest.xml +8 -8
- lib/Autocompleteplus/Autosuggest/Xml/Generator.php +86 -86
- lib/Autocompleteplus/Autosuggest/Xml/GeneratorInterface.php +11 -11
- package.xml +6 -8
app/code/local/Autocompleteplus/Autosuggest/Adminhtml/Model/Attributes.php
CHANGED
@@ -1,55 +1,55 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* InstantSearchPlus (Autosuggest).
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is available through the world-wide-web at this URL:
|
9 |
-
* http://opensource.org/licenses/osl-3.0.php
|
10 |
-
*
|
11 |
-
* @category Mage
|
12 |
-
*
|
13 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Used in creating options for Yes|No config value selection.
|
19 |
-
*/
|
20 |
-
class Autocompleteplus_Autosuggest_Adminhtml_Model_Attributes
|
21 |
-
{
|
22 |
-
public $fields = array();
|
23 |
-
/**
|
24 |
-
* Options getter.
|
25 |
-
*
|
26 |
-
* @return array
|
27 |
-
*/
|
28 |
-
public function toOptionArray()
|
29 |
-
{
|
30 |
-
$this->fields = $this->getOptions();
|
31 |
-
|
32 |
-
return $this->fields;
|
33 |
-
}
|
34 |
-
|
35 |
-
public function getOptions()
|
36 |
-
{
|
37 |
-
$entityType = Mage::getModel('catalog/product')->getResource()->getEntityType();
|
38 |
-
$entityTypeId = $entityType->getId();
|
39 |
-
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
|
40 |
-
->setEntityTypeFilter($entityTypeId)
|
41 |
-
->getData();
|
42 |
-
|
43 |
-
$result = array();
|
44 |
-
$result[] = array('value' => '', 'label' => 'Choose an attribute');
|
45 |
-
foreach ($attributeInfo as $_key => $_value) {
|
46 |
-
if (isset($_value['frontend_label']) && ($_value['frontend_label'] != '')) {
|
47 |
-
$result[] = array('value' => $_value['attribute_code'], 'label' => $_value['frontend_label']);
|
48 |
-
} else {
|
49 |
-
$result[] = array('value' => $_value['attribute_code'], 'label' => $_value['attribute_code']);
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
return $result;
|
54 |
-
}
|
55 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* InstantSearchPlus (Autosuggest).
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Mage
|
12 |
+
*
|
13 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Used in creating options for Yes|No config value selection.
|
19 |
+
*/
|
20 |
+
class Autocompleteplus_Autosuggest_Adminhtml_Model_Attributes
|
21 |
+
{
|
22 |
+
public $fields = array();
|
23 |
+
/**
|
24 |
+
* Options getter.
|
25 |
+
*
|
26 |
+
* @return array
|
27 |
+
*/
|
28 |
+
public function toOptionArray()
|
29 |
+
{
|
30 |
+
$this->fields = $this->getOptions();
|
31 |
+
|
32 |
+
return $this->fields;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getOptions()
|
36 |
+
{
|
37 |
+
$entityType = Mage::getModel('catalog/product')->getResource()->getEntityType();
|
38 |
+
$entityTypeId = $entityType->getId();
|
39 |
+
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
|
40 |
+
->setEntityTypeFilter($entityTypeId)
|
41 |
+
->getData();
|
42 |
+
|
43 |
+
$result = array();
|
44 |
+
$result[] = array('value' => '', 'label' => 'Choose an attribute');
|
45 |
+
foreach ($attributeInfo as $_key => $_value) {
|
46 |
+
if (isset($_value['frontend_label']) && ($_value['frontend_label'] != '')) {
|
47 |
+
$result[] = array('value' => $_value['attribute_code'], 'label' => $_value['frontend_label']);
|
48 |
+
} else {
|
49 |
+
$result[] = array('value' => $_value['attribute_code'], 'label' => $_value['attribute_code']);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
return $result;
|
54 |
+
}
|
55 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Adminhtml/Model/Button.php
CHANGED
@@ -1,78 +1,78 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* InstantSearchPlus (Autosuggest).
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is available through the world-wide-web at this URL:
|
9 |
-
* http://opensource.org/licenses/osl-3.0.php
|
10 |
-
*
|
11 |
-
* @category Mage
|
12 |
-
*
|
13 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Used in creating options for Yes|No config value selection.
|
19 |
-
*/
|
20 |
-
class Autocompleteplus_Autosuggest_Adminhtml_Model_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
|
21 |
-
{
|
22 |
-
/*
|
23 |
-
* Set template
|
24 |
-
*/
|
25 |
-
protected function _construct()
|
26 |
-
{
|
27 |
-
parent::_construct();
|
28 |
-
$this->setTemplate('autocompleteplus/system/config/button.phtml');
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Return element html.
|
33 |
-
*
|
34 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
35 |
-
*
|
36 |
-
* @return string
|
37 |
-
*/
|
38 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
39 |
-
{
|
40 |
-
$this->setElement($element);
|
41 |
-
|
42 |
-
return $this->_toHtml();
|
43 |
-
}
|
44 |
-
|
45 |
-
public function getUUID()
|
46 |
-
{
|
47 |
-
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
48 |
-
|
49 |
-
return $config->getUUID();
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Return ajax url for button.
|
54 |
-
*
|
55 |
-
* @return string
|
56 |
-
*/
|
57 |
-
public function getAjaxCheckUrl()
|
58 |
-
{
|
59 |
-
return Mage::helper('adminhtml')->getUrl('autocompleteplus/products/updateemail');
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Generate button html.
|
64 |
-
*
|
65 |
-
* @return string
|
66 |
-
*/
|
67 |
-
public function getButtonHtml()
|
68 |
-
{
|
69 |
-
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
70 |
-
->setData(array(
|
71 |
-
'id' => 'autocompleteplus_button',
|
72 |
-
'label' => $this->helper('adminhtml')->__('Update'),
|
73 |
-
'onclick' => 'javascript:updateautocomplete(); return false;',
|
74 |
-
));
|
75 |
-
|
76 |
-
return $button->toHtml();
|
77 |
-
}
|
78 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* InstantSearchPlus (Autosuggest).
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Mage
|
12 |
+
*
|
13 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Used in creating options for Yes|No config value selection.
|
19 |
+
*/
|
20 |
+
class Autocompleteplus_Autosuggest_Adminhtml_Model_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
|
21 |
+
{
|
22 |
+
/*
|
23 |
+
* Set template
|
24 |
+
*/
|
25 |
+
protected function _construct()
|
26 |
+
{
|
27 |
+
parent::_construct();
|
28 |
+
$this->setTemplate('autocompleteplus/system/config/button.phtml');
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Return element html.
|
33 |
+
*
|
34 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
35 |
+
*
|
36 |
+
* @return string
|
37 |
+
*/
|
38 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
39 |
+
{
|
40 |
+
$this->setElement($element);
|
41 |
+
|
42 |
+
return $this->_toHtml();
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getUUID()
|
46 |
+
{
|
47 |
+
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
48 |
+
|
49 |
+
return $config->getUUID();
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Return ajax url for button.
|
54 |
+
*
|
55 |
+
* @return string
|
56 |
+
*/
|
57 |
+
public function getAjaxCheckUrl()
|
58 |
+
{
|
59 |
+
return Mage::helper('adminhtml')->getUrl('autocompleteplus/products/updateemail');
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Generate button html.
|
64 |
+
*
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
public function getButtonHtml()
|
68 |
+
{
|
69 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
70 |
+
->setData(array(
|
71 |
+
'id' => 'autocompleteplus_button',
|
72 |
+
'label' => $this->helper('adminhtml')->__('Update'),
|
73 |
+
'onclick' => 'javascript:updateautocomplete(); return false;',
|
74 |
+
));
|
75 |
+
|
76 |
+
return $button->toHtml();
|
77 |
+
}
|
78 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Block/Adminhtml/Button.php
CHANGED
@@ -1,80 +1,80 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* InstantSearchPlus (Autosuggest).
|
5 |
-
*
|
6 |
-
* NOTICE OF LICENSE
|
7 |
-
*
|
8 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
-
* that is available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
*
|
12 |
-
* @category Mage
|
13 |
-
*
|
14 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
15 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
-
*/
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Used in creating options for Yes|No config value selection.
|
20 |
-
*/
|
21 |
-
class Autocompleteplus_Autosuggest_Block_Adminhtml_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
* Set Template.
|
25 |
-
*/
|
26 |
-
protected function _construct()
|
27 |
-
{
|
28 |
-
parent::_construct();
|
29 |
-
$this->setTemplate('autocompleteplus/system/config/button.phtml');
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Return element html.
|
34 |
-
*
|
35 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
36 |
-
*
|
37 |
-
* @return string
|
38 |
-
*/
|
39 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
40 |
-
{
|
41 |
-
$this->setElement($element);
|
42 |
-
|
43 |
-
return $this->_toHtml();
|
44 |
-
}
|
45 |
-
|
46 |
-
public function getUUID()
|
47 |
-
{
|
48 |
-
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
49 |
-
|
50 |
-
return $config->getUUID();
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Return ajax url for button.
|
55 |
-
*
|
56 |
-
* @return string
|
57 |
-
*/
|
58 |
-
public function getAjaxCheckUrl()
|
59 |
-
{
|
60 |
-
return Mage::helper('adminhtml')->getUrl('autocompleteplus/products/updateemail');
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Generate button html.
|
65 |
-
*
|
66 |
-
* @return string
|
67 |
-
*/
|
68 |
-
public function getButtonHtml()
|
69 |
-
{
|
70 |
-
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
71 |
-
|
72 |
-
->setData(array(
|
73 |
-
'id' => 'autocompleteplus_button',
|
74 |
-
'label' => $this->helper('adminhtml')->__('Update'),
|
75 |
-
'onclick' => 'javascript:updateautocomplete(); return false;',
|
76 |
-
));
|
77 |
-
|
78 |
-
return $button->toHtml();
|
79 |
-
}
|
80 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* InstantSearchPlus (Autosuggest).
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* @category Mage
|
13 |
+
*
|
14 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Used in creating options for Yes|No config value selection.
|
20 |
+
*/
|
21 |
+
class Autocompleteplus_Autosuggest_Block_Adminhtml_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* Set Template.
|
25 |
+
*/
|
26 |
+
protected function _construct()
|
27 |
+
{
|
28 |
+
parent::_construct();
|
29 |
+
$this->setTemplate('autocompleteplus/system/config/button.phtml');
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Return element html.
|
34 |
+
*
|
35 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
36 |
+
*
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
40 |
+
{
|
41 |
+
$this->setElement($element);
|
42 |
+
|
43 |
+
return $this->_toHtml();
|
44 |
+
}
|
45 |
+
|
46 |
+
public function getUUID()
|
47 |
+
{
|
48 |
+
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
49 |
+
|
50 |
+
return $config->getUUID();
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Return ajax url for button.
|
55 |
+
*
|
56 |
+
* @return string
|
57 |
+
*/
|
58 |
+
public function getAjaxCheckUrl()
|
59 |
+
{
|
60 |
+
return Mage::helper('adminhtml')->getUrl('autocompleteplus/products/updateemail');
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Generate button html.
|
65 |
+
*
|
66 |
+
* @return string
|
67 |
+
*/
|
68 |
+
public function getButtonHtml()
|
69 |
+
{
|
70 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
71 |
+
|
72 |
+
->setData(array(
|
73 |
+
'id' => 'autocompleteplus_button',
|
74 |
+
'label' => $this->helper('adminhtml')->__('Update'),
|
75 |
+
'onclick' => 'javascript:updateautocomplete(); return false;',
|
76 |
+
));
|
77 |
+
|
78 |
+
return $button->toHtml();
|
79 |
+
}
|
80 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Block/Adminhtml/Process.php
CHANGED
@@ -1,31 +1,31 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Block_Adminhtml_Process extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
-
{
|
5 |
-
protected function _construct()
|
6 |
-
{
|
7 |
-
$configTemplate = <<<TMPL
|
8 |
-
<li style="#{style}" id="#{id}">
|
9 |
-
<img id="#{id}_img" src="#{image}" class="v-middle" style="margin-right:5px"/>
|
10 |
-
<span id="#{id}_status" class="text">#{text}</span>
|
11 |
-
</li>
|
12 |
-
TMPL;
|
13 |
-
|
14 |
-
$this->_pushConfig = array(
|
15 |
-
'styles' => array(
|
16 |
-
'error' => array(
|
17 |
-
'icon' => $this->getSkinUrl('images/error_msg_icon.gif'),
|
18 |
-
'bg' => '#FDD',
|
19 |
-
),
|
20 |
-
'message' => array(
|
21 |
-
'icon' => $this->getSkinUrl('images/fam_bullet_success.gif'),
|
22 |
-
'bg' => '#DDF',
|
23 |
-
),
|
24 |
-
),
|
25 |
-
'loader' => $this->getSkinUrl('images/ajax-loader.gif'),
|
26 |
-
'template' => $configTemplate,
|
27 |
-
'text' => $this->__('Processed <strong>%s%% %s/%d</strong> records', '#{percent}', '#{updated}', $this->getBatchItemsCount()),
|
28 |
-
'successText' => $this->__('Imported <strong>%s</strong> records', '#{updated}'),
|
29 |
-
);
|
30 |
-
}
|
31 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Block_Adminhtml_Process extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
+
{
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
$configTemplate = <<<TMPL
|
8 |
+
<li style="#{style}" id="#{id}">
|
9 |
+
<img id="#{id}_img" src="#{image}" class="v-middle" style="margin-right:5px"/>
|
10 |
+
<span id="#{id}_status" class="text">#{text}</span>
|
11 |
+
</li>
|
12 |
+
TMPL;
|
13 |
+
|
14 |
+
$this->_pushConfig = array(
|
15 |
+
'styles' => array(
|
16 |
+
'error' => array(
|
17 |
+
'icon' => $this->getSkinUrl('images/error_msg_icon.gif'),
|
18 |
+
'bg' => '#FDD',
|
19 |
+
),
|
20 |
+
'message' => array(
|
21 |
+
'icon' => $this->getSkinUrl('images/fam_bullet_success.gif'),
|
22 |
+
'bg' => '#DDF',
|
23 |
+
),
|
24 |
+
),
|
25 |
+
'loader' => $this->getSkinUrl('images/ajax-loader.gif'),
|
26 |
+
'template' => $configTemplate,
|
27 |
+
'text' => $this->__('Processed <strong>%s%% %s/%d</strong> records', '#{percent}', '#{updated}', $this->getBatchItemsCount()),
|
28 |
+
'successText' => $this->__('Imported <strong>%s</strong> records', '#{updated}'),
|
29 |
+
);
|
30 |
+
}
|
31 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Block/Adminhtml/Sync.php
CHANGED
@@ -1,78 +1,78 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Yes/no options for sync.
|
5 |
-
*/
|
6 |
-
class Autocompleteplus_Autosuggest_Block_Adminhtml_Sync extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
-
{
|
8 |
-
protected function _construct()
|
9 |
-
{
|
10 |
-
parent::_construct();
|
11 |
-
$this->setTemplate('autocompleteplus/system/config/sync.phtml');
|
12 |
-
}
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Return element html.
|
16 |
-
*
|
17 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
18 |
-
*
|
19 |
-
* @return string
|
20 |
-
*/
|
21 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
22 |
-
{
|
23 |
-
$this->setElement($element);
|
24 |
-
|
25 |
-
return $this->_toHtml();
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Return UUID.
|
30 |
-
*
|
31 |
-
* @return string
|
32 |
-
*/
|
33 |
-
public function getUUID()
|
34 |
-
{
|
35 |
-
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
36 |
-
|
37 |
-
return $config->getUUID();
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Reachable or not.
|
42 |
-
*
|
43 |
-
* @return bool
|
44 |
-
*/
|
45 |
-
public function getIsReachable()
|
46 |
-
{
|
47 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
48 |
-
|
49 |
-
return $helper->getIsReachable();
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Return ajax url for button.
|
54 |
-
*
|
55 |
-
* @return string
|
56 |
-
*/
|
57 |
-
public function getSyncUrl()
|
58 |
-
{
|
59 |
-
return Mage::helper('adminhtml')->getUrl('adminhtml/autocompleteplus_push/startpush');
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Generate button html.
|
64 |
-
*
|
65 |
-
* @return string
|
66 |
-
*/
|
67 |
-
public function getButtonHtml()
|
68 |
-
{
|
69 |
-
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
70 |
-
->setData(array(
|
71 |
-
'id' => 'autocompleteplus_sync',
|
72 |
-
'label' => $this->helper('adminhtml')->__('Sync'),
|
73 |
-
'onclick' => 'javascript:syncautocomplete(); return false;',
|
74 |
-
));
|
75 |
-
|
76 |
-
return $button->toHtml();
|
77 |
-
}
|
78 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Yes/no options for sync.
|
5 |
+
*/
|
6 |
+
class Autocompleteplus_Autosuggest_Block_Adminhtml_Sync extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
+
{
|
8 |
+
protected function _construct()
|
9 |
+
{
|
10 |
+
parent::_construct();
|
11 |
+
$this->setTemplate('autocompleteplus/system/config/sync.phtml');
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Return element html.
|
16 |
+
*
|
17 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
18 |
+
*
|
19 |
+
* @return string
|
20 |
+
*/
|
21 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
22 |
+
{
|
23 |
+
$this->setElement($element);
|
24 |
+
|
25 |
+
return $this->_toHtml();
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Return UUID.
|
30 |
+
*
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
public function getUUID()
|
34 |
+
{
|
35 |
+
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
36 |
+
|
37 |
+
return $config->getUUID();
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Reachable or not.
|
42 |
+
*
|
43 |
+
* @return bool
|
44 |
+
*/
|
45 |
+
public function getIsReachable()
|
46 |
+
{
|
47 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
48 |
+
|
49 |
+
return $helper->getIsReachable();
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Return ajax url for button.
|
54 |
+
*
|
55 |
+
* @return string
|
56 |
+
*/
|
57 |
+
public function getSyncUrl()
|
58 |
+
{
|
59 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/autocompleteplus_push/startpush');
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Generate button html.
|
64 |
+
*
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
public function getButtonHtml()
|
68 |
+
{
|
69 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
70 |
+
->setData(array(
|
71 |
+
'id' => 'autocompleteplus_sync',
|
72 |
+
'label' => $this->helper('adminhtml')->__('Sync'),
|
73 |
+
'onclick' => 'javascript:syncautocomplete(); return false;',
|
74 |
+
));
|
75 |
+
|
76 |
+
return $button->toHtml();
|
77 |
+
}
|
78 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Block/Autocomplete.php
CHANGED
@@ -1,57 +1,57 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Block_Autocomplete extends Mage_Core_Block_Abstract
|
4 |
-
{
|
5 |
-
protected function _toHtml()
|
6 |
-
{
|
7 |
-
$is_full_text_wrong_flow = false;
|
8 |
-
try {
|
9 |
-
$fulltext_enable = Mage::getSingleton('core/session')->getIsFullTextEnable();
|
10 |
-
if (!$fulltext_enable) {
|
11 |
-
return '';
|
12 |
-
}
|
13 |
-
// checking if the searched query from addSearchFilter() is the same to the current query
|
14 |
-
$current_search_term = urlencode(self::getRequest()->getParam('q'));
|
15 |
-
$searched_term = Mage::getSingleton('core/session')->getIspUrlEncodeQuery();
|
16 |
-
if ($current_search_term != $searched_term) {
|
17 |
-
$is_full_text_wrong_flow = true;
|
18 |
-
}
|
19 |
-
} catch (Exception $e) {
|
20 |
-
Mage::log('autocomplete.php _toHtml() Exception => fulltext_enable and query calculations'.$e->getMessage(), null, 'autocompleteplus.log');
|
21 |
-
|
22 |
-
return '';
|
23 |
-
}
|
24 |
-
|
25 |
-
$params = array();
|
26 |
-
if (!$is_full_text_wrong_flow) {
|
27 |
-
try {
|
28 |
-
$alternatives = Mage::getSingleton('core/session')->getIspSearchAlternatives();
|
29 |
-
$results_for = Mage::getSingleton('core/session')->getIspSearchResultsFor();
|
30 |
-
} catch (Exception $e) {
|
31 |
-
Mage::log('autocomplete.php _toHtml() Exception => results_for and did you mean calculations'.$e->getMessage(), null, 'autocompleteplus.log');
|
32 |
-
|
33 |
-
return '';
|
34 |
-
}
|
35 |
-
|
36 |
-
if ($alternatives) {
|
37 |
-
$params['alternatives'] = json_encode($alternatives);
|
38 |
-
}
|
39 |
-
if ($results_for) {
|
40 |
-
$params['results_for'] = $results_for;
|
41 |
-
}
|
42 |
-
} else {
|
43 |
-
$params['wrong_flow'] = 1;
|
44 |
-
}
|
45 |
-
|
46 |
-
$magento_version = Mage::getVersion();
|
47 |
-
$extension_version = (string) Mage::getConfig()->getNode()->modules->Autocompleteplus_Autosuggest->version;
|
48 |
-
$versions = ($params == '') ? 'mage_v='.$magento_version.'&ext_v='.$extension_version
|
49 |
-
: '&mage_v='.$magento_version.'&ext_v='.$extension_version;
|
50 |
-
|
51 |
-
Mage::getSingleton('core/session')->unsIsFullTextEnable();
|
52 |
-
Mage::getSingleton('core/session')->unsIspSearchAlternatives();
|
53 |
-
Mage::getSingleton('core/session')->unsIspSearchResultsFor();
|
54 |
-
|
55 |
-
return '<script data-cfasync="false" async type="text/javascript" src="https://acp-magento.appspot.com/js/magento_full_text.js?'.http_build_query($params).$versions.'"></script>';
|
56 |
-
}
|
57 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Block_Autocomplete extends Mage_Core_Block_Abstract
|
4 |
+
{
|
5 |
+
protected function _toHtml()
|
6 |
+
{
|
7 |
+
$is_full_text_wrong_flow = false;
|
8 |
+
try {
|
9 |
+
$fulltext_enable = Mage::getSingleton('core/session')->getIsFullTextEnable();
|
10 |
+
if (!$fulltext_enable) {
|
11 |
+
return '';
|
12 |
+
}
|
13 |
+
// checking if the searched query from addSearchFilter() is the same to the current query
|
14 |
+
$current_search_term = urlencode(self::getRequest()->getParam('q'));
|
15 |
+
$searched_term = Mage::getSingleton('core/session')->getIspUrlEncodeQuery();
|
16 |
+
if ($current_search_term != $searched_term) {
|
17 |
+
$is_full_text_wrong_flow = true;
|
18 |
+
}
|
19 |
+
} catch (Exception $e) {
|
20 |
+
Mage::log('autocomplete.php _toHtml() Exception => fulltext_enable and query calculations'.$e->getMessage(), null, 'autocompleteplus.log');
|
21 |
+
|
22 |
+
return '';
|
23 |
+
}
|
24 |
+
|
25 |
+
$params = array();
|
26 |
+
if (!$is_full_text_wrong_flow) {
|
27 |
+
try {
|
28 |
+
$alternatives = Mage::getSingleton('core/session')->getIspSearchAlternatives();
|
29 |
+
$results_for = Mage::getSingleton('core/session')->getIspSearchResultsFor();
|
30 |
+
} catch (Exception $e) {
|
31 |
+
Mage::log('autocomplete.php _toHtml() Exception => results_for and did you mean calculations'.$e->getMessage(), null, 'autocompleteplus.log');
|
32 |
+
|
33 |
+
return '';
|
34 |
+
}
|
35 |
+
|
36 |
+
if ($alternatives) {
|
37 |
+
$params['alternatives'] = json_encode($alternatives);
|
38 |
+
}
|
39 |
+
if ($results_for) {
|
40 |
+
$params['results_for'] = $results_for;
|
41 |
+
}
|
42 |
+
} else {
|
43 |
+
$params['wrong_flow'] = 1;
|
44 |
+
}
|
45 |
+
|
46 |
+
$magento_version = Mage::getVersion();
|
47 |
+
$extension_version = (string) Mage::getConfig()->getNode()->modules->Autocompleteplus_Autosuggest->version;
|
48 |
+
$versions = ($params == '') ? 'mage_v='.$magento_version.'&ext_v='.$extension_version
|
49 |
+
: '&mage_v='.$magento_version.'&ext_v='.$extension_version;
|
50 |
+
|
51 |
+
Mage::getSingleton('core/session')->unsIsFullTextEnable();
|
52 |
+
Mage::getSingleton('core/session')->unsIspSearchAlternatives();
|
53 |
+
Mage::getSingleton('core/session')->unsIspSearchResultsFor();
|
54 |
+
|
55 |
+
return '<script data-cfasync="false" async type="text/javascript" src="https://acp-magento.appspot.com/js/magento_full_text.js?'.http_build_query($params).$versions.'"></script>';
|
56 |
+
}
|
57 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Block/Autocorrection.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
class Autocompleteplus_Autosuggest_Block_Autocorrection extends Mage_Core_Block_Template
|
5 |
-
{
|
6 |
-
protected function _prepareLayout()
|
7 |
-
{
|
8 |
-
$header = $this->__("Search results for '%s'", $this->helper('catalogsearch')->getEscapedQueryText());
|
9 |
-
if (Mage::registry('search_results_for')) {
|
10 |
-
$header = $this->__("No results for '%s', showing results for '%s'", $this->helper('catalogsearch')->getQueryText(), Mage::registry('search_results_for'));
|
11 |
-
}
|
12 |
-
$alternatives = '';
|
13 |
-
if (Mage::registry('search_alternatives')) {
|
14 |
-
$links = array();
|
15 |
-
foreach (Mage::registry('search_alternatives') as $alternative) {
|
16 |
-
$links[] = '<a href="'.$this->getUrl('catalogsearch/result', array('q' => $alternative)).'">'.$alternative.'</a>';
|
17 |
-
}
|
18 |
-
|
19 |
-
$alternatives = '</h1><strong>'.$this->__('Did you mean:').'</strong><p>'.implode(', ', $links).'</p>';
|
20 |
-
}
|
21 |
-
|
22 |
-
if (Mage::registry('search_results_for') || Mage::registry('search_alternatives')) {
|
23 |
-
$this->getLayout()
|
24 |
-
->getBlock('search.result')
|
25 |
-
->setHeaderText($header.$alternatives);
|
26 |
-
}
|
27 |
-
}
|
28 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Autocompleteplus_Autosuggest_Block_Autocorrection extends Mage_Core_Block_Template
|
5 |
+
{
|
6 |
+
protected function _prepareLayout()
|
7 |
+
{
|
8 |
+
$header = $this->__("Search results for '%s'", $this->helper('catalogsearch')->getEscapedQueryText());
|
9 |
+
if (Mage::registry('search_results_for')) {
|
10 |
+
$header = $this->__("No results for '%s', showing results for '%s'", $this->helper('catalogsearch')->getQueryText(), Mage::registry('search_results_for'));
|
11 |
+
}
|
12 |
+
$alternatives = '';
|
13 |
+
if (Mage::registry('search_alternatives')) {
|
14 |
+
$links = array();
|
15 |
+
foreach (Mage::registry('search_alternatives') as $alternative) {
|
16 |
+
$links[] = '<a href="'.$this->getUrl('catalogsearch/result', array('q' => $alternative)).'">'.$alternative.'</a>';
|
17 |
+
}
|
18 |
+
|
19 |
+
$alternatives = '</h1><strong>'.$this->__('Did you mean:').'</strong><p>'.implode(', ', $links).'</p>';
|
20 |
+
}
|
21 |
+
|
22 |
+
if (Mage::registry('search_results_for') || Mage::registry('search_alternatives')) {
|
23 |
+
$this->getLayout()
|
24 |
+
->getBlock('search.result')
|
25 |
+
->setHeaderText($header.$alternatives);
|
26 |
+
}
|
27 |
+
}
|
28 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Block/Inject.php
CHANGED
@@ -1,169 +1,169 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Block_Inject extends Mage_Checkout_Block_Cart_Sidebar
|
4 |
-
{
|
5 |
-
const AUTOCOMPLETE_JS_URL = 'https://acp-magento.appspot.com/js/acp-magento.js';
|
6 |
-
|
7 |
-
public $_onCatalog = false;
|
8 |
-
protected $_helper;
|
9 |
-
|
10 |
-
protected function _construct()
|
11 |
-
{
|
12 |
-
$this->_helper = Mage::helper('autocompleteplus_autosuggest');
|
13 |
-
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
14 |
-
$this->_uuid = $config->getUUID();
|
15 |
-
|
16 |
-
//do not cache this block
|
17 |
-
$this->setCacheLifetime(null);
|
18 |
-
}
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Test to see if admin is logged in
|
22 |
-
* by swapping session identifier.
|
23 |
-
*
|
24 |
-
* @return bool
|
25 |
-
*/
|
26 |
-
protected function _isAdminLoggedIn()
|
27 |
-
{
|
28 |
-
$io = new Varien_Io_File();
|
29 |
-
$cookie = Mage::getModel('core/cookie');
|
30 |
-
$sessionCookie = $cookie->get('adminhtml');
|
31 |
-
$path = $io->getCleanPath(Mage::getBaseDir('session'));
|
32 |
-
$sessionFilePath = $path.DS.'sess_'.$sessionCookie;
|
33 |
-
|
34 |
-
//check if adminhtml cookie is set
|
35 |
-
if ($sessionCookie) {
|
36 |
-
//get session path and add dir seperator and content field of cookie as data name with magento "sess_" prefix
|
37 |
-
if (!$io->fileExists($sessionFilePath)) {
|
38 |
-
return false;
|
39 |
-
}
|
40 |
-
//write content of file in var
|
41 |
-
$io->open(array('path' => $path));
|
42 |
-
$sessionFile = $io->read($sessionFilePath);
|
43 |
-
if (stripos($sessionFile, 'Mage_Admin_Model_User')) {
|
44 |
-
return true;
|
45 |
-
}
|
46 |
-
|
47 |
-
}
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Get the current store code.
|
52 |
-
*
|
53 |
-
* @return string
|
54 |
-
*/
|
55 |
-
public function getStoreId()
|
56 |
-
{
|
57 |
-
return Mage::app()->getStore()->getStoreId();
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Get the Magento version.
|
62 |
-
*
|
63 |
-
* @return string
|
64 |
-
*/
|
65 |
-
public function getMagentoVersion()
|
66 |
-
{
|
67 |
-
return Mage::getVersion();
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Get the AUTOCOMPLETEPLUS version.
|
72 |
-
*
|
73 |
-
* @return string
|
74 |
-
*/
|
75 |
-
public function getVersion()
|
76 |
-
{
|
77 |
-
return Mage::helper('autocompleteplus_autosuggest')->getVersion();
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Get the current product.
|
82 |
-
*
|
83 |
-
* @return Mage_Catalog_Model_Product
|
84 |
-
*/
|
85 |
-
public function getProduct()
|
86 |
-
{
|
87 |
-
return Mage::registry('current_product');
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* UUID getter.
|
92 |
-
*
|
93 |
-
* @return string
|
94 |
-
*/
|
95 |
-
public function getUUID()
|
96 |
-
{
|
97 |
-
return $this->_uuid;
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Get the URL of the current product if it exists.
|
102 |
-
*
|
103 |
-
* @return string
|
104 |
-
*/
|
105 |
-
public function getProductUrl()
|
106 |
-
{
|
107 |
-
if ($product = $this->getProduct()) {
|
108 |
-
return urlencode($product->getProductUrl());
|
109 |
-
}
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Get the current product's SKU if the product exists.
|
114 |
-
*
|
115 |
-
* @return string
|
116 |
-
*/
|
117 |
-
public function getProductSku()
|
118 |
-
{
|
119 |
-
if ($product = $this->getProduct()) {
|
120 |
-
return $product->getSku();
|
121 |
-
}
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* Get the ID of the current product if it exists.
|
126 |
-
*
|
127 |
-
* @return string
|
128 |
-
*/
|
129 |
-
public function getProductIdentifier()
|
130 |
-
{
|
131 |
-
if ($product = $this->getProduct()) {
|
132 |
-
return $product->getId();
|
133 |
-
}
|
134 |
-
}
|
135 |
-
|
136 |
-
public function getQuoteId()
|
137 |
-
{
|
138 |
-
return Mage::getSingleton('checkout/session')->getQuoteId();
|
139 |
-
}
|
140 |
-
|
141 |
-
public function isLoggedInUser(){
|
142 |
-
$session_customer = Mage::getSingleton('customer/session');
|
143 |
-
return $session_customer->isLoggedIn();
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* Return a formatted string for the <script src> attr.
|
148 |
-
*
|
149 |
-
* @return string
|
150 |
-
*/
|
151 |
-
public function getSrc()
|
152 |
-
{
|
153 |
-
$parameters = array(
|
154 |
-
'mage_v' => $this->getMagentoVersion(),
|
155 |
-
'ext_v' => $this->getVersion(),
|
156 |
-
'store' => $this->getStoreId(),
|
157 |
-
'UUID' => $this->getUUID(),
|
158 |
-
'product_url' => $this->getProductUrl(),
|
159 |
-
'product_sku' => $this->getProductSku(),
|
160 |
-
'product_id' => $this->getProductIdentifier(),
|
161 |
-
'is_admin_user' => $this->_isAdminLoggedIn(),
|
162 |
-
'sessionID' => $this->_helper->getSessionId(),
|
163 |
-
'QuoteID' => $this->getQuoteId(),
|
164 |
-
'is_user_logged_in'=> $this->isLoggedInUser()
|
165 |
-
);
|
166 |
-
|
167 |
-
return self::AUTOCOMPLETE_JS_URL.'?'.http_build_query($parameters, '', '&');
|
168 |
-
}
|
169 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Block_Inject extends Mage_Checkout_Block_Cart_Sidebar
|
4 |
+
{
|
5 |
+
const AUTOCOMPLETE_JS_URL = 'https://acp-magento.appspot.com/js/acp-magento.js';
|
6 |
+
|
7 |
+
public $_onCatalog = false;
|
8 |
+
protected $_helper;
|
9 |
+
|
10 |
+
protected function _construct()
|
11 |
+
{
|
12 |
+
$this->_helper = Mage::helper('autocompleteplus_autosuggest');
|
13 |
+
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
14 |
+
$this->_uuid = $config->getUUID();
|
15 |
+
|
16 |
+
//do not cache this block
|
17 |
+
$this->setCacheLifetime(null);
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Test to see if admin is logged in
|
22 |
+
* by swapping session identifier.
|
23 |
+
*
|
24 |
+
* @return bool
|
25 |
+
*/
|
26 |
+
protected function _isAdminLoggedIn()
|
27 |
+
{
|
28 |
+
$io = new Varien_Io_File();
|
29 |
+
$cookie = Mage::getModel('core/cookie');
|
30 |
+
$sessionCookie = $cookie->get('adminhtml');
|
31 |
+
$path = $io->getCleanPath(Mage::getBaseDir('session'));
|
32 |
+
$sessionFilePath = $path.DS.'sess_'.$sessionCookie;
|
33 |
+
|
34 |
+
//check if adminhtml cookie is set
|
35 |
+
if ($sessionCookie) {
|
36 |
+
//get session path and add dir seperator and content field of cookie as data name with magento "sess_" prefix
|
37 |
+
if (!$io->fileExists($sessionFilePath)) {
|
38 |
+
return false;
|
39 |
+
}
|
40 |
+
//write content of file in var
|
41 |
+
$io->open(array('path' => $path));
|
42 |
+
$sessionFile = $io->read($sessionFilePath);
|
43 |
+
if (stripos($sessionFile, 'Mage_Admin_Model_User')) {
|
44 |
+
return true;
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Get the current store code.
|
52 |
+
*
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
public function getStoreId()
|
56 |
+
{
|
57 |
+
return Mage::app()->getStore()->getStoreId();
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Get the Magento version.
|
62 |
+
*
|
63 |
+
* @return string
|
64 |
+
*/
|
65 |
+
public function getMagentoVersion()
|
66 |
+
{
|
67 |
+
return Mage::getVersion();
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Get the AUTOCOMPLETEPLUS version.
|
72 |
+
*
|
73 |
+
* @return string
|
74 |
+
*/
|
75 |
+
public function getVersion()
|
76 |
+
{
|
77 |
+
return Mage::helper('autocompleteplus_autosuggest')->getVersion();
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Get the current product.
|
82 |
+
*
|
83 |
+
* @return Mage_Catalog_Model_Product
|
84 |
+
*/
|
85 |
+
public function getProduct()
|
86 |
+
{
|
87 |
+
return Mage::registry('current_product');
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* UUID getter.
|
92 |
+
*
|
93 |
+
* @return string
|
94 |
+
*/
|
95 |
+
public function getUUID()
|
96 |
+
{
|
97 |
+
return $this->_uuid;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Get the URL of the current product if it exists.
|
102 |
+
*
|
103 |
+
* @return string
|
104 |
+
*/
|
105 |
+
public function getProductUrl()
|
106 |
+
{
|
107 |
+
if ($product = $this->getProduct()) {
|
108 |
+
return urlencode($product->getProductUrl());
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Get the current product's SKU if the product exists.
|
114 |
+
*
|
115 |
+
* @return string
|
116 |
+
*/
|
117 |
+
public function getProductSku()
|
118 |
+
{
|
119 |
+
if ($product = $this->getProduct()) {
|
120 |
+
return $product->getSku();
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Get the ID of the current product if it exists.
|
126 |
+
*
|
127 |
+
* @return string
|
128 |
+
*/
|
129 |
+
public function getProductIdentifier()
|
130 |
+
{
|
131 |
+
if ($product = $this->getProduct()) {
|
132 |
+
return $product->getId();
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
public function getQuoteId()
|
137 |
+
{
|
138 |
+
return Mage::getSingleton('checkout/session')->getQuoteId();
|
139 |
+
}
|
140 |
+
|
141 |
+
public function isLoggedInUser(){
|
142 |
+
$session_customer = Mage::getSingleton('customer/session');
|
143 |
+
return $session_customer->isLoggedIn();
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Return a formatted string for the <script src> attr.
|
148 |
+
*
|
149 |
+
* @return string
|
150 |
+
*/
|
151 |
+
public function getSrc()
|
152 |
+
{
|
153 |
+
$parameters = array(
|
154 |
+
'mage_v' => $this->getMagentoVersion(),
|
155 |
+
'ext_v' => $this->getVersion(),
|
156 |
+
'store' => $this->getStoreId(),
|
157 |
+
'UUID' => $this->getUUID(),
|
158 |
+
'product_url' => $this->getProductUrl(),
|
159 |
+
'product_sku' => $this->getProductSku(),
|
160 |
+
'product_id' => $this->getProductIdentifier(),
|
161 |
+
'is_admin_user' => $this->_isAdminLoggedIn(),
|
162 |
+
'sessionID' => $this->_helper->getSessionId(),
|
163 |
+
'QuoteID' => $this->getQuoteId(),
|
164 |
+
'is_user_logged_in'=> $this->isLoggedInUser()
|
165 |
+
);
|
166 |
+
|
167 |
+
return self::AUTOCOMPLETE_JS_URL.'?'.http_build_query($parameters, '', '&');
|
168 |
+
}
|
169 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Block/Notifications.php
CHANGED
@@ -1,44 +1,44 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* InstantSearchPlus (Autosuggest).
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is available through the world-wide-web at this URL:
|
9 |
-
* http://opensource.org/licenses/osl-3.0.php
|
10 |
-
*
|
11 |
-
* @category Mage
|
12 |
-
*
|
13 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
class Autocompleteplus_Autosuggest_Block_Notifications extends Mage_Core_Block_Template
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @return Autocompleteplus_Autosuggest_Model_Mysql4_Notifications_Collection
|
20 |
-
*/
|
21 |
-
public function getNotifications()
|
22 |
-
{
|
23 |
-
/** @var Autocompleteplus_Autosuggest_Model_Mysql4_Notifications_Collection $collection */
|
24 |
-
$collection = Mage::getModel('autocompleteplus_autosuggest/notifications')
|
25 |
-
->getCollection();
|
26 |
-
|
27 |
-
return $collection->addTypeFilter('alert')->addActiveFilter();
|
28 |
-
}
|
29 |
-
|
30 |
-
public function localhostSynced()
|
31 |
-
{
|
32 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
33 |
-
|
34 |
-
$isReachable = $helper->getIsReachable();
|
35 |
-
|
36 |
-
$syncWasStarted = $helper->getIfSyncWasInitiated();
|
37 |
-
|
38 |
-
if (!$isReachable && !$syncWasStarted) {
|
39 |
-
return true;
|
40 |
-
} else {
|
41 |
-
return false;
|
42 |
-
}
|
43 |
-
}
|
44 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* InstantSearchPlus (Autosuggest).
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Mage
|
12 |
+
*
|
13 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
class Autocompleteplus_Autosuggest_Block_Notifications extends Mage_Core_Block_Template
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* @return Autocompleteplus_Autosuggest_Model_Mysql4_Notifications_Collection
|
20 |
+
*/
|
21 |
+
public function getNotifications()
|
22 |
+
{
|
23 |
+
/** @var Autocompleteplus_Autosuggest_Model_Mysql4_Notifications_Collection $collection */
|
24 |
+
$collection = Mage::getModel('autocompleteplus_autosuggest/notifications')
|
25 |
+
->getCollection();
|
26 |
+
|
27 |
+
return $collection->addTypeFilter('alert')->addActiveFilter();
|
28 |
+
}
|
29 |
+
|
30 |
+
public function localhostSynced()
|
31 |
+
{
|
32 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
33 |
+
|
34 |
+
$isReachable = $helper->getIsReachable();
|
35 |
+
|
36 |
+
$syncWasStarted = $helper->getIfSyncWasInitiated();
|
37 |
+
|
38 |
+
if (!$isReachable && !$syncWasStarted) {
|
39 |
+
return true;
|
40 |
+
} else {
|
41 |
+
return false;
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Controller/Abstract.php
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
abstract class Autocompleteplus_Autosuggest_Controller_Abstract extends Mage_Core_Controller_Front_Action
|
4 |
-
{
|
5 |
-
const PHP_SCRIPT_TIMEOUT = 1800;
|
6 |
-
const MISSING_PARAMETER = 767;
|
7 |
-
const STATUS_FAILURE = 'failure';
|
8 |
-
const STATUS_SUCCESS = 'success';
|
9 |
-
|
10 |
-
public function preDispatch()
|
11 |
-
{
|
12 |
-
parent::preDispatch();
|
13 |
-
set_time_limit(self::PHP_SCRIPT_TIMEOUT);
|
14 |
-
}
|
15 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class Autocompleteplus_Autosuggest_Controller_Abstract extends Mage_Core_Controller_Front_Action
|
4 |
+
{
|
5 |
+
const PHP_SCRIPT_TIMEOUT = 1800;
|
6 |
+
const MISSING_PARAMETER = 767;
|
7 |
+
const STATUS_FAILURE = 'failure';
|
8 |
+
const STATUS_SUCCESS = 'success';
|
9 |
+
|
10 |
+
public function preDispatch()
|
11 |
+
{
|
12 |
+
parent::preDispatch();
|
13 |
+
set_time_limit(self::PHP_SCRIPT_TIMEOUT);
|
14 |
+
}
|
15 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Helper/Data.php
CHANGED
@@ -1,877 +1,882 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* InstantSearchPlus (Autosuggest).
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is available through the world-wide-web at this URL:
|
9 |
-
* http://opensource.org/licenses/osl-3.0.php
|
10 |
-
*
|
11 |
-
* @category Mage
|
12 |
-
*
|
13 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
17 |
-
{
|
18 |
-
|
19 |
-
const WEBSITES_SCOPE = 'websites';
|
20 |
-
|
21 |
-
const STORES_SCOPE = 'stores';
|
22 |
-
|
23 |
-
const DEFAULT_SCOPE = 'default';
|
24 |
-
|
25 |
-
|
26 |
-
const WEBSITE_ID = 'website_id';
|
27 |
-
|
28 |
-
// private $server_url = 'http://0-2vk.acp-magento.appspot.com';
|
29 |
-
private $server_url = 'http://magento.instantsearchplus.com';
|
30 |
-
|
31 |
-
protected $_authKey;
|
32 |
-
|
33 |
-
public function getServerUrl()
|
34 |
-
{
|
35 |
-
return $this->server_url;
|
36 |
-
}
|
37 |
-
|
38 |
-
public function validateUuid($uuid)
|
39 |
-
{
|
40 |
-
if (strlen($uuid) == 36
|
41 |
-
&& substr_count($uuid, '-') == 4
|
42 |
-
) {
|
43 |
-
return true;
|
44 |
-
}
|
45 |
-
|
46 |
-
return false;
|
47 |
-
}
|
48 |
-
|
49 |
-
public function getConfig()
|
50 |
-
{
|
51 |
-
return Mage::getModel('autocompleteplus_autosuggest/config');
|
52 |
-
}
|
53 |
-
|
54 |
-
public function getMageVersion()
|
55 |
-
{
|
56 |
-
return Mage::getVersion();
|
57 |
-
}
|
58 |
-
|
59 |
-
public function getVersion()
|
60 |
-
{
|
61 |
-
return (string) Mage::getConfig()->getModuleConfig('Autocompleteplus_Autosuggest')->version;
|
62 |
-
}
|
63 |
-
|
64 |
-
public function getConfigDataByFullPath($path)
|
65 |
-
{
|
66 |
-
$valsArr = $this->getConfigMultiDataByFullPath($path);
|
67 |
-
|
68 |
-
$value = '';
|
69 |
-
|
70 |
-
if (is_array($valsArr) && count($valsArr) > 0) {
|
71 |
-
$value = array_shift($valsArr);
|
72 |
-
}
|
73 |
-
|
74 |
-
return $value;
|
75 |
-
}
|
76 |
-
|
77 |
-
public function getConfigMultiDataByFullPath($path)
|
78 |
-
{
|
79 |
-
$values = array();
|
80 |
-
|
81 |
-
if (!$rows = Mage::getSingleton('core/config_data')->getCollection()->getItemsByColumnValue('path', $path)) {
|
82 |
-
$conf = Mage::getSingleton('core/config')->init()->getXpath('/config/default/'.$path);
|
83 |
-
$values[] = array_shift($conf);
|
84 |
-
} else {
|
85 |
-
|
86 |
-
foreach ($rows as $row) {
|
87 |
-
$scopeId = $row->getScopeId();
|
88 |
-
|
89 |
-
$rowValue = $row->getValue();
|
90 |
-
|
91 |
-
if ($scopeId != null && $rowValue != null) {
|
92 |
-
$values[$scopeId] = $rowValue;
|
93 |
-
}
|
94 |
-
}
|
95 |
-
}
|
96 |
-
|
97 |
-
return $values;
|
98 |
-
}
|
99 |
-
|
100 |
-
public function getConfigMultiScopesDataByFullPath($path)
|
101 |
-
{
|
102 |
-
$values = array();
|
103 |
-
|
104 |
-
$rows = Mage::getSingleton('core/config_data')->getCollection()->getItemsByColumnValue('path', $path);
|
105 |
-
|
106 |
-
foreach ($rows as $row) {
|
107 |
-
$scope = $row->getScope();
|
108 |
-
|
109 |
-
$scopeId = $row->getScopeId();
|
110 |
-
|
111 |
-
$rowValue = $row->getValue();
|
112 |
-
|
113 |
-
if ($scope != null && $scopeId != null && $rowValue != null) {
|
114 |
-
|
115 |
-
if (!array_key_exists($scope,$values)) {
|
116 |
-
$values[$scope] = array();
|
117 |
-
}
|
118 |
-
|
119 |
-
$values[$scope][$scopeId] = $rowValue;
|
120 |
-
}
|
121 |
-
}
|
122 |
-
|
123 |
-
|
124 |
-
return $values;
|
125 |
-
}
|
126 |
-
|
127 |
-
public function sendCurl($command)
|
128 |
-
{
|
129 |
-
if (isset($ch)) {
|
130 |
-
unset($ch);
|
131 |
-
}
|
132 |
-
|
133 |
-
if (function_exists('curl_setopt')) {
|
134 |
-
$ch = curl_init();
|
135 |
-
curl_setopt($ch, CURLOPT_URL, $command);
|
136 |
-
curl_setopt($ch, CURLOPT_HEADER, 0);
|
137 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
138 |
-
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
|
139 |
-
$str = curl_exec($ch);
|
140 |
-
} else {
|
141 |
-
$str = 'failed';
|
142 |
-
}
|
143 |
-
|
144 |
-
return $str;
|
145 |
-
}
|
146 |
-
|
147 |
-
public static function sendPostCurl($command, $data = array(), $cookie_file = 'genCookie.txt')
|
148 |
-
{
|
149 |
-
if (isset($ch)) {
|
150 |
-
unset($ch);
|
151 |
-
}
|
152 |
-
|
153 |
-
if (function_exists('curl_setopt')) {
|
154 |
-
$ch = curl_init();
|
155 |
-
curl_setopt($ch, CURLOPT_URL, $command);
|
156 |
-
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
|
157 |
-
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
|
158 |
-
curl_setopt($ch, CURLOPT_HEADER, 0);
|
159 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
160 |
-
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
|
161 |
-
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20100101 Firefox/21.0');
|
162 |
-
//curl_setopt($ch,CURLOPT_POST,0);
|
163 |
-
if (!empty($data)) {
|
164 |
-
curl_setopt_array($ch, array(
|
165 |
-
CURLOPT_POSTFIELDS => $data,
|
166 |
-
));
|
167 |
-
}
|
168 |
-
|
169 |
-
// curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
170 |
-
// 'Connection: Keep-Alive',
|
171 |
-
// 'Keep-Alive: 800'
|
172 |
-
// ));
|
173 |
-
|
174 |
-
$str = curl_exec($ch);
|
175 |
-
} else {
|
176 |
-
$str = 'failed';
|
177 |
-
}
|
178 |
-
|
179 |
-
return $str;
|
180 |
-
}
|
181 |
-
|
182 |
-
public function prepareGroupedProductPrice($groupedProduct)
|
183 |
-
{
|
184 |
-
$aProductIds = $groupedProduct->getTypeInstance()->getChildrenIds($groupedProduct->getId());
|
185 |
-
|
186 |
-
$prices = array();
|
187 |
-
foreach ($aProductIds as $ids) {
|
188 |
-
foreach ($ids as $id) {
|
189 |
-
try {
|
190 |
-
$aProduct = Mage::getModel('catalog/product')->load($id);
|
191 |
-
$prices[] = $aProduct->getPriceModel()->getPrice($aProduct);
|
192 |
-
} catch (Exception $e) {
|
193 |
-
continue;
|
194 |
-
}
|
195 |
-
}
|
196 |
-
}
|
197 |
-
|
198 |
-
krsort($prices);
|
199 |
-
try {
|
200 |
-
if (count($prices) > 0) {
|
201 |
-
$groupedProduct->setPrice($prices[0]);
|
202 |
-
} else {
|
203 |
-
$groupedProduct->setPrice(0);
|
204 |
-
}
|
205 |
-
} catch (Exception $e) {
|
206 |
-
$groupedProduct->setPrice(0);
|
207 |
-
}
|
208 |
-
|
209 |
-
// or you can return price
|
210 |
-
}
|
211 |
-
|
212 |
-
public function getBundlePrice($product)
|
213 |
-
{
|
214 |
-
$optionCol = $product->getTypeInstance(true)
|
215 |
-
->getOptionsCollection($product);
|
216 |
-
$selectionCol = $product->getTypeInstance(true)
|
217 |
-
->getSelectionsCollection(
|
218 |
-
$product->getTypeInstance(true)->getOptionsIds($product),
|
219 |
-
$product
|
220 |
-
);
|
221 |
-
$optionCol->appendSelections($selectionCol);
|
222 |
-
$price = $product->getPrice();
|
223 |
-
|
224 |
-
foreach ($optionCol as $option) {
|
225 |
-
if ($option->required) {
|
226 |
-
$selections = $option->getSelections();
|
227 |
-
$selPricesArr = array();
|
228 |
-
|
229 |
-
if (is_array($selections)) {
|
230 |
-
foreach ($selections as $s) {
|
231 |
-
$selPricesArr[] = $s->price;
|
232 |
-
}
|
233 |
-
|
234 |
-
$minPrice = min($selPricesArr);
|
235 |
-
|
236 |
-
if ($product->getSpecialPrice() > 0) {
|
237 |
-
$minPrice *= $product->getSpecialPrice() / 100;
|
238 |
-
}
|
239 |
-
|
240 |
-
$price += round($minPrice, 2);
|
241 |
-
}
|
242 |
-
}
|
243 |
-
}
|
244 |
-
|
245 |
-
return $price;
|
246 |
-
}
|
247 |
-
|
248 |
-
public function getMultiStoreDataJson()
|
249 |
-
{
|
250 |
-
$websites = Mage::getModel('core/website')->getCollection();
|
251 |
-
$mage = Mage::getVersion();
|
252 |
-
$ext = Mage::helper('autocompleteplus_autosuggest')->getVersion();
|
253 |
-
$version = array('mage' => $mage, 'ext' => $ext);
|
254 |
-
|
255 |
-
//getting site url
|
256 |
-
$url = $this->getConfigDataByFullPath('web/unsecure/base_url');
|
257 |
-
|
258 |
-
//getting site owner email
|
259 |
-
$storeMail = $this->getConfigDataByFullPath('autocompleteplus/config/store_email');
|
260 |
-
|
261 |
-
if (!$storeMail) {
|
262 |
-
$storeMail = $this->getConfigDataByFullPath('trans_email/ident_general/email');
|
263 |
-
}
|
264 |
-
|
265 |
-
$storesArr = array();
|
266 |
-
foreach ($websites as $website) {
|
267 |
-
$code = $website->getCode();
|
268 |
-
$stores = $website->getStores();
|
269 |
-
foreach ($stores as $store) {
|
270 |
-
$storesArr[$store->getStoreId()] = $store->getData();
|
271 |
-
}
|
272 |
-
}
|
273 |
-
|
274 |
-
if (count($storesArr) == 1) {
|
275 |
-
try {
|
276 |
-
$dataArr = array(
|
277 |
-
'stores' => array_pop($storesArr),
|
278 |
-
'version' => $version,
|
279 |
-
);
|
280 |
-
} catch (Exception $e) {
|
281 |
-
$dataArr = array(
|
282 |
-
'stores' => array(),
|
283 |
-
'version' => $version,
|
284 |
-
);
|
285 |
-
}
|
286 |
-
|
287 |
-
$dataArr['site'] = $url;
|
288 |
-
$dataArr['email'] = $storeMail;
|
289 |
-
|
290 |
-
$multistoreJson = json_encode($dataArr);
|
291 |
-
} else {
|
292 |
-
$multistoreData = $this->_createMultiStoreJson($storesArr);
|
293 |
-
|
294 |
-
$multistoreDataByScope = $this->_createMultiStoreByScopeJson($storesArr);
|
295 |
-
|
296 |
-
$dataArr = array(
|
297 |
-
'stores' => $multistoreData,
|
298 |
-
'stores2' => $multistoreDataByScope,
|
299 |
-
'version' => $version,
|
300 |
-
);
|
301 |
-
|
302 |
-
$dataArr['site'] = $url;
|
303 |
-
$dataArr['email'] = $storeMail;
|
304 |
-
$multistoreJson = json_encode($dataArr);
|
305 |
-
}
|
306 |
-
|
307 |
-
return $multistoreJson;
|
308 |
-
}
|
309 |
-
|
310 |
-
public function getExtensionConflict($all_conflicts = false)
|
311 |
-
{
|
312 |
-
$all_rewrite_classes = array();
|
313 |
-
$node_type_list = array('model', 'helper', 'block');
|
314 |
-
|
315 |
-
foreach ($node_type_list as $node_type) {
|
316 |
-
foreach (Mage::getConfig()->getNode('modules')->children() as $name => $module) {
|
317 |
-
if ($module->codePool == 'core' || $module->active != 'true') {
|
318 |
-
continue;
|
319 |
-
}
|
320 |
-
$config_file_path = Mage::getConfig()->getModuleDir('etc', $name).DS.'config.xml';
|
321 |
-
$config = new Varien_Simplexml_Config();
|
322 |
-
$config->loadString('<config/>');
|
323 |
-
$config->loadFile($config_file_path);
|
324 |
-
$config->extend($config, true);
|
325 |
-
|
326 |
-
$nodes = $config->getNode()->global->{$node_type.'s'};
|
327 |
-
if (!$nodes) {
|
328 |
-
continue;
|
329 |
-
}
|
330 |
-
foreach ($nodes->children() as $node_name => $config) {
|
331 |
-
if ($config->rewrite) { // there is rewrite for current config
|
332 |
-
foreach ($config->rewrite->children() as $class_tag => $derived_class) {
|
333 |
-
$base_class_name = $this->_getMageBaseClass($node_type, $node_name, $class_tag);
|
334 |
-
|
335 |
-
$lead_derived_class = '';
|
336 |
-
$conf = Mage::getConfig()->getNode()->global->{$node_type.'s'}->{$node_name};
|
337 |
-
if (isset($conf->rewrite->$class_tag)) {
|
338 |
-
$lead_derived_class = (string) $conf->rewrite->$class_tag;
|
339 |
-
}
|
340 |
-
if ($derived_class == '') {
|
341 |
-
$derived_class = $lead_derived_class;
|
342 |
-
}
|
343 |
-
|
344 |
-
if (empty($all_rewrite_classes[$base_class_name])) {
|
345 |
-
$all_rewrite_classes[$base_class_name] = array(
|
346 |
-
'derived' => array((string) $derived_class),
|
347 |
-
'lead' => (string) $lead_derived_class,
|
348 |
-
'tag' => $class_tag,
|
349 |
-
'name' => array((string) $name),
|
350 |
-
);
|
351 |
-
} else {
|
352 |
-
array_push($all_rewrite_classes[$base_class_name]['derived'], (string) $derived_class);
|
353 |
-
array_push($all_rewrite_classes[$base_class_name]['name'], (string) $name);
|
354 |
-
}
|
355 |
-
}
|
356 |
-
}
|
357 |
-
}
|
358 |
-
}
|
359 |
-
}
|
360 |
-
if ($all_conflicts) {
|
361 |
-
return $all_rewrite_classes;
|
362 |
-
}
|
363 |
-
|
364 |
-
$isp_rewrite_classes = array();
|
365 |
-
$isp_module_name = 'Autocompleteplus_Autosuggest';
|
366 |
-
foreach ($all_rewrite_classes as $base => $conflict_info) {
|
367 |
-
if (in_array($isp_module_name, $conflict_info['name'])) { // if isp extension rewrite this base class
|
368 |
-
if (count($conflict_info['derived']) > 1) { // more then 1 class rewrite this base class => there is a conflict
|
369 |
-
$isp_rewrite_classes[$base] = $conflict_info;
|
370 |
-
}
|
371 |
-
}
|
372 |
-
}
|
373 |
-
|
374 |
-
return $isp_rewrite_classes;
|
375 |
-
}
|
376 |
-
|
377 |
-
protected function _getMageBaseClass($node_type, $node_name, $class_tag)
|
378 |
-
{
|
379 |
-
$config = Mage::getConfig()->getNode()->global->{$node_type.'s'}->$node_name;
|
380 |
-
|
381 |
-
if (!empty($config)) {
|
382 |
-
$className = $config->getClassName();
|
383 |
-
}
|
384 |
-
if (empty($className)) {
|
385 |
-
$className = 'mage_'.$node_name.'_'.$node_type;
|
386 |
-
}
|
387 |
-
if (!empty($class_tag)) {
|
388 |
-
$className .= '_'.$class_tag;
|
389 |
-
}
|
390 |
-
|
391 |
-
return uc_words($className);
|
392 |
-
}
|
393 |
-
|
394 |
-
/**
|
395 |
-
* Checksum functionality.
|
396 |
-
*/
|
397 |
-
public function isChecksumTableExists()
|
398 |
-
{
|
399 |
-
$table_prefix = (string) Mage::getConfig()->getTablePrefix();
|
400 |
-
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
401 |
-
if ($read->showTableStatus($table_prefix.'autocompleteplus_checksum')) {
|
402 |
-
return true;
|
403 |
-
} else {
|
404 |
-
return false;
|
405 |
-
}
|
406 |
-
}
|
407 |
-
|
408 |
-
public function calculateChecksum($product)
|
409 |
-
{
|
410 |
-
$product_id = $product->getId();
|
411 |
-
$product_title = $product->getName();
|
412 |
-
$product_description = $product->getDescription();
|
413 |
-
$product_short_desc = $product->getShortDescription();
|
414 |
-
$product_url = $product->getUrlPath(); //Mage::helper('catalog/product')->getProductUrl($product_id); | $product->getProductUrl()
|
415 |
-
$product_visibility = $product->getVisibility();
|
416 |
-
$product_in_stock = $product->isInStock();
|
417 |
-
$product_price = (float) $product->getPrice();
|
418 |
-
try {
|
419 |
-
$product_thumb_url = '/'.$product->getImage();
|
420 |
-
|
421 |
-
// $product_thumb_url = $product->getThumbnailUrl(); //Mage::helper('catalog/image')->init($product, 'thumbnail');
|
422 |
-
// $thumb_pattern = '/\/[^\/]+(?![^\/]*\/)/';
|
423 |
-
// if (preg_match($thumb_pattern, $product_thumb_url, $matches) && count($matches) > 0){
|
424 |
-
// $product_thumb_url = $matches[0];
|
425 |
-
// } else {
|
426 |
-
// $product_thumb_url = '';
|
427 |
-
// }
|
428 |
-
} catch (Exception $e) {
|
429 |
-
$product_thumb_url = '';
|
430 |
-
}
|
431 |
-
$product_type = $product->getTypeID();
|
432 |
-
|
433 |
-
$checksum_string = $product_id.$product_title.$product_description.$product_short_desc.$product_url.
|
434 |
-
$product_visibility.$product_in_stock.$product_price.$product_thumb_url.$product_type;
|
435 |
-
|
436 |
-
$checksum_md5 = md5($checksum_string);
|
437 |
-
|
438 |
-
return $checksum_md5;
|
439 |
-
}
|
440 |
-
|
441 |
-
public function getSavedChecksum($table_prefix, $read, $product_id, $store_id)
|
442 |
-
{
|
443 |
-
$sql_fetch = 'SELECT checksum FROM '.$table_prefix.'autocompleteplus_checksum WHERE identifier=? AND store_id=?';
|
444 |
-
$updates = $read->fetchAll($sql_fetch, array($product_id, $store_id));
|
445 |
-
if ($updates && (count($updates) != 0)) {
|
446 |
-
return $updates[0]['checksum'];
|
447 |
-
} else {
|
448 |
-
return '';
|
449 |
-
}
|
450 |
-
}
|
451 |
-
|
452 |
-
public function updateSavedProductChecksum($product_id, $sku, $store_id, $checksum)
|
453 |
-
{
|
454 |
-
return;
|
455 |
-
if ($product_id == null || $sku == null) {
|
456 |
-
return;
|
457 |
-
}
|
458 |
-
$checksumModel = Mage::getModel('autocompleteplus_autosuggest/checksum');
|
459 |
-
$collection = $checksumModel->getCollection()
|
460 |
-
->addFieldToFilter('identifier', $product_id)
|
461 |
-
->addFieldToFilter('store_id', $store_id);
|
462 |
-
|
463 |
-
$row = $collection->getFirstItem();
|
464 |
-
|
465 |
-
if ($row && $collection->getSize() > 0) {
|
466 |
-
if ($row->getChecksum() != $checksum) {
|
467 |
-
$row->setChecksum($checksum)->save();
|
468 |
-
}
|
469 |
-
} else {
|
470 |
-
$checksumModel->setIdentifier($product_id)
|
471 |
-
->setSku($sku)
|
472 |
-
->setStoreId($store_id)
|
473 |
-
->setChecksum($checksum)
|
474 |
-
->save();
|
475 |
-
}
|
476 |
-
}
|
477 |
-
|
478 |
-
public function updateDeletedProductChecksum($table_prefix, $read, $write, $product_id, $sku, $store_id)
|
479 |
-
{
|
480 |
-
return;
|
481 |
-
if ($product_id == null) {
|
482 |
-
return;
|
483 |
-
}
|
484 |
-
|
485 |
-
$checksums = Mage::getModel('autocompleteplus_autosuggest/checksum')->getCollection()
|
486 |
-
->addFieldToFilter('identifier', $product_id)
|
487 |
-
->addFieldToFilter('store_id', $store_id);
|
488 |
-
|
489 |
-
if ($checksums->getSize() > 0) {
|
490 |
-
// @codingStandardsIgnoreLine
|
491 |
-
$checksum = $checksums->getFirstItem();
|
492 |
-
$checksum->delete();
|
493 |
-
}
|
494 |
-
}
|
495 |
-
|
496 |
-
private function setUpdateNeededForProduct($read, $write, $product_id, $product_sku, $store_id)
|
497 |
-
{
|
498 |
-
if ($product_id == null) {
|
499 |
-
return;
|
500 |
-
}
|
501 |
-
if ($product_sku == null) {
|
502 |
-
$product_sku = 'dummy_sku';
|
503 |
-
}
|
504 |
-
try {
|
505 |
-
$table_prefix = (string) Mage::getConfig()->getTablePrefix();
|
506 |
-
$is_table_exist = $write->showTableStatus($table_prefix.'autocompleteplus_batches');
|
507 |
-
if (!$is_table_exist) { // table not exists
|
508 |
-
return;
|
509 |
-
}
|
510 |
-
|
511 |
-
$sql_fetch = 'SELECT * FROM '.$table_prefix.'autocompleteplus_batches WHERE product_id=? AND store_id=?';
|
512 |
-
$updates = $read->fetchAll($sql_fetch, array($product_id, $store_id));
|
513 |
-
|
514 |
-
if ($updates && (count($updates) != 0)) {
|
515 |
-
$sql = 'UPDATE '.$table_prefix.'autocompleteplus_batches SET update_date=?,action=? WHERE product_id=? AND store_id=?';
|
516 |
-
$write->query($sql, array(strtotime('now'), 'update', $product_id, $store_id));
|
517 |
-
} else {
|
518 |
-
$sql = 'INSERT INTO '.$table_prefix.'autocompleteplus_batches (product_id,store_id,update_date,action,sku) VALUES (?,?,?,?,?)';
|
519 |
-
$write->query($sql, array($product_id, $store_id, strtotime('now'), 'update', $product_sku));
|
520 |
-
}
|
521 |
-
} catch (Exception $e) {
|
522 |
-
Mage::log('Exception raised in setUpdateNeededForProduct() - '.$e->getMessage(), null, 'autocompleteplus.log');
|
523 |
-
$this->ispErrorLog('Exception raised in setUpdateNeededForProduct() - '.$e->getMessage());
|
524 |
-
}
|
525 |
-
}
|
526 |
-
|
527 |
-
public function compareProductsChecksum($from, $count, $store_id = null)
|
528 |
-
{
|
529 |
-
$num_of_updates = 0;
|
530 |
-
if (!$this->isChecksumTableExists()) {
|
531 |
-
return;
|
532 |
-
}
|
533 |
-
|
534 |
-
$products = Mage::getModel('catalog/product')->getCollection();
|
535 |
-
if ($store_id) {
|
536 |
-
$products->addStoreFilter($store_id);
|
537 |
-
}
|
538 |
-
$products->getSelect()->limit($count, $from);
|
539 |
-
$products->load();
|
540 |
-
|
541 |
-
$table_prefix = (string) Mage::getConfig()->getTablePrefix();
|
542 |
-
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
543 |
-
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
544 |
-
|
545 |
-
foreach ($products as $product) {
|
546 |
-
try {
|
547 |
-
$product_collection_data = $product->getData();
|
548 |
-
$product_model = Mage::getModel('catalog/product')
|
549 |
-
->setStore($store_id)->setStoreId($store_id)
|
550 |
-
->load($product_collection_data['entity_id']);
|
551 |
-
|
552 |
-
$current_checksum = $this->getSavedChecksum($table_prefix, $read, $product_model->getId(), $store_id);
|
553 |
-
$new_checksum = $this->calculateChecksum($product_model);
|
554 |
-
} catch (Exception $e) {
|
555 |
-
Mage::log('Exception raised in compareProductsChecksum() on id: '.$product->getId().' -> '.$e->getMessage(), null, 'autocompleteplus.log');
|
556 |
-
$this->ispErrorLog('Exception raised in compareProductsChecksum() on id: '.$product->getId().' -> '.$e->getMessage());
|
557 |
-
|
558 |
-
return 0;
|
559 |
-
}
|
560 |
-
if ($current_checksum == '' || $current_checksum != $new_checksum) {
|
561 |
-
++$num_of_updates;
|
562 |
-
$this->updateSavedProductChecksum($table_prefix, $read, $write, $product_model->getId(), $product_model->getSku(),
|
563 |
-
$store_id, $new_checksum);
|
564 |
-
$this->setUpdateNeededForProduct($read, $write, $product_model->getId(), $product_model->getSku(), $store_id);
|
565 |
-
}
|
566 |
-
}
|
567 |
-
|
568 |
-
return $num_of_updates;
|
569 |
-
}
|
570 |
-
|
571 |
-
public function deleteProductFromTables($read, $write, $table_prefix, $product_id, $store_id)
|
572 |
-
{
|
573 |
-
$dt = strtotime('now');
|
574 |
-
$sku = 'dummy_sku';
|
575 |
-
$sqlFetch = 'SELECT * FROM '.$table_prefix.'autocompleteplus_batches WHERE product_id = ? AND store_id=?';
|
576 |
-
$updates = $read->fetchAll($sqlFetch, array($product_id, $store_id));
|
577 |
-
|
578 |
-
if ($updates && count($updates) != 0) {
|
579 |
-
$sql = 'UPDATE '.$table_prefix.'autocompleteplus_batches SET update_date=?,action=? WHERE product_id = ? AND store_id = ?';
|
580 |
-
$write->query($sql, array($dt, 'remove', $product_id, $store_id));
|
581 |
-
} else {
|
582 |
-
$sql = 'INSERT INTO '.$table_prefix.'autocompleteplus_batches (product_id,store_id,update_date,action,sku) VALUES (?,?,?,?,?)';
|
583 |
-
$write->query($sql, array($product_id, $store_id, $dt, 'remove', $sku));
|
584 |
-
}
|
585 |
-
|
586 |
-
$this->updateDeletedProductChecksum($table_prefix, $read, $write, $product_id, $sku, $store_id);
|
587 |
-
}
|
588 |
-
|
589 |
-
public function ispLog($log)
|
590 |
-
{
|
591 |
-
Mage::log($log, null, 'autocompleteplus.log');
|
592 |
-
}
|
593 |
-
|
594 |
-
public function ispErrorLog($log)
|
595 |
-
{
|
596 |
-
$uuid = $this->getUUID();
|
597 |
-
$site_url = $this->getConfigDataByFullPath('web/unsecure/base_url');
|
598 |
-
$store_id = Mage::app()->getStore()->getStoreId();
|
599 |
-
|
600 |
-
$server_url = $this->server_url.'/magento_logging_error';
|
601 |
-
$request = $server_url.'?uuid='.$uuid.'&site_url='.$site_url.'&store_id='.$store_id.'&msg='.urlencode($log);
|
602 |
-
|
603 |
-
$resp = $this->sendCurl($request);
|
604 |
-
}
|
605 |
-
|
606 |
-
public function getUUID()
|
607 |
-
{
|
608 |
-
return $this->getConfig()->getUUID();
|
609 |
-
}
|
610 |
-
|
611 |
-
/**
|
612 |
-
* Deprecated, use getAuthorizationKey()
|
613 |
-
*/
|
614 |
-
public function getKey()
|
615 |
-
{
|
616 |
-
return $this->getAuthorizationKey();
|
617 |
-
}
|
618 |
-
|
619 |
-
public function getAuthorizationKey()
|
620 |
-
{
|
621 |
-
return $this->getConfig()->getAuthorizationKey();
|
622 |
-
}
|
623 |
-
|
624 |
-
public function getIsReachable()
|
625 |
-
{
|
626 |
-
return $this->getConfig()->isReachable();
|
627 |
-
}
|
628 |
-
|
629 |
-
public function getServerEndPoint()
|
630 |
-
{
|
631 |
-
try {
|
632 |
-
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
633 |
-
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
634 |
-
$_tableprefix = (string) Mage::getConfig()->getTablePrefix();
|
635 |
-
$tblExist = $write->showTableStatus($_tableprefix.'autocompleteplus_config');
|
636 |
-
|
637 |
-
if (!$tblExist) {
|
638 |
-
return '';
|
639 |
-
}
|
640 |
-
|
641 |
-
$sql = 'SELECT * FROM `'.$_tableprefix.'autocompleteplus_config` WHERE `id` =1';
|
642 |
-
$licenseData = $read->fetchAll($sql);
|
643 |
-
if (array_key_exists('server_type', $licenseData[0])) {
|
644 |
-
$key = $licenseData[0]['server_type'];
|
645 |
-
} else {
|
646 |
-
$key = '';
|
647 |
-
}
|
648 |
-
} catch (Exception $e) {
|
649 |
-
$key = '';
|
650 |
-
}
|
651 |
-
|
652 |
-
return $key;
|
653 |
-
}
|
654 |
-
|
655 |
-
public function setServerEndPoint($end_point)
|
656 |
-
{
|
657 |
-
try {
|
658 |
-
$_tableprefix = (string) Mage::getConfig()->getTablePrefix();
|
659 |
-
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
660 |
-
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
661 |
-
$tblExist = $write->showTableStatus($_tableprefix.'autocompleteplus_config');
|
662 |
-
|
663 |
-
if (!$tblExist) {
|
664 |
-
return;
|
665 |
-
}
|
666 |
-
|
667 |
-
$sqlFetch = 'SELECT * FROM '.$_tableprefix.'autocompleteplus_config WHERE id = 1';
|
668 |
-
$updates = $write->fetchAll($sqlFetch);
|
669 |
-
|
670 |
-
if ($updates && count($updates) != 0) {
|
671 |
-
$sql = 'UPDATE '.$_tableprefix.'autocompleteplus_config SET server_type=? WHERE id = 1';
|
672 |
-
$write->query($sql, array($end_point));
|
673 |
-
} else {
|
674 |
-
Mage::log('cant update server_type', null, 'autocompleteplus.log');
|
675 |
-
}
|
676 |
-
} catch (Exception $e) {
|
677 |
-
Mage::log($e->getMessage(), null, 'autocompleteplus.log');
|
678 |
-
}
|
679 |
-
}
|
680 |
-
|
681 |
-
public function getErrormessage()
|
682 |
-
{
|
683 |
-
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
684 |
-
|
685 |
-
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
686 |
-
|
687 |
-
$_tableprefix = (string) Mage::getConfig()->getTablePrefix();
|
688 |
-
|
689 |
-
$tblExist = $write->showTableStatus($_tableprefix.'autocompleteplus_config');
|
690 |
-
|
691 |
-
if (!$tblExist) {
|
692 |
-
return '';
|
693 |
-
}
|
694 |
-
|
695 |
-
$sql = 'SELECT * FROM `'.$_tableprefix.'autocompleteplus_config` WHERE `id` =1';
|
696 |
-
|
697 |
-
$licenseData = $read->fetchAll($sql);
|
698 |
-
|
699 |
-
$errormessage = $licenseData[0]['errormessage'];
|
700 |
-
|
701 |
-
return $errormessage;
|
702 |
-
}
|
703 |
-
|
704 |
-
public function getIfSyncWasInitiated()
|
705 |
-
{
|
706 |
-
$collection = Mage::getModel('autocompleteplus_autosuggest/pusher')->getCollection();
|
707 |
-
|
708 |
-
return $collection->getSize() > 0;
|
709 |
-
}
|
710 |
-
|
711 |
-
public function getPushId()
|
712 |
-
{
|
713 |
-
$collection = Mage::getModel('autocompleteplus_autosuggest/pusher')
|
714 |
-
->getCollection()
|
715 |
-
->addFilter('sent', 0);
|
716 |
-
|
717 |
-
$collection->getSelect()->limit(1);
|
718 |
-
$collection->load();
|
719 |
-
|
720 |
-
return $collection->getLastItem()->getId();
|
721 |
-
}
|
722 |
-
|
723 |
-
public function getPushUrl($id = null)
|
724 |
-
{
|
725 |
-
if ($id == null) {
|
726 |
-
$id = $this->getPushId();
|
727 |
-
}
|
728 |
-
|
729 |
-
$url = Mage::getUrl();
|
730 |
-
|
731 |
-
if (strpos($url, 'index.php') !== false) {
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
//
|
748 |
-
//
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
$
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
$
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
if (
|
858 |
-
|
859 |
-
}
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* InstantSearchPlus (Autosuggest).
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Mage
|
12 |
+
*
|
13 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
17 |
+
{
|
18 |
+
|
19 |
+
const WEBSITES_SCOPE = 'websites';
|
20 |
+
|
21 |
+
const STORES_SCOPE = 'stores';
|
22 |
+
|
23 |
+
const DEFAULT_SCOPE = 'default';
|
24 |
+
|
25 |
+
|
26 |
+
const WEBSITE_ID = 'website_id';
|
27 |
+
|
28 |
+
// private $server_url = 'http://0-2vk.acp-magento.appspot.com';
|
29 |
+
private $server_url = 'http://magento.instantsearchplus.com';
|
30 |
+
|
31 |
+
protected $_authKey;
|
32 |
+
|
33 |
+
public function getServerUrl()
|
34 |
+
{
|
35 |
+
return $this->server_url;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function validateUuid($uuid)
|
39 |
+
{
|
40 |
+
if (strlen($uuid) == 36
|
41 |
+
&& substr_count($uuid, '-') == 4
|
42 |
+
) {
|
43 |
+
return true;
|
44 |
+
}
|
45 |
+
|
46 |
+
return false;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getConfig()
|
50 |
+
{
|
51 |
+
return Mage::getModel('autocompleteplus_autosuggest/config');
|
52 |
+
}
|
53 |
+
|
54 |
+
public function getMageVersion()
|
55 |
+
{
|
56 |
+
return Mage::getVersion();
|
57 |
+
}
|
58 |
+
|
59 |
+
public function getVersion()
|
60 |
+
{
|
61 |
+
return (string) Mage::getConfig()->getModuleConfig('Autocompleteplus_Autosuggest')->version;
|
62 |
+
}
|
63 |
+
|
64 |
+
public function getConfigDataByFullPath($path)
|
65 |
+
{
|
66 |
+
$valsArr = $this->getConfigMultiDataByFullPath($path);
|
67 |
+
|
68 |
+
$value = '';
|
69 |
+
|
70 |
+
if (is_array($valsArr) && count($valsArr) > 0) {
|
71 |
+
$value = array_shift($valsArr);
|
72 |
+
}
|
73 |
+
|
74 |
+
return $value;
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getConfigMultiDataByFullPath($path)
|
78 |
+
{
|
79 |
+
$values = array();
|
80 |
+
|
81 |
+
if (!$rows = Mage::getSingleton('core/config_data')->getCollection()->getItemsByColumnValue('path', $path)) {
|
82 |
+
$conf = Mage::getSingleton('core/config')->init()->getXpath('/config/default/'.$path);
|
83 |
+
$values[] = array_shift($conf);
|
84 |
+
} else {
|
85 |
+
|
86 |
+
foreach ($rows as $row) {
|
87 |
+
$scopeId = $row->getScopeId();
|
88 |
+
|
89 |
+
$rowValue = $row->getValue();
|
90 |
+
|
91 |
+
if ($scopeId != null && $rowValue != null) {
|
92 |
+
$values[$scopeId] = $rowValue;
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
return $values;
|
98 |
+
}
|
99 |
+
|
100 |
+
public function getConfigMultiScopesDataByFullPath($path)
|
101 |
+
{
|
102 |
+
$values = array();
|
103 |
+
|
104 |
+
$rows = Mage::getSingleton('core/config_data')->getCollection()->getItemsByColumnValue('path', $path);
|
105 |
+
|
106 |
+
foreach ($rows as $row) {
|
107 |
+
$scope = $row->getScope();
|
108 |
+
|
109 |
+
$scopeId = $row->getScopeId();
|
110 |
+
|
111 |
+
$rowValue = $row->getValue();
|
112 |
+
|
113 |
+
if ($scope != null && $scopeId != null && $rowValue != null) {
|
114 |
+
|
115 |
+
if (!array_key_exists($scope,$values)) {
|
116 |
+
$values[$scope] = array();
|
117 |
+
}
|
118 |
+
|
119 |
+
$values[$scope][$scopeId] = $rowValue;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
|
124 |
+
return $values;
|
125 |
+
}
|
126 |
+
|
127 |
+
public function sendCurl($command)
|
128 |
+
{
|
129 |
+
if (isset($ch)) {
|
130 |
+
unset($ch);
|
131 |
+
}
|
132 |
+
|
133 |
+
if (function_exists('curl_setopt')) {
|
134 |
+
$ch = curl_init();
|
135 |
+
curl_setopt($ch, CURLOPT_URL, $command);
|
136 |
+
curl_setopt($ch, CURLOPT_HEADER, 0);
|
137 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
138 |
+
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
|
139 |
+
$str = curl_exec($ch);
|
140 |
+
} else {
|
141 |
+
$str = 'failed';
|
142 |
+
}
|
143 |
+
|
144 |
+
return $str;
|
145 |
+
}
|
146 |
+
|
147 |
+
public static function sendPostCurl($command, $data = array(), $cookie_file = 'genCookie.txt')
|
148 |
+
{
|
149 |
+
if (isset($ch)) {
|
150 |
+
unset($ch);
|
151 |
+
}
|
152 |
+
|
153 |
+
if (function_exists('curl_setopt')) {
|
154 |
+
$ch = curl_init();
|
155 |
+
curl_setopt($ch, CURLOPT_URL, $command);
|
156 |
+
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
|
157 |
+
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
|
158 |
+
curl_setopt($ch, CURLOPT_HEADER, 0);
|
159 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
160 |
+
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
|
161 |
+
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20100101 Firefox/21.0');
|
162 |
+
//curl_setopt($ch,CURLOPT_POST,0);
|
163 |
+
if (!empty($data)) {
|
164 |
+
curl_setopt_array($ch, array(
|
165 |
+
CURLOPT_POSTFIELDS => $data,
|
166 |
+
));
|
167 |
+
}
|
168 |
+
|
169 |
+
// curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
170 |
+
// 'Connection: Keep-Alive',
|
171 |
+
// 'Keep-Alive: 800'
|
172 |
+
// ));
|
173 |
+
|
174 |
+
$str = curl_exec($ch);
|
175 |
+
} else {
|
176 |
+
$str = 'failed';
|
177 |
+
}
|
178 |
+
|
179 |
+
return $str;
|
180 |
+
}
|
181 |
+
|
182 |
+
public function prepareGroupedProductPrice($groupedProduct)
|
183 |
+
{
|
184 |
+
$aProductIds = $groupedProduct->getTypeInstance()->getChildrenIds($groupedProduct->getId());
|
185 |
+
|
186 |
+
$prices = array();
|
187 |
+
foreach ($aProductIds as $ids) {
|
188 |
+
foreach ($ids as $id) {
|
189 |
+
try {
|
190 |
+
$aProduct = Mage::getModel('catalog/product')->load($id);
|
191 |
+
$prices[] = $aProduct->getPriceModel()->getPrice($aProduct);
|
192 |
+
} catch (Exception $e) {
|
193 |
+
continue;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
+
krsort($prices);
|
199 |
+
try {
|
200 |
+
if (count($prices) > 0) {
|
201 |
+
$groupedProduct->setPrice($prices[0]);
|
202 |
+
} else {
|
203 |
+
$groupedProduct->setPrice(0);
|
204 |
+
}
|
205 |
+
} catch (Exception $e) {
|
206 |
+
$groupedProduct->setPrice(0);
|
207 |
+
}
|
208 |
+
|
209 |
+
// or you can return price
|
210 |
+
}
|
211 |
+
|
212 |
+
public function getBundlePrice($product)
|
213 |
+
{
|
214 |
+
$optionCol = $product->getTypeInstance(true)
|
215 |
+
->getOptionsCollection($product);
|
216 |
+
$selectionCol = $product->getTypeInstance(true)
|
217 |
+
->getSelectionsCollection(
|
218 |
+
$product->getTypeInstance(true)->getOptionsIds($product),
|
219 |
+
$product
|
220 |
+
);
|
221 |
+
$optionCol->appendSelections($selectionCol);
|
222 |
+
$price = $product->getPrice();
|
223 |
+
|
224 |
+
foreach ($optionCol as $option) {
|
225 |
+
if ($option->required) {
|
226 |
+
$selections = $option->getSelections();
|
227 |
+
$selPricesArr = array();
|
228 |
+
|
229 |
+
if (is_array($selections)) {
|
230 |
+
foreach ($selections as $s) {
|
231 |
+
$selPricesArr[] = $s->price;
|
232 |
+
}
|
233 |
+
|
234 |
+
$minPrice = min($selPricesArr);
|
235 |
+
|
236 |
+
if ($product->getSpecialPrice() > 0) {
|
237 |
+
$minPrice *= $product->getSpecialPrice() / 100;
|
238 |
+
}
|
239 |
+
|
240 |
+
$price += round($minPrice, 2);
|
241 |
+
}
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
return $price;
|
246 |
+
}
|
247 |
+
|
248 |
+
public function getMultiStoreDataJson()
|
249 |
+
{
|
250 |
+
$websites = Mage::getModel('core/website')->getCollection();
|
251 |
+
$mage = Mage::getVersion();
|
252 |
+
$ext = Mage::helper('autocompleteplus_autosuggest')->getVersion();
|
253 |
+
$version = array('mage' => $mage, 'ext' => $ext);
|
254 |
+
|
255 |
+
//getting site url
|
256 |
+
$url = $this->getConfigDataByFullPath('web/unsecure/base_url');
|
257 |
+
|
258 |
+
//getting site owner email
|
259 |
+
$storeMail = $this->getConfigDataByFullPath('autocompleteplus/config/store_email');
|
260 |
+
|
261 |
+
if (!$storeMail) {
|
262 |
+
$storeMail = $this->getConfigDataByFullPath('trans_email/ident_general/email');
|
263 |
+
}
|
264 |
+
|
265 |
+
$storesArr = array();
|
266 |
+
foreach ($websites as $website) {
|
267 |
+
$code = $website->getCode();
|
268 |
+
$stores = $website->getStores();
|
269 |
+
foreach ($stores as $store) {
|
270 |
+
$storesArr[$store->getStoreId()] = $store->getData();
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
if (count($storesArr) == 1) {
|
275 |
+
try {
|
276 |
+
$dataArr = array(
|
277 |
+
'stores' => array_pop($storesArr),
|
278 |
+
'version' => $version,
|
279 |
+
);
|
280 |
+
} catch (Exception $e) {
|
281 |
+
$dataArr = array(
|
282 |
+
'stores' => array(),
|
283 |
+
'version' => $version,
|
284 |
+
);
|
285 |
+
}
|
286 |
+
|
287 |
+
$dataArr['site'] = $url;
|
288 |
+
$dataArr['email'] = $storeMail;
|
289 |
+
|
290 |
+
$multistoreJson = json_encode($dataArr);
|
291 |
+
} else {
|
292 |
+
$multistoreData = $this->_createMultiStoreJson($storesArr);
|
293 |
+
|
294 |
+
$multistoreDataByScope = $this->_createMultiStoreByScopeJson($storesArr);
|
295 |
+
|
296 |
+
$dataArr = array(
|
297 |
+
'stores' => $multistoreData,
|
298 |
+
'stores2' => $multistoreDataByScope,
|
299 |
+
'version' => $version,
|
300 |
+
);
|
301 |
+
|
302 |
+
$dataArr['site'] = $url;
|
303 |
+
$dataArr['email'] = $storeMail;
|
304 |
+
$multistoreJson = json_encode($dataArr);
|
305 |
+
}
|
306 |
+
|
307 |
+
return $multistoreJson;
|
308 |
+
}
|
309 |
+
|
310 |
+
public function getExtensionConflict($all_conflicts = false)
|
311 |
+
{
|
312 |
+
$all_rewrite_classes = array();
|
313 |
+
$node_type_list = array('model', 'helper', 'block');
|
314 |
+
|
315 |
+
foreach ($node_type_list as $node_type) {
|
316 |
+
foreach (Mage::getConfig()->getNode('modules')->children() as $name => $module) {
|
317 |
+
if ($module->codePool == 'core' || $module->active != 'true') {
|
318 |
+
continue;
|
319 |
+
}
|
320 |
+
$config_file_path = Mage::getConfig()->getModuleDir('etc', $name).DS.'config.xml';
|
321 |
+
$config = new Varien_Simplexml_Config();
|
322 |
+
$config->loadString('<config/>');
|
323 |
+
$config->loadFile($config_file_path);
|
324 |
+
$config->extend($config, true);
|
325 |
+
|
326 |
+
$nodes = $config->getNode()->global->{$node_type.'s'};
|
327 |
+
if (!$nodes) {
|
328 |
+
continue;
|
329 |
+
}
|
330 |
+
foreach ($nodes->children() as $node_name => $config) {
|
331 |
+
if ($config->rewrite) { // there is rewrite for current config
|
332 |
+
foreach ($config->rewrite->children() as $class_tag => $derived_class) {
|
333 |
+
$base_class_name = $this->_getMageBaseClass($node_type, $node_name, $class_tag);
|
334 |
+
|
335 |
+
$lead_derived_class = '';
|
336 |
+
$conf = Mage::getConfig()->getNode()->global->{$node_type.'s'}->{$node_name};
|
337 |
+
if (isset($conf->rewrite->$class_tag)) {
|
338 |
+
$lead_derived_class = (string) $conf->rewrite->$class_tag;
|
339 |
+
}
|
340 |
+
if ($derived_class == '') {
|
341 |
+
$derived_class = $lead_derived_class;
|
342 |
+
}
|
343 |
+
|
344 |
+
if (empty($all_rewrite_classes[$base_class_name])) {
|
345 |
+
$all_rewrite_classes[$base_class_name] = array(
|
346 |
+
'derived' => array((string) $derived_class),
|
347 |
+
'lead' => (string) $lead_derived_class,
|
348 |
+
'tag' => $class_tag,
|
349 |
+
'name' => array((string) $name),
|
350 |
+
);
|
351 |
+
} else {
|
352 |
+
array_push($all_rewrite_classes[$base_class_name]['derived'], (string) $derived_class);
|
353 |
+
array_push($all_rewrite_classes[$base_class_name]['name'], (string) $name);
|
354 |
+
}
|
355 |
+
}
|
356 |
+
}
|
357 |
+
}
|
358 |
+
}
|
359 |
+
}
|
360 |
+
if ($all_conflicts) {
|
361 |
+
return $all_rewrite_classes;
|
362 |
+
}
|
363 |
+
|
364 |
+
$isp_rewrite_classes = array();
|
365 |
+
$isp_module_name = 'Autocompleteplus_Autosuggest';
|
366 |
+
foreach ($all_rewrite_classes as $base => $conflict_info) {
|
367 |
+
if (in_array($isp_module_name, $conflict_info['name'])) { // if isp extension rewrite this base class
|
368 |
+
if (count($conflict_info['derived']) > 1) { // more then 1 class rewrite this base class => there is a conflict
|
369 |
+
$isp_rewrite_classes[$base] = $conflict_info;
|
370 |
+
}
|
371 |
+
}
|
372 |
+
}
|
373 |
+
|
374 |
+
return $isp_rewrite_classes;
|
375 |
+
}
|
376 |
+
|
377 |
+
protected function _getMageBaseClass($node_type, $node_name, $class_tag)
|
378 |
+
{
|
379 |
+
$config = Mage::getConfig()->getNode()->global->{$node_type.'s'}->$node_name;
|
380 |
+
|
381 |
+
if (!empty($config)) {
|
382 |
+
$className = $config->getClassName();
|
383 |
+
}
|
384 |
+
if (empty($className)) {
|
385 |
+
$className = 'mage_'.$node_name.'_'.$node_type;
|
386 |
+
}
|
387 |
+
if (!empty($class_tag)) {
|
388 |
+
$className .= '_'.$class_tag;
|
389 |
+
}
|
390 |
+
|
391 |
+
return uc_words($className);
|
392 |
+
}
|
393 |
+
|
394 |
+
/**
|
395 |
+
* Checksum functionality.
|
396 |
+
*/
|
397 |
+
public function isChecksumTableExists()
|
398 |
+
{
|
399 |
+
$table_prefix = (string) Mage::getConfig()->getTablePrefix();
|
400 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
401 |
+
if ($read->showTableStatus($table_prefix.'autocompleteplus_checksum')) {
|
402 |
+
return true;
|
403 |
+
} else {
|
404 |
+
return false;
|
405 |
+
}
|
406 |
+
}
|
407 |
+
|
408 |
+
public function calculateChecksum($product)
|
409 |
+
{
|
410 |
+
$product_id = $product->getId();
|
411 |
+
$product_title = $product->getName();
|
412 |
+
$product_description = $product->getDescription();
|
413 |
+
$product_short_desc = $product->getShortDescription();
|
414 |
+
$product_url = $product->getUrlPath(); //Mage::helper('catalog/product')->getProductUrl($product_id); | $product->getProductUrl()
|
415 |
+
$product_visibility = $product->getVisibility();
|
416 |
+
$product_in_stock = $product->isInStock();
|
417 |
+
$product_price = (float) $product->getPrice();
|
418 |
+
try {
|
419 |
+
$product_thumb_url = '/'.$product->getImage();
|
420 |
+
|
421 |
+
// $product_thumb_url = $product->getThumbnailUrl(); //Mage::helper('catalog/image')->init($product, 'thumbnail');
|
422 |
+
// $thumb_pattern = '/\/[^\/]+(?![^\/]*\/)/';
|
423 |
+
// if (preg_match($thumb_pattern, $product_thumb_url, $matches) && count($matches) > 0){
|
424 |
+
// $product_thumb_url = $matches[0];
|
425 |
+
// } else {
|
426 |
+
// $product_thumb_url = '';
|
427 |
+
// }
|
428 |
+
} catch (Exception $e) {
|
429 |
+
$product_thumb_url = '';
|
430 |
+
}
|
431 |
+
$product_type = $product->getTypeID();
|
432 |
+
|
433 |
+
$checksum_string = $product_id.$product_title.$product_description.$product_short_desc.$product_url.
|
434 |
+
$product_visibility.$product_in_stock.$product_price.$product_thumb_url.$product_type;
|
435 |
+
|
436 |
+
$checksum_md5 = md5($checksum_string);
|
437 |
+
|
438 |
+
return $checksum_md5;
|
439 |
+
}
|
440 |
+
|
441 |
+
public function getSavedChecksum($table_prefix, $read, $product_id, $store_id)
|
442 |
+
{
|
443 |
+
$sql_fetch = 'SELECT checksum FROM '.$table_prefix.'autocompleteplus_checksum WHERE identifier=? AND store_id=?';
|
444 |
+
$updates = $read->fetchAll($sql_fetch, array($product_id, $store_id));
|
445 |
+
if ($updates && (count($updates) != 0)) {
|
446 |
+
return $updates[0]['checksum'];
|
447 |
+
} else {
|
448 |
+
return '';
|
449 |
+
}
|
450 |
+
}
|
451 |
+
|
452 |
+
public function updateSavedProductChecksum($product_id, $sku, $store_id, $checksum)
|
453 |
+
{
|
454 |
+
return;
|
455 |
+
if ($product_id == null || $sku == null) {
|
456 |
+
return;
|
457 |
+
}
|
458 |
+
$checksumModel = Mage::getModel('autocompleteplus_autosuggest/checksum');
|
459 |
+
$collection = $checksumModel->getCollection()
|
460 |
+
->addFieldToFilter('identifier', $product_id)
|
461 |
+
->addFieldToFilter('store_id', $store_id);
|
462 |
+
|
463 |
+
$row = $collection->getFirstItem();
|
464 |
+
|
465 |
+
if ($row && $collection->getSize() > 0) {
|
466 |
+
if ($row->getChecksum() != $checksum) {
|
467 |
+
$row->setChecksum($checksum)->save();
|
468 |
+
}
|
469 |
+
} else {
|
470 |
+
$checksumModel->setIdentifier($product_id)
|
471 |
+
->setSku($sku)
|
472 |
+
->setStoreId($store_id)
|
473 |
+
->setChecksum($checksum)
|
474 |
+
->save();
|
475 |
+
}
|
476 |
+
}
|
477 |
+
|
478 |
+
public function updateDeletedProductChecksum($table_prefix, $read, $write, $product_id, $sku, $store_id)
|
479 |
+
{
|
480 |
+
return;
|
481 |
+
if ($product_id == null) {
|
482 |
+
return;
|
483 |
+
}
|
484 |
+
|
485 |
+
$checksums = Mage::getModel('autocompleteplus_autosuggest/checksum')->getCollection()
|
486 |
+
->addFieldToFilter('identifier', $product_id)
|
487 |
+
->addFieldToFilter('store_id', $store_id);
|
488 |
+
|
489 |
+
if ($checksums->getSize() > 0) {
|
490 |
+
// @codingStandardsIgnoreLine
|
491 |
+
$checksum = $checksums->getFirstItem();
|
492 |
+
$checksum->delete();
|
493 |
+
}
|
494 |
+
}
|
495 |
+
|
496 |
+
private function setUpdateNeededForProduct($read, $write, $product_id, $product_sku, $store_id)
|
497 |
+
{
|
498 |
+
if ($product_id == null) {
|
499 |
+
return;
|
500 |
+
}
|
501 |
+
if ($product_sku == null) {
|
502 |
+
$product_sku = 'dummy_sku';
|
503 |
+
}
|
504 |
+
try {
|
505 |
+
$table_prefix = (string) Mage::getConfig()->getTablePrefix();
|
506 |
+
$is_table_exist = $write->showTableStatus($table_prefix.'autocompleteplus_batches');
|
507 |
+
if (!$is_table_exist) { // table not exists
|
508 |
+
return;
|
509 |
+
}
|
510 |
+
|
511 |
+
$sql_fetch = 'SELECT * FROM '.$table_prefix.'autocompleteplus_batches WHERE product_id=? AND store_id=?';
|
512 |
+
$updates = $read->fetchAll($sql_fetch, array($product_id, $store_id));
|
513 |
+
|
514 |
+
if ($updates && (count($updates) != 0)) {
|
515 |
+
$sql = 'UPDATE '.$table_prefix.'autocompleteplus_batches SET update_date=?,action=? WHERE product_id=? AND store_id=?';
|
516 |
+
$write->query($sql, array(strtotime('now'), 'update', $product_id, $store_id));
|
517 |
+
} else {
|
518 |
+
$sql = 'INSERT INTO '.$table_prefix.'autocompleteplus_batches (product_id,store_id,update_date,action,sku) VALUES (?,?,?,?,?)';
|
519 |
+
$write->query($sql, array($product_id, $store_id, strtotime('now'), 'update', $product_sku));
|
520 |
+
}
|
521 |
+
} catch (Exception $e) {
|
522 |
+
Mage::log('Exception raised in setUpdateNeededForProduct() - '.$e->getMessage(), null, 'autocompleteplus.log');
|
523 |
+
$this->ispErrorLog('Exception raised in setUpdateNeededForProduct() - '.$e->getMessage());
|
524 |
+
}
|
525 |
+
}
|
526 |
+
|
527 |
+
public function compareProductsChecksum($from, $count, $store_id = null)
|
528 |
+
{
|
529 |
+
$num_of_updates = 0;
|
530 |
+
if (!$this->isChecksumTableExists()) {
|
531 |
+
return;
|
532 |
+
}
|
533 |
+
|
534 |
+
$products = Mage::getModel('catalog/product')->getCollection();
|
535 |
+
if ($store_id) {
|
536 |
+
$products->addStoreFilter($store_id);
|
537 |
+
}
|
538 |
+
$products->getSelect()->limit($count, $from);
|
539 |
+
$products->load();
|
540 |
+
|
541 |
+
$table_prefix = (string) Mage::getConfig()->getTablePrefix();
|
542 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
543 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
544 |
+
|
545 |
+
foreach ($products as $product) {
|
546 |
+
try {
|
547 |
+
$product_collection_data = $product->getData();
|
548 |
+
$product_model = Mage::getModel('catalog/product')
|
549 |
+
->setStore($store_id)->setStoreId($store_id)
|
550 |
+
->load($product_collection_data['entity_id']);
|
551 |
+
|
552 |
+
$current_checksum = $this->getSavedChecksum($table_prefix, $read, $product_model->getId(), $store_id);
|
553 |
+
$new_checksum = $this->calculateChecksum($product_model);
|
554 |
+
} catch (Exception $e) {
|
555 |
+
Mage::log('Exception raised in compareProductsChecksum() on id: '.$product->getId().' -> '.$e->getMessage(), null, 'autocompleteplus.log');
|
556 |
+
$this->ispErrorLog('Exception raised in compareProductsChecksum() on id: '.$product->getId().' -> '.$e->getMessage());
|
557 |
+
|
558 |
+
return 0;
|
559 |
+
}
|
560 |
+
if ($current_checksum == '' || $current_checksum != $new_checksum) {
|
561 |
+
++$num_of_updates;
|
562 |
+
$this->updateSavedProductChecksum($table_prefix, $read, $write, $product_model->getId(), $product_model->getSku(),
|
563 |
+
$store_id, $new_checksum);
|
564 |
+
$this->setUpdateNeededForProduct($read, $write, $product_model->getId(), $product_model->getSku(), $store_id);
|
565 |
+
}
|
566 |
+
}
|
567 |
+
|
568 |
+
return $num_of_updates;
|
569 |
+
}
|
570 |
+
|
571 |
+
public function deleteProductFromTables($read, $write, $table_prefix, $product_id, $store_id)
|
572 |
+
{
|
573 |
+
$dt = strtotime('now');
|
574 |
+
$sku = 'dummy_sku';
|
575 |
+
$sqlFetch = 'SELECT * FROM '.$table_prefix.'autocompleteplus_batches WHERE product_id = ? AND store_id=?';
|
576 |
+
$updates = $read->fetchAll($sqlFetch, array($product_id, $store_id));
|
577 |
+
|
578 |
+
if ($updates && count($updates) != 0) {
|
579 |
+
$sql = 'UPDATE '.$table_prefix.'autocompleteplus_batches SET update_date=?,action=? WHERE product_id = ? AND store_id = ?';
|
580 |
+
$write->query($sql, array($dt, 'remove', $product_id, $store_id));
|
581 |
+
} else {
|
582 |
+
$sql = 'INSERT INTO '.$table_prefix.'autocompleteplus_batches (product_id,store_id,update_date,action,sku) VALUES (?,?,?,?,?)';
|
583 |
+
$write->query($sql, array($product_id, $store_id, $dt, 'remove', $sku));
|
584 |
+
}
|
585 |
+
|
586 |
+
$this->updateDeletedProductChecksum($table_prefix, $read, $write, $product_id, $sku, $store_id);
|
587 |
+
}
|
588 |
+
|
589 |
+
public function ispLog($log)
|
590 |
+
{
|
591 |
+
Mage::log($log, null, 'autocompleteplus.log');
|
592 |
+
}
|
593 |
+
|
594 |
+
public function ispErrorLog($log)
|
595 |
+
{
|
596 |
+
$uuid = $this->getUUID();
|
597 |
+
$site_url = $this->getConfigDataByFullPath('web/unsecure/base_url');
|
598 |
+
$store_id = Mage::app()->getStore()->getStoreId();
|
599 |
+
|
600 |
+
$server_url = $this->server_url.'/magento_logging_error';
|
601 |
+
$request = $server_url.'?uuid='.$uuid.'&site_url='.$site_url.'&store_id='.$store_id.'&msg='.urlencode($log);
|
602 |
+
|
603 |
+
$resp = $this->sendCurl($request);
|
604 |
+
}
|
605 |
+
|
606 |
+
public function getUUID()
|
607 |
+
{
|
608 |
+
return $this->getConfig()->getUUID();
|
609 |
+
}
|
610 |
+
|
611 |
+
/**
|
612 |
+
* Deprecated, use getAuthorizationKey()
|
613 |
+
*/
|
614 |
+
public function getKey()
|
615 |
+
{
|
616 |
+
return $this->getAuthorizationKey();
|
617 |
+
}
|
618 |
+
|
619 |
+
public function getAuthorizationKey()
|
620 |
+
{
|
621 |
+
return $this->getConfig()->getAuthorizationKey();
|
622 |
+
}
|
623 |
+
|
624 |
+
public function getIsReachable()
|
625 |
+
{
|
626 |
+
return $this->getConfig()->isReachable();
|
627 |
+
}
|
628 |
+
|
629 |
+
public function getServerEndPoint()
|
630 |
+
{
|
631 |
+
try {
|
632 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
633 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
634 |
+
$_tableprefix = (string) Mage::getConfig()->getTablePrefix();
|
635 |
+
$tblExist = $write->showTableStatus($_tableprefix.'autocompleteplus_config');
|
636 |
+
|
637 |
+
if (!$tblExist) {
|
638 |
+
return '';
|
639 |
+
}
|
640 |
+
|
641 |
+
$sql = 'SELECT * FROM `'.$_tableprefix.'autocompleteplus_config` WHERE `id` =1';
|
642 |
+
$licenseData = $read->fetchAll($sql);
|
643 |
+
if (array_key_exists('server_type', $licenseData[0])) {
|
644 |
+
$key = $licenseData[0]['server_type'];
|
645 |
+
} else {
|
646 |
+
$key = '';
|
647 |
+
}
|
648 |
+
} catch (Exception $e) {
|
649 |
+
$key = '';
|
650 |
+
}
|
651 |
+
|
652 |
+
return $key;
|
653 |
+
}
|
654 |
+
|
655 |
+
public function setServerEndPoint($end_point)
|
656 |
+
{
|
657 |
+
try {
|
658 |
+
$_tableprefix = (string) Mage::getConfig()->getTablePrefix();
|
659 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
660 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
661 |
+
$tblExist = $write->showTableStatus($_tableprefix.'autocompleteplus_config');
|
662 |
+
|
663 |
+
if (!$tblExist) {
|
664 |
+
return;
|
665 |
+
}
|
666 |
+
|
667 |
+
$sqlFetch = 'SELECT * FROM '.$_tableprefix.'autocompleteplus_config WHERE id = 1';
|
668 |
+
$updates = $write->fetchAll($sqlFetch);
|
669 |
+
|
670 |
+
if ($updates && count($updates) != 0) {
|
671 |
+
$sql = 'UPDATE '.$_tableprefix.'autocompleteplus_config SET server_type=? WHERE id = 1';
|
672 |
+
$write->query($sql, array($end_point));
|
673 |
+
} else {
|
674 |
+
Mage::log('cant update server_type', null, 'autocompleteplus.log');
|
675 |
+
}
|
676 |
+
} catch (Exception $e) {
|
677 |
+
Mage::log($e->getMessage(), null, 'autocompleteplus.log');
|
678 |
+
}
|
679 |
+
}
|
680 |
+
|
681 |
+
public function getErrormessage()
|
682 |
+
{
|
683 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
684 |
+
|
685 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
686 |
+
|
687 |
+
$_tableprefix = (string) Mage::getConfig()->getTablePrefix();
|
688 |
+
|
689 |
+
$tblExist = $write->showTableStatus($_tableprefix.'autocompleteplus_config');
|
690 |
+
|
691 |
+
if (!$tblExist) {
|
692 |
+
return '';
|
693 |
+
}
|
694 |
+
|
695 |
+
$sql = 'SELECT * FROM `'.$_tableprefix.'autocompleteplus_config` WHERE `id` =1';
|
696 |
+
|
697 |
+
$licenseData = $read->fetchAll($sql);
|
698 |
+
|
699 |
+
$errormessage = $licenseData[0]['errormessage'];
|
700 |
+
|
701 |
+
return $errormessage;
|
702 |
+
}
|
703 |
+
|
704 |
+
public function getIfSyncWasInitiated()
|
705 |
+
{
|
706 |
+
$collection = Mage::getModel('autocompleteplus_autosuggest/pusher')->getCollection();
|
707 |
+
|
708 |
+
return $collection->getSize() > 0;
|
709 |
+
}
|
710 |
+
|
711 |
+
public function getPushId()
|
712 |
+
{
|
713 |
+
$collection = Mage::getModel('autocompleteplus_autosuggest/pusher')
|
714 |
+
->getCollection()
|
715 |
+
->addFilter('sent', 0);
|
716 |
+
|
717 |
+
$collection->getSelect()->limit(1);
|
718 |
+
$collection->load();
|
719 |
+
|
720 |
+
return $collection->getLastItem()->getId();
|
721 |
+
}
|
722 |
+
|
723 |
+
public function getPushUrl($id = null)
|
724 |
+
{
|
725 |
+
if ($id == null) {
|
726 |
+
$id = $this->getPushId();
|
727 |
+
}
|
728 |
+
|
729 |
+
$url = Mage::getUrl();
|
730 |
+
|
731 |
+
if (strpos($url, 'index.php') !== false) {
|
732 |
+
|
733 |
+
if (substr($url, -1) != '/') {
|
734 |
+
$url.= '/';
|
735 |
+
}
|
736 |
+
|
737 |
+
$url = $url.'autocompleteplus/products/pushbulk/pushid/'.$id;
|
738 |
+
} else {
|
739 |
+
$url = $url.'index.php/autocompleteplus/products/pushbulk/pushid/'.$id;
|
740 |
+
}
|
741 |
+
|
742 |
+
return $url;
|
743 |
+
}
|
744 |
+
|
745 |
+
public function escapeXml($xml)
|
746 |
+
{
|
747 |
+
// $pairs = array(
|
748 |
+
// "\x03" => "",
|
749 |
+
// "\x05" => "",
|
750 |
+
// "\x0E" => "",
|
751 |
+
// "\x16" => "",
|
752 |
+
// );
|
753 |
+
// $xml = strtr($xml, $pairs);
|
754 |
+
|
755 |
+
$xml = preg_replace('/[\x00-\x1f]/', '', $xml);
|
756 |
+
|
757 |
+
return $xml;
|
758 |
+
}
|
759 |
+
|
760 |
+
/**
|
761 |
+
* Get the session cookie value
|
762 |
+
* protected with a salt (the store encryption key).
|
763 |
+
*
|
764 |
+
* @return string
|
765 |
+
*/
|
766 |
+
public function getSessionId()
|
767 |
+
{
|
768 |
+
return md5(Mage::app()->getCookie()->get('frontend').$this->_getEncryptionKey());
|
769 |
+
}
|
770 |
+
|
771 |
+
/**
|
772 |
+
* Return encryption key in Magento to use as salt
|
773 |
+
* Requires getting from configNode so that it is backward
|
774 |
+
* compatible with later versions.
|
775 |
+
*
|
776 |
+
* @return string
|
777 |
+
*/
|
778 |
+
protected function _getEncryptionKey()
|
779 |
+
{
|
780 |
+
return (string) Mage::getConfig()->getNode('global/crypt/key');
|
781 |
+
}
|
782 |
+
|
783 |
+
/**
|
784 |
+
* @param $storesArr
|
785 |
+
* @param $multistoreData
|
786 |
+
* @return array
|
787 |
+
*/
|
788 |
+
protected function _createMultiStoreByScopeJson($storesArr)
|
789 |
+
{
|
790 |
+
$multistoreData = array();
|
791 |
+
$storeComplete = array();
|
792 |
+
|
793 |
+
$storeUrls = $this->getConfigMultiScopesDataByFullPath('web/unsecure/base_url');
|
794 |
+
$locales = $this->getConfigMultiScopesDataByFullPath('general/locale/code');
|
795 |
+
$useStoreCode = $this->getConfigDataByFullPath('web/url/use_store');
|
796 |
+
|
797 |
+
foreach ($storesArr as $storeId => $value) {
|
798 |
+
if (!$value['is_active']) {
|
799 |
+
continue;
|
800 |
+
}
|
801 |
+
|
802 |
+
$storeComplete = $value;
|
803 |
+
|
804 |
+
if (array_key_exists(self::STORES_SCOPE, $locales) &&
|
805 |
+
array_key_exists($storeId, $locales[self::STORES_SCOPE]))
|
806 |
+
{
|
807 |
+
$storeComplete['lang'] = $locales[self::STORES_SCOPE][$storeId];
|
808 |
+
} elseif (array_key_exists(self::WEBSITES_SCOPE, $locales) &&
|
809 |
+
array_key_exists($storeComplete[self::WEBSITE_ID],$locales[self::WEBSITES_SCOPE]))
|
810 |
+
{
|
811 |
+
$storeComplete['lang'] = $locales[self::WEBSITES_SCOPE][$storeComplete[self::WEBSITE_ID]];
|
812 |
+
}else if (array_key_exists(self::DEFAULT_SCOPE, $locales) &&
|
813 |
+
array_key_exists(0,$locales[self::DEFAULT_SCOPE]))
|
814 |
+
{
|
815 |
+
$storeComplete['lang'] = $locales[self::DEFAULT_SCOPE][0];
|
816 |
+
}
|
817 |
+
|
818 |
+
|
819 |
+
if (!$useStoreCode) {
|
820 |
+
if (array_key_exists(self::STORES_SCOPE, $storeUrls) &&
|
821 |
+
array_key_exists($storeId, $storeUrls[self::STORES_SCOPE]))
|
822 |
+
{
|
823 |
+
$storeComplete['url'] = $storeUrls[self::STORES_SCOPE][$storeId];
|
824 |
+
} elseif (array_key_exists(self::WEBSITES_SCOPE, $storeUrls) &&
|
825 |
+
array_key_exists($storeComplete[self::WEBSITE_ID],$storeUrls[self::WEBSITES_SCOPE]))
|
826 |
+
{
|
827 |
+
$storeComplete['url'] = $storeUrls[self::WEBSITES_SCOPE][$storeComplete[self::WEBSITE_ID]];
|
828 |
+
}else if (array_key_exists(self::DEFAULT_SCOPE, $storeUrls) &&
|
829 |
+
array_key_exists(0,$storeUrls[self::DEFAULT_SCOPE]))
|
830 |
+
{
|
831 |
+
$storeComplete['url'] = $storeUrls[self::DEFAULT_SCOPE][0];
|
832 |
+
}
|
833 |
+
} else {
|
834 |
+
$storeComplete['url'] = $storeUrls[0] . $value['code'];
|
835 |
+
}
|
836 |
+
|
837 |
+
$multistoreData[] = $storeComplete;
|
838 |
+
}
|
839 |
+
return $multistoreData;
|
840 |
+
}
|
841 |
+
|
842 |
+
/**
|
843 |
+
* @param $storesArr
|
844 |
+
* @param $multistoreData
|
845 |
+
* @return array
|
846 |
+
*/
|
847 |
+
protected function _createMultiStoreJson($storesArr)
|
848 |
+
{
|
849 |
+
$multistoreData = array();
|
850 |
+
$storeComplete = array();
|
851 |
+
|
852 |
+
$storeUrls = $this->getConfigMultiDataByFullPath('web/unsecure/base_url');
|
853 |
+
$locales = $this->getConfigMultiDataByFullPath('general/locale/code');
|
854 |
+
$useStoreCode = $this->getConfigDataByFullPath('web/url/use_store');
|
855 |
+
|
856 |
+
foreach ($storesArr as $key => $value) {
|
857 |
+
if (!$value['is_active']) {
|
858 |
+
continue;
|
859 |
+
}
|
860 |
+
|
861 |
+
$storeComplete = $value;
|
862 |
+
if (array_key_exists($key, $locales)) {
|
863 |
+
$storeComplete['lang'] = $locales[$key];
|
864 |
+
} else {
|
865 |
+
$storeComplete['lang'] = $locales[0];
|
866 |
+
}
|
867 |
+
|
868 |
+
if (array_key_exists($key, $storeUrls)) {
|
869 |
+
$storeComplete['url'] = $storeUrls[$key];
|
870 |
+
} else {
|
871 |
+
$storeComplete['url'] = $storeUrls[0];
|
872 |
+
}
|
873 |
+
|
874 |
+
if ($useStoreCode) {
|
875 |
+
$storeComplete['url'] = $storeUrls[0] . $value['code'];
|
876 |
+
}
|
877 |
+
|
878 |
+
$multistoreData[] = $storeComplete;
|
879 |
+
}
|
880 |
+
return $multistoreData;
|
881 |
+
}
|
882 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Adminhtml/Attributes.php
CHANGED
@@ -1,58 +1,58 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* InstantSearchPlus (Autosuggest).
|
5 |
-
*
|
6 |
-
* NOTICE OF LICENSE
|
7 |
-
*
|
8 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
-
* that is available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
*
|
12 |
-
* @category Mage
|
13 |
-
*
|
14 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
15 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
-
*/
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Used in creating options for Yes|No config value selection.
|
20 |
-
*/
|
21 |
-
class Autocompleteplus_Autosuggest_Model_Adminhtml_Attributes
|
22 |
-
{
|
23 |
-
public $fields = array();
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Options getter.
|
27 |
-
*
|
28 |
-
* @return array
|
29 |
-
*/
|
30 |
-
public function toOptionArray()
|
31 |
-
{
|
32 |
-
$this->fields = $this->getOptions();
|
33 |
-
|
34 |
-
return $this->fields;
|
35 |
-
}
|
36 |
-
|
37 |
-
public function getOptions()
|
38 |
-
{
|
39 |
-
$entityType = Mage::getModel('catalog/product')->getResource()->getEntityType();
|
40 |
-
$entityTypeId = $entityType->getId();
|
41 |
-
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
|
42 |
-
->setEntityTypeFilter($entityTypeId)
|
43 |
-
->getData();
|
44 |
-
|
45 |
-
$result = array();
|
46 |
-
$result[] = array('value' => '', 'label' => 'Choose an attribute');
|
47 |
-
|
48 |
-
foreach ($attributeInfo as $_key => $_value) {
|
49 |
-
if (isset($_value['frontend_label']) && ($_value['frontend_label'] != '')) {
|
50 |
-
$result[] = array('value' => $_value['attribute_code'], 'label' => $_value['frontend_label']);
|
51 |
-
} else {
|
52 |
-
$result[] = array('value' => $_value['attribute_code'], 'label' => $_value['attribute_code']);
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
return $result;
|
57 |
-
}
|
58 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* InstantSearchPlus (Autosuggest).
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* @category Mage
|
13 |
+
*
|
14 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Used in creating options for Yes|No config value selection.
|
20 |
+
*/
|
21 |
+
class Autocompleteplus_Autosuggest_Model_Adminhtml_Attributes
|
22 |
+
{
|
23 |
+
public $fields = array();
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Options getter.
|
27 |
+
*
|
28 |
+
* @return array
|
29 |
+
*/
|
30 |
+
public function toOptionArray()
|
31 |
+
{
|
32 |
+
$this->fields = $this->getOptions();
|
33 |
+
|
34 |
+
return $this->fields;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getOptions()
|
38 |
+
{
|
39 |
+
$entityType = Mage::getModel('catalog/product')->getResource()->getEntityType();
|
40 |
+
$entityTypeId = $entityType->getId();
|
41 |
+
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
|
42 |
+
->setEntityTypeFilter($entityTypeId)
|
43 |
+
->getData();
|
44 |
+
|
45 |
+
$result = array();
|
46 |
+
$result[] = array('value' => '', 'label' => 'Choose an attribute');
|
47 |
+
|
48 |
+
foreach ($attributeInfo as $_key => $_value) {
|
49 |
+
if (isset($_value['frontend_label']) && ($_value['frontend_label'] != '')) {
|
50 |
+
$result[] = array('value' => $_value['attribute_code'], 'label' => $_value['frontend_label']);
|
51 |
+
} else {
|
52 |
+
$result[] = array('value' => $_value['attribute_code'], 'label' => $_value['attribute_code']);
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
return $result;
|
57 |
+
}
|
58 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Api.php
CHANGED
@@ -1,50 +1,50 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Api extends Mage_Api_Model_Resource_Abstract
|
4 |
-
{
|
5 |
-
protected function _getConfig()
|
6 |
-
{
|
7 |
-
return Mage::getModel('autocompleteplus_autosuggest/config');
|
8 |
-
}
|
9 |
-
|
10 |
-
public function setLayeredSearchOn($scope, $scopeId)
|
11 |
-
{
|
12 |
-
try {
|
13 |
-
$this->_getConfig()->enableLayeredNavigation($scope, $scopeId);
|
14 |
-
Mage::app()->getCacheInstance()->cleanType('config');
|
15 |
-
} catch (Exception $e) {
|
16 |
-
Mage::logException($e);
|
17 |
-
|
18 |
-
return $e->getMessage();
|
19 |
-
}
|
20 |
-
|
21 |
-
return 'Done';
|
22 |
-
}
|
23 |
-
|
24 |
-
public function setLayeredSearchOff($scope, $scopeId)
|
25 |
-
{
|
26 |
-
try {
|
27 |
-
$this->_getConfig()->disableLayeredNavigation($scope, $scopeId);
|
28 |
-
Mage::app()->getCacheInstance()->cleanType('config');
|
29 |
-
} catch (Exception $e) {
|
30 |
-
Mage::logException($e);
|
31 |
-
|
32 |
-
return $e->getMessage();
|
33 |
-
}
|
34 |
-
|
35 |
-
return 'Done';
|
36 |
-
}
|
37 |
-
|
38 |
-
public function getLayeredSearchConfig($scopeId)
|
39 |
-
{
|
40 |
-
try {
|
41 |
-
$layered = $this->_getConfig()->getLayeredNavigationStatus($scopeId);
|
42 |
-
} catch (Exception $e) {
|
43 |
-
Mage::logException($e);
|
44 |
-
|
45 |
-
return $e->getMessage();
|
46 |
-
}
|
47 |
-
|
48 |
-
return $layered;
|
49 |
-
}
|
50 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Api extends Mage_Api_Model_Resource_Abstract
|
4 |
+
{
|
5 |
+
protected function _getConfig()
|
6 |
+
{
|
7 |
+
return Mage::getModel('autocompleteplus_autosuggest/config');
|
8 |
+
}
|
9 |
+
|
10 |
+
public function setLayeredSearchOn($scope, $scopeId)
|
11 |
+
{
|
12 |
+
try {
|
13 |
+
$this->_getConfig()->enableLayeredNavigation($scope, $scopeId);
|
14 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
15 |
+
} catch (Exception $e) {
|
16 |
+
Mage::logException($e);
|
17 |
+
|
18 |
+
return $e->getMessage();
|
19 |
+
}
|
20 |
+
|
21 |
+
return 'Done';
|
22 |
+
}
|
23 |
+
|
24 |
+
public function setLayeredSearchOff($scope, $scopeId)
|
25 |
+
{
|
26 |
+
try {
|
27 |
+
$this->_getConfig()->disableLayeredNavigation($scope, $scopeId);
|
28 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
29 |
+
} catch (Exception $e) {
|
30 |
+
Mage::logException($e);
|
31 |
+
|
32 |
+
return $e->getMessage();
|
33 |
+
}
|
34 |
+
|
35 |
+
return 'Done';
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getLayeredSearchConfig($scopeId)
|
39 |
+
{
|
40 |
+
try {
|
41 |
+
$layered = $this->_getConfig()->getLayeredNavigationStatus($scopeId);
|
42 |
+
} catch (Exception $e) {
|
43 |
+
Mage::logException($e);
|
44 |
+
|
45 |
+
return $e->getMessage();
|
46 |
+
}
|
47 |
+
|
48 |
+
return $layered;
|
49 |
+
}
|
50 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Api/V2.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Api_V2 extends Autocompleteplus_Autosuggest_Model_Api
|
4 |
-
{
|
5 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Api_V2 extends Autocompleteplus_Autosuggest_Model_Api
|
4 |
+
{
|
5 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Batches.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Batches extends Mage_Core_Model_Abstract
|
4 |
-
{
|
5 |
-
public function _construct()
|
6 |
-
{
|
7 |
-
$this->_init('autocompleteplus_autosuggest/batches');
|
8 |
-
}
|
9 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Batches extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('autocompleteplus_autosuggest/batches');
|
8 |
+
}
|
9 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Catalog.php
CHANGED
@@ -1,337 +1,374 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstract
|
4 |
-
{
|
5 |
-
protected $imageField;
|
6 |
-
protected $standardImageFields = array('image', 'small_image', 'thumbnail');
|
7 |
-
protected $useAttributes;
|
8 |
-
protected $attributes;
|
9 |
-
protected $currency;
|
10 |
-
protected $pageNum;
|
11 |
-
protected $_productCollection;
|
12 |
-
protected $_xmlGenerator;
|
13 |
-
protected $_helper;
|
14 |
-
protected $_attributes;
|
15 |
-
|
16 |
-
public function getXmlGenerator()
|
17 |
-
{
|
18 |
-
if (!$this->_xmlGenerator) {
|
19 |
-
$this->_xmlGenerator = new Autocompleteplus_Autosuggest_Xml_Generator();
|
20 |
-
}
|
21 |
-
|
22 |
-
return $this->_xmlGenerator;
|
23 |
-
}
|
24 |
-
|
25 |
-
public function getHelper()
|
26 |
-
{
|
27 |
-
if (!$this->_helper) {
|
28 |
-
$this->_helper = Mage::helper('autocompleteplus_autosuggest');
|
29 |
-
}
|
30 |
-
return $this->_helper;
|
31 |
-
}
|
32 |
-
|
33 |
-
public function getAttributes()
|
34 |
-
{
|
35 |
-
if (!$this->_attributes) {
|
36 |
-
|
37 |
-
$productModel = Mage::getModel('catalog/product');
|
38 |
-
$this->_attributes = Mage::getResourceModel('eav/entity_attribute_collection')
|
39 |
-
->setEntityTypeFilter($productModel->getResource()->getTypeId())
|
40 |
-
->addFieldToFilter('is_user_defined', '1')
|
41 |
-
;
|
42 |
-
}
|
43 |
-
return $this->_attributes;
|
44 |
-
}
|
45 |
-
|
46 |
-
public function getProductCollection($new = false)
|
47 |
-
{
|
48 |
-
if (!$this->_productCollection) {
|
49 |
-
$this->_productCollection = Mage::getModel('catalog/product')->getCollection();
|
50 |
-
}
|
51 |
-
|
52 |
-
if ($new === true) {
|
53 |
-
return Mage::getModel('catalog/product')->getCollection();
|
54 |
-
}
|
55 |
-
|
56 |
-
return $this->_productCollection;
|
57 |
-
}
|
58 |
-
|
59 |
-
public function getProductRenderer()
|
60 |
-
{
|
61 |
-
return Mage::getSingleton('autocompleteplus_autosuggest/renderer_catalog_product');
|
62 |
-
}
|
63 |
-
|
64 |
-
public function getBatchRenderer()
|
65 |
-
{
|
66 |
-
return Mage::getSingleton('autocompleteplus_autosuggest/renderer_batches');
|
67 |
-
}
|
68 |
-
|
69 |
-
public function renderCatalogXml($startInd = 0,
|
70 |
-
$count = 10000,
|
71 |
-
$storeId = false,
|
72 |
-
$orders = false,
|
73 |
-
$monthInterval = 12,
|
74 |
-
$checksum = false)
|
75 |
-
{
|
76 |
-
$xmlGenerator = $this->getXmlGenerator();
|
77 |
-
$count = ($count > 10000) ? 10000 : $count;
|
78 |
-
$this->setStoreId($storeId);
|
79 |
-
$this->setOrders($orders);
|
80 |
-
$this->setMonthInterval($monthInterval);
|
81 |
-
$this->setChecksum($checksum);
|
82 |
-
|
83 |
-
|
84 |
-
$xmlGenerator->setRootAttributes(array(
|
85 |
-
'version' => $this->getHelper()->getVersion(),
|
86 |
-
'magento' => $this->getHelper()->getMageVersion()
|
87 |
-
))->setRootElementName('catalog');
|
88 |
-
|
89 |
-
$productCollection = $this->getProductCollection();
|
90 |
-
|
91 |
-
// @codingStandardsIgnoreLine
|
92 |
-
$productCollection->getSelect()->limit($count, $startInd);
|
93 |
-
if (is_numeric($storeId)) {
|
94 |
-
$productCollection->addStoreFilter($storeId);
|
95 |
-
$productCollection->setStoreId($storeId);
|
96 |
-
}
|
97 |
-
|
98 |
-
$attributesToSelect = $this->_getAttributesToSelect();
|
99 |
-
|
100 |
-
$productCollection->addAttributeToSelect($attributesToSelect);
|
101 |
-
|
102 |
-
Mage::getModel('review/review')->appendSummary($productCollection);
|
103 |
-
|
104 |
-
if ($this->getChecksum() !== false) {
|
105 |
-
$this->setHasChecksum($checksum);
|
106 |
-
}
|
107 |
-
|
108 |
-
|
109 |
-
$this->
|
110 |
-
|
111 |
-
->
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
->
|
117 |
-
->
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
$
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
$
|
148 |
-
|
149 |
-
$
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
$
|
189 |
-
|
190 |
-
$
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
$
|
197 |
-
|
198 |
-
$
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
$productCollection
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
$
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
->
|
248 |
-
->
|
249 |
-
->
|
250 |
-
->
|
251 |
-
->
|
252 |
-
->
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
'
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
$
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
protected $imageField;
|
6 |
+
protected $standardImageFields = array('image', 'small_image', 'thumbnail');
|
7 |
+
protected $useAttributes;
|
8 |
+
protected $attributes;
|
9 |
+
protected $currency;
|
10 |
+
protected $pageNum;
|
11 |
+
protected $_productCollection;
|
12 |
+
protected $_xmlGenerator;
|
13 |
+
protected $_helper;
|
14 |
+
protected $_attributes;
|
15 |
+
|
16 |
+
public function getXmlGenerator()
|
17 |
+
{
|
18 |
+
if (!$this->_xmlGenerator) {
|
19 |
+
$this->_xmlGenerator = new Autocompleteplus_Autosuggest_Xml_Generator();
|
20 |
+
}
|
21 |
+
|
22 |
+
return $this->_xmlGenerator;
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getHelper()
|
26 |
+
{
|
27 |
+
if (!$this->_helper) {
|
28 |
+
$this->_helper = Mage::helper('autocompleteplus_autosuggest');
|
29 |
+
}
|
30 |
+
return $this->_helper;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getAttributes()
|
34 |
+
{
|
35 |
+
if (!$this->_attributes) {
|
36 |
+
|
37 |
+
$productModel = Mage::getModel('catalog/product');
|
38 |
+
$this->_attributes = Mage::getResourceModel('eav/entity_attribute_collection')
|
39 |
+
->setEntityTypeFilter($productModel->getResource()->getTypeId())
|
40 |
+
->addFieldToFilter('is_user_defined', '1')
|
41 |
+
;
|
42 |
+
}
|
43 |
+
return $this->_attributes;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function getProductCollection($new = false)
|
47 |
+
{
|
48 |
+
if (!$this->_productCollection) {
|
49 |
+
$this->_productCollection = Mage::getModel('catalog/product')->getCollection();
|
50 |
+
}
|
51 |
+
|
52 |
+
if ($new === true) {
|
53 |
+
return Mage::getModel('catalog/product')->getCollection();
|
54 |
+
}
|
55 |
+
|
56 |
+
return $this->_productCollection;
|
57 |
+
}
|
58 |
+
|
59 |
+
public function getProductRenderer()
|
60 |
+
{
|
61 |
+
return Mage::getSingleton('autocompleteplus_autosuggest/renderer_catalog_product');
|
62 |
+
}
|
63 |
+
|
64 |
+
public function getBatchRenderer()
|
65 |
+
{
|
66 |
+
return Mage::getSingleton('autocompleteplus_autosuggest/renderer_batches');
|
67 |
+
}
|
68 |
+
|
69 |
+
public function renderCatalogXml($startInd = 0,
|
70 |
+
$count = 10000,
|
71 |
+
$storeId = false,
|
72 |
+
$orders = false,
|
73 |
+
$monthInterval = 12,
|
74 |
+
$checksum = false)
|
75 |
+
{
|
76 |
+
$xmlGenerator = $this->getXmlGenerator();
|
77 |
+
$count = ($count > 10000) ? 10000 : $count;
|
78 |
+
$this->setStoreId($storeId);
|
79 |
+
$this->setOrders($orders);
|
80 |
+
$this->setMonthInterval($monthInterval);
|
81 |
+
$this->setChecksum($checksum);
|
82 |
+
|
83 |
+
|
84 |
+
$xmlGenerator->setRootAttributes(array(
|
85 |
+
'version' => $this->getHelper()->getVersion(),
|
86 |
+
'magento' => $this->getHelper()->getMageVersion()
|
87 |
+
))->setRootElementName('catalog');
|
88 |
+
|
89 |
+
$productCollection = $this->getProductCollection();
|
90 |
+
|
91 |
+
// @codingStandardsIgnoreLine
|
92 |
+
$productCollection->getSelect()->limit($count, $startInd);
|
93 |
+
if (is_numeric($storeId)) {
|
94 |
+
$productCollection->addStoreFilter($storeId);
|
95 |
+
$productCollection->setStoreId($storeId);
|
96 |
+
}
|
97 |
+
|
98 |
+
$attributesToSelect = $this->_getAttributesToSelect();
|
99 |
+
|
100 |
+
$productCollection->addAttributeToSelect($attributesToSelect);
|
101 |
+
|
102 |
+
Mage::getModel('review/review')->appendSummary($productCollection);
|
103 |
+
|
104 |
+
if ($this->getChecksum() !== false) {
|
105 |
+
$this->setHasChecksum($checksum);
|
106 |
+
}
|
107 |
+
|
108 |
+
if ($this->getOrders()) {
|
109 |
+
$ordersData = $this->getOrdersPerProduct();
|
110 |
+
$this->getProductRenderer()
|
111 |
+
->setOrderData($ordersData);
|
112 |
+
}
|
113 |
+
|
114 |
+
foreach ($productCollection as $product) {
|
115 |
+
$this->getProductRenderer()
|
116 |
+
->setAction('insert')
|
117 |
+
->setProduct($product)
|
118 |
+
->setStoreId($this->getStoreId())
|
119 |
+
->setOrders($this->getOrders())
|
120 |
+
->setMonthInterval($this->getMonthInterval())
|
121 |
+
->setXmlElement($xmlGenerator)
|
122 |
+
->setAttributes($this->getAttributes())
|
123 |
+
->renderXml();
|
124 |
+
if ($this->getHasChecksum()) {
|
125 |
+
if ($this->getHelper()->isChecksumTableExists()) {
|
126 |
+
$checksum = $this->getHelper()->calculateChecksum($product);
|
127 |
+
$this->getHelper()->updateSavedProductChecksum($product->getId(), $product->getSku(), $this->getStoreId(), $checksum);
|
128 |
+
}
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
return $xmlGenerator->generateXml();
|
133 |
+
}
|
134 |
+
|
135 |
+
public function getAllProductIds()
|
136 |
+
{
|
137 |
+
$idsSelect = clone $this->getProductCollection()->getSelect();
|
138 |
+
$idsSelect->reset(Zend_Db_Select::LIMIT_COUNT);
|
139 |
+
$idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
|
140 |
+
//$idsSelect->from
|
141 |
+
$idsSelect->columns(Mage::getResourceModel('catalog/product')->getIdFieldName(), 'main_table');
|
142 |
+
return Mage::getResourceModel('catalog/product')->getConnection()->fetchCol($idsSelect);
|
143 |
+
}
|
144 |
+
|
145 |
+
public function getOrdersPerProduct()
|
146 |
+
{ //$t=$this->getAllProductIds();
|
147 |
+
$productIds = implode(',', $this->getProductCollection()->getAllIds());
|
148 |
+
$salesOrderItemCollection = Mage::getResourceModel('sales/order_item_collection');
|
149 |
+
$salesOrderItemCollection->getSelect()->reset(Zend_Db_Select::COLUMNS)
|
150 |
+
->columns(array('product_id', 'SUM(qty_ordered) as qty_ordered'))
|
151 |
+
->where(new Zend_Db_Expr('store_id = ' . $this->getStoreId()))
|
152 |
+
->where(new Zend_Db_Expr('product_id IN (' . $productIds . ')'))
|
153 |
+
->where(new Zend_Db_Expr('created_at BETWEEN NOW() - INTERVAL ' . $this->getMonthInterval() . ' MONTH AND NOW()'))
|
154 |
+
->group(array('product_id'));
|
155 |
+
|
156 |
+
$products = array();
|
157 |
+
|
158 |
+
foreach ($salesOrderItemCollection as $item) {
|
159 |
+
$products[$item['product_id']] = (int)$item['qty_ordered'];
|
160 |
+
}
|
161 |
+
|
162 |
+
return $products;
|
163 |
+
}
|
164 |
+
|
165 |
+
|
166 |
+
public function canUseAttributes()
|
167 |
+
{
|
168 |
+
if (!$this->_useAttributes) {
|
169 |
+
$this->_useAttributes = Mage::getStoreConfigFlag('autocompleteplus/config/attributes');
|
170 |
+
}
|
171 |
+
return $this->_useAttributes;
|
172 |
+
}
|
173 |
+
|
174 |
+
public function renderUpdatesCatalogXml($count, $from, $to, $storeId)
|
175 |
+
{
|
176 |
+
$updates = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()
|
177 |
+
->addFieldToFilter('update_date', array(
|
178 |
+
'from' => $from,
|
179 |
+
'to' => $to
|
180 |
+
))
|
181 |
+
->addFieldToFilter('store_id', $storeId);
|
182 |
+
|
183 |
+
$this->setStoreId($storeId);
|
184 |
+
$updates->setOrder('update_date', 'ASC');
|
185 |
+
|
186 |
+
$updates->setPageSize($count);
|
187 |
+
$updates->setCurPage(1);
|
188 |
+
$xmlGenerator= $this->getXmlGenerator();
|
189 |
+
|
190 |
+
$xmlGenerator->setRootAttributes(array(
|
191 |
+
'version' => $this->getHelper()->getVersion(),
|
192 |
+
'magento' => $this->getHelper()->getMageVersion(),
|
193 |
+
'fromdatetime' => $from
|
194 |
+
))->setRootElementName('catalog');
|
195 |
+
|
196 |
+
$updatesBulk=array();
|
197 |
+
|
198 |
+
$productIds=array();
|
199 |
+
|
200 |
+
foreach ($updates as $batch) {
|
201 |
+
|
202 |
+
if ($batch['action'] == 'update') {
|
203 |
+
|
204 |
+
if ($batch['product_id'] != null) {
|
205 |
+
$updatesBulk[$batch['product_id']] = $batch;
|
206 |
+
|
207 |
+
$productIds[] = $batch['product_id'];
|
208 |
+
|
209 |
+
} else {
|
210 |
+
$batch['action'] = 'remove';
|
211 |
+
$this->getBatchRenderer()
|
212 |
+
->setXmlElement($xmlGenerator)
|
213 |
+
->makeRemoveRow($batch);
|
214 |
+
}
|
215 |
+
|
216 |
+
} elseif ($batch['action'] == 'remove') {
|
217 |
+
|
218 |
+
$this->getBatchRenderer()
|
219 |
+
->setXmlElement($xmlGenerator)
|
220 |
+
->makeRemoveRow($batch);
|
221 |
+
}
|
222 |
+
|
223 |
+
}
|
224 |
+
|
225 |
+
$this->currency = Mage::app()->getStore($storeId)->getCurrentCurrencyCode();
|
226 |
+
|
227 |
+
$productCollection = $this->getProductCollection();
|
228 |
+
|
229 |
+
$productCollection->addStoreFilter($storeId);
|
230 |
+
|
231 |
+
$productCollection->setStoreId($storeId);
|
232 |
+
|
233 |
+
$attributesToSelect = $this->_getAttributesToSelect();
|
234 |
+
|
235 |
+
$productCollection->addAttributeToSelect($attributesToSelect)
|
236 |
+
->addAttributeToFilter('entity_id', array('in' => $productIds));
|
237 |
+
|
238 |
+
foreach ($productCollection as $product) {
|
239 |
+
|
240 |
+
$updatedate = $updatesBulk[$product->getId()]['update_date'];
|
241 |
+
|
242 |
+
$this->getProductRenderer()
|
243 |
+
->setXmlElement($xmlGenerator)
|
244 |
+
->setAction('update')
|
245 |
+
->setProduct($product)
|
246 |
+
->setStoreId($storeId)
|
247 |
+
->setOrders($this->getOrders())
|
248 |
+
->setMonthInterval($this->getMonthInterval())
|
249 |
+
->setXmlElement($xmlGenerator)
|
250 |
+
->setAttributes($this->getAttributes())
|
251 |
+
->setUpdateDate($updatedate)
|
252 |
+
->renderXml();
|
253 |
+
}
|
254 |
+
|
255 |
+
return $xmlGenerator->generateXml();
|
256 |
+
}
|
257 |
+
|
258 |
+
public function renderCatalogFromIds($count, $fromId, $storeId)
|
259 |
+
{
|
260 |
+
$xmlGenerator = $this->getXmlGenerator();
|
261 |
+
$xmlGenerator->setRootAttributes(array(
|
262 |
+
'version' => $this->getHelper()->getVersion(),
|
263 |
+
'magento' => $this->getHelper()->getMageVersion()
|
264 |
+
))->setRootElementName('catalog');
|
265 |
+
|
266 |
+
$productCollection = $this->getProductCollection();
|
267 |
+
if (is_numeric($storeId)) {
|
268 |
+
$productCollection->addStoreFilter($storeId);
|
269 |
+
$productCollection->setStoreId($storeId);
|
270 |
+
}
|
271 |
+
|
272 |
+
$attributesToSelect = $this->_getAttributesToSelect();
|
273 |
+
|
274 |
+
$productCollection->addAttributeToSelect($attributesToSelect);
|
275 |
+
|
276 |
+
$productCollection->addAttributeToFilter('entity_id', array('from' => $fromId));
|
277 |
+
$productCollection->setPageSize($count);
|
278 |
+
$productCollection->setCurPage(1);
|
279 |
+
|
280 |
+
Mage::getModel('review/review')->appendSummary($productCollection);
|
281 |
+
|
282 |
+
foreach ($productCollection as $product) {
|
283 |
+
$this->getProductRenderer()
|
284 |
+
->setAction('getfromid')
|
285 |
+
->setProduct($product)
|
286 |
+
->setStoreId($storeId)
|
287 |
+
->setXmlElement($xmlGenerator)
|
288 |
+
->setAttributes($this->getAttributes())
|
289 |
+
->setGetByIdStatus(1)
|
290 |
+
->renderXml();
|
291 |
+
}
|
292 |
+
|
293 |
+
return $xmlGenerator->generateXml();
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Creates an XML representation of catalog by ids.
|
298 |
+
*
|
299 |
+
* @param array $ids
|
300 |
+
* @param int $storeId
|
301 |
+
*
|
302 |
+
* @return string
|
303 |
+
*/
|
304 |
+
public function renderCatalogByIds($ids, $storeId = 0)
|
305 |
+
{
|
306 |
+
$xmlGenerator = $this->getXmlGenerator();
|
307 |
+
$xmlGenerator->setRootAttributes(array(
|
308 |
+
'version' => $this->getHelper()->getVersion(),
|
309 |
+
'magento' => $this->getHelper()->getMageVersion()
|
310 |
+
))->setRootElementName('catalog');
|
311 |
+
|
312 |
+
$productCollection = $this->getProductCollection();
|
313 |
+
if (is_numeric($storeId)) {
|
314 |
+
$productCollection->addStoreFilter($storeId);
|
315 |
+
$productCollection->setStoreId($storeId);
|
316 |
+
}
|
317 |
+
|
318 |
+
$attributesToSelect = $this->_getAttributesToSelect();
|
319 |
+
|
320 |
+
$productCollection->addAttributeToSelect($attributesToSelect);
|
321 |
+
|
322 |
+
$productCollection->addAttributeToFilter('entity_id', array('in' => $ids));
|
323 |
+
|
324 |
+
Mage::getModel('review/review')->appendSummary($productCollection);
|
325 |
+
|
326 |
+
foreach ($productCollection as $product) {
|
327 |
+
$this->getProductRenderer()
|
328 |
+
->setAction('getbyid')
|
329 |
+
->setProduct($product)
|
330 |
+
->setStoreId($storeId)
|
331 |
+
->setXmlElement($xmlGenerator)
|
332 |
+
->setAttributes($this->getAttributes())
|
333 |
+
->setGetByIdStatus(1)
|
334 |
+
->renderXml();
|
335 |
+
}
|
336 |
+
|
337 |
+
return $xmlGenerator->generateXml();
|
338 |
+
}
|
339 |
+
|
340 |
+
/**
|
341 |
+
* @return array
|
342 |
+
*/
|
343 |
+
protected function _getAttributesToSelect()
|
344 |
+
{
|
345 |
+
$attributesToSelect = array(
|
346 |
+
'store_id',
|
347 |
+
'name',
|
348 |
+
'description',
|
349 |
+
'short_description',
|
350 |
+
'visibility',
|
351 |
+
'thumbnail',
|
352 |
+
'image',
|
353 |
+
'small_image',
|
354 |
+
'url',
|
355 |
+
'status',
|
356 |
+
'updated_at',
|
357 |
+
'price',
|
358 |
+
'meta_title',
|
359 |
+
'meta_description',
|
360 |
+
'special_price',
|
361 |
+
'sku'
|
362 |
+
);
|
363 |
+
|
364 |
+
if ($this->canUseAttributes()) {
|
365 |
+
foreach ($this->getAttributes() as $attr) {
|
366 |
+
$action = $attr->getAttributeCode();
|
367 |
+
|
368 |
+
$attributesToSelect[] = $action;
|
369 |
+
}
|
370 |
+
return $attributesToSelect;
|
371 |
+
}
|
372 |
+
return $attributesToSelect;
|
373 |
+
}
|
374 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Catalogreport.php
CHANGED
@@ -1,113 +1,113 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Catalogreport extends Mage_Core_Model_Abstract
|
4 |
-
{
|
5 |
-
protected $_storeId;
|
6 |
-
|
7 |
-
public function getDisabledProductsCount()
|
8 |
-
{
|
9 |
-
try {
|
10 |
-
$collection = $this->getProductCollectionStoreFilterFactory();
|
11 |
-
$this->addDisabledFilterToCollection($collection);
|
12 |
-
|
13 |
-
return $collection->getSize();
|
14 |
-
} catch (Exception $e) {
|
15 |
-
return -1;
|
16 |
-
}
|
17 |
-
}
|
18 |
-
|
19 |
-
public function getEnabledProductsCount()
|
20 |
-
{
|
21 |
-
try {
|
22 |
-
$collection = $this->getProductCollectionStoreFilterFactory();
|
23 |
-
$this->addEnabledFilterToCollection($collection);
|
24 |
-
|
25 |
-
return $collection->getSize();
|
26 |
-
} catch (Exception $e) {
|
27 |
-
return -1;
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
public function getSearchableProductsCount()
|
32 |
-
{
|
33 |
-
try {
|
34 |
-
$collection = $this->getProductCollectionStoreFilterFactory();
|
35 |
-
$this->addEnabledFilterToCollection($collection);
|
36 |
-
$this->addVisibleInSearchFilterToCollection($collection);
|
37 |
-
|
38 |
-
return $collection->getSize();
|
39 |
-
} catch (Exception $e) {
|
40 |
-
return -1;
|
41 |
-
}
|
42 |
-
}
|
43 |
-
|
44 |
-
public function getSearchableProducts2Count()
|
45 |
-
{
|
46 |
-
try {
|
47 |
-
$num_of_searchable_products = Mage::getModel('catalog/product')->getCollection()
|
48 |
-
->addStoreFilter($this->getCurrentStoreId())
|
49 |
-
->addAttributeToFilter('status', array('eq' => 1)) // Mage_Catalog_Model_Product_Status::STATUS_ENABLED
|
50 |
-
->addAttributeToFilter(array(
|
51 |
-
array('attribute' => 'visibility', 'finset' => 3), // visibility Search
|
52 |
-
array('attribute' => 'visibility', 'finset' => 4), // visibility Catalog, Search
|
53 |
-
))
|
54 |
-
->getSize();
|
55 |
-
|
56 |
-
return $num_of_searchable_products;
|
57 |
-
} catch (Exception $e) {
|
58 |
-
return -1;
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
protected function getProductCollectionStoreFilterFactory()
|
63 |
-
{
|
64 |
-
return Mage::getModel('catalog/product')->getCollection()
|
65 |
-
->addStoreFilter($this->getCurrentStoreId());
|
66 |
-
}
|
67 |
-
|
68 |
-
public function addEnabledFilterToCollection($collection)
|
69 |
-
{
|
70 |
-
return $collection->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED));
|
71 |
-
}
|
72 |
-
|
73 |
-
public function addDisabledFilterToCollection($collection)
|
74 |
-
{
|
75 |
-
return $collection->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_DISABLED));
|
76 |
-
}
|
77 |
-
|
78 |
-
public function addVisibleInCatalogFilterToCollection($collection)
|
79 |
-
{
|
80 |
-
return Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
|
81 |
-
}
|
82 |
-
|
83 |
-
public function addVisibleInSearchFilterToCollection($collection)
|
84 |
-
{
|
85 |
-
return Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Return the current store - can be overridden with post.
|
90 |
-
*
|
91 |
-
* @return int
|
92 |
-
*/
|
93 |
-
public function getCurrentStoreId()
|
94 |
-
{
|
95 |
-
if (!$this->_storeId) {
|
96 |
-
$post = $this->getRequest()->getParams();
|
97 |
-
if (array_key_exists('store_id', $post)) {
|
98 |
-
$this->_storeId = $post['store_id'];
|
99 |
-
} elseif (array_key_exists('store', $post)) {
|
100 |
-
$this->_storeId = $post['store'];
|
101 |
-
} else {
|
102 |
-
$this->_storeId = Mage::app()->getStore()->getStoreId();
|
103 |
-
}
|
104 |
-
}
|
105 |
-
|
106 |
-
return $this->_storeId;
|
107 |
-
}
|
108 |
-
|
109 |
-
public function getRequest()
|
110 |
-
{
|
111 |
-
return Mage::app()->getRequest();
|
112 |
-
}
|
113 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Catalogreport extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
protected $_storeId;
|
6 |
+
|
7 |
+
public function getDisabledProductsCount()
|
8 |
+
{
|
9 |
+
try {
|
10 |
+
$collection = $this->getProductCollectionStoreFilterFactory();
|
11 |
+
$this->addDisabledFilterToCollection($collection);
|
12 |
+
|
13 |
+
return $collection->getSize();
|
14 |
+
} catch (Exception $e) {
|
15 |
+
return -1;
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getEnabledProductsCount()
|
20 |
+
{
|
21 |
+
try {
|
22 |
+
$collection = $this->getProductCollectionStoreFilterFactory();
|
23 |
+
$this->addEnabledFilterToCollection($collection);
|
24 |
+
|
25 |
+
return $collection->getSize();
|
26 |
+
} catch (Exception $e) {
|
27 |
+
return -1;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getSearchableProductsCount()
|
32 |
+
{
|
33 |
+
try {
|
34 |
+
$collection = $this->getProductCollectionStoreFilterFactory();
|
35 |
+
$this->addEnabledFilterToCollection($collection);
|
36 |
+
$this->addVisibleInSearchFilterToCollection($collection);
|
37 |
+
|
38 |
+
return $collection->getSize();
|
39 |
+
} catch (Exception $e) {
|
40 |
+
return -1;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
public function getSearchableProducts2Count()
|
45 |
+
{
|
46 |
+
try {
|
47 |
+
$num_of_searchable_products = Mage::getModel('catalog/product')->getCollection()
|
48 |
+
->addStoreFilter($this->getCurrentStoreId())
|
49 |
+
->addAttributeToFilter('status', array('eq' => 1)) // Mage_Catalog_Model_Product_Status::STATUS_ENABLED
|
50 |
+
->addAttributeToFilter(array(
|
51 |
+
array('attribute' => 'visibility', 'finset' => 3), // visibility Search
|
52 |
+
array('attribute' => 'visibility', 'finset' => 4), // visibility Catalog, Search
|
53 |
+
))
|
54 |
+
->getSize();
|
55 |
+
|
56 |
+
return $num_of_searchable_products;
|
57 |
+
} catch (Exception $e) {
|
58 |
+
return -1;
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
protected function getProductCollectionStoreFilterFactory()
|
63 |
+
{
|
64 |
+
return Mage::getModel('catalog/product')->getCollection()
|
65 |
+
->addStoreFilter($this->getCurrentStoreId());
|
66 |
+
}
|
67 |
+
|
68 |
+
public function addEnabledFilterToCollection($collection)
|
69 |
+
{
|
70 |
+
return $collection->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED));
|
71 |
+
}
|
72 |
+
|
73 |
+
public function addDisabledFilterToCollection($collection)
|
74 |
+
{
|
75 |
+
return $collection->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_DISABLED));
|
76 |
+
}
|
77 |
+
|
78 |
+
public function addVisibleInCatalogFilterToCollection($collection)
|
79 |
+
{
|
80 |
+
return Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
|
81 |
+
}
|
82 |
+
|
83 |
+
public function addVisibleInSearchFilterToCollection($collection)
|
84 |
+
{
|
85 |
+
return Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Return the current store - can be overridden with post.
|
90 |
+
*
|
91 |
+
* @return int
|
92 |
+
*/
|
93 |
+
public function getCurrentStoreId()
|
94 |
+
{
|
95 |
+
if (!$this->_storeId) {
|
96 |
+
$post = $this->getRequest()->getParams();
|
97 |
+
if (array_key_exists('store_id', $post)) {
|
98 |
+
$this->_storeId = $post['store_id'];
|
99 |
+
} elseif (array_key_exists('store', $post)) {
|
100 |
+
$this->_storeId = $post['store'];
|
101 |
+
} else {
|
102 |
+
$this->_storeId = Mage::app()->getStore()->getStoreId();
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
return $this->_storeId;
|
107 |
+
}
|
108 |
+
|
109 |
+
public function getRequest()
|
110 |
+
{
|
111 |
+
return Mage::app()->getRequest();
|
112 |
+
}
|
113 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Checksum.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Checksum extends Mage_Core_Model_Abstract
|
4 |
-
{
|
5 |
-
public function _construct()
|
6 |
-
{
|
7 |
-
$this->_init('autocompleteplus_autosuggest/checksum');
|
8 |
-
}
|
9 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Checksum extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('autocompleteplus_autosuggest/checksum');
|
8 |
+
}
|
9 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Config.php
CHANGED
@@ -1,371 +1,389 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Config extends Mage_Core_Model_Abstract
|
4 |
-
{
|
5 |
-
protected $_helper = false;
|
6 |
-
protected $_apiEndpoint = false;
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Define XML Config paths and states.
|
10 |
-
*/
|
11 |
-
const XML_SEARCH_LAYERED_DISABLED = 0;
|
12 |
-
const XML_SEARCH_LAYERED_ENABLED = 1;
|
13 |
-
const XML_SEARCH_LAYERED_CONFIG = 'autocompleteplus/config/layered';
|
14 |
-
const XML_API_ENDPOINT_CONFIG = 'default/autocompleteplus/config/api_endpoint';
|
15 |
-
const XML_STORE_EMAIL_CONFIG = 'autocompleteplus/config/store_email';
|
16 |
-
const XML_AUTHORIZATION_KEY_CONFIG = 'autocompleteplus_autosuggest/config/authorization_key';
|
17 |
-
const XML_UUID_CONFIG = 'autocompleteplus_autosuggest/config/uuid';
|
18 |
-
const XML_SITE_URL_CONFIG = 'autocompleteplus_autosuggest/config/site_url';
|
19 |
-
const XML_IS_REACHABLE_CONFIG = 'autocompleteplus_autosuggest/config/is_reachable';
|
20 |
-
const XML_ERROR_MESSAGE_CONFIG = 'autocompleteplus_autosuggest/config/error_message';
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Fetch Magento Config Model.
|
24 |
-
*
|
25 |
-
* @return false|Mage_Core_Model_Config
|
26 |
-
*/
|
27 |
-
protected function _getMageConfig()
|
28 |
-
{
|
29 |
-
return Mage::getModel('core/config');
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Fetch API Endpoint URL.
|
34 |
-
*
|
35 |
-
* @return string|Mage_Core_Model_Config_Element
|
36 |
-
*/
|
37 |
-
public function getEndpoint()
|
38 |
-
{
|
39 |
-
if (!$this->_apiEndpoint) {
|
40 |
-
$this->_apiEndpoint = Mage::getConfig()->getNode(self::XML_API_ENDPOINT_CONFIG);
|
41 |
-
}
|
42 |
-
|
43 |
-
return $this->_apiEndpoint;
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Fetch AA Helper.
|
48 |
-
*
|
49 |
-
* @return bool|Mage_Core_Helper_Abstract
|
50 |
-
*/
|
51 |
-
protected function _getHelper()
|
52 |
-
{
|
53 |
-
if (!$this->_helper) {
|
54 |
-
$this->_helper = Mage::helper('autocompleteplus_autosuggest');
|
55 |
-
}
|
56 |
-
|
57 |
-
return $this->_helper;
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Enable Layered Navigation.
|
62 |
-
*
|
63 |
-
* @param string $scope
|
64 |
-
* @param int $scopeId
|
65 |
-
*/
|
66 |
-
public function enableLayeredNavigation($scope = 'stores', $scopeId = 0)
|
67 |
-
{
|
68 |
-
$this->_getMageConfig()->deleteConfig(self::XML_SEARCH_LAYERED_CONFIG, 'default', $scopeId);
|
69 |
-
$this->_getMageConfig()->saveConfig(self::XML_SEARCH_LAYERED_CONFIG, self::XML_SEARCH_LAYERED_ENABLED, $scope, $scopeId);
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Disable Layered Navigation.
|
74 |
-
*
|
75 |
-
* @param string $scope
|
76 |
-
* @param int $scopeId
|
77 |
-
*/
|
78 |
-
public function disableLayeredNavigation($scope = 'stores', $scopeId = 0)
|
79 |
-
{
|
80 |
-
$this->_getMageConfig()->deleteConfig(self::XML_SEARCH_LAYERED_CONFIG, 'default', $scopeId);
|
81 |
-
$this->_getMageConfig()->saveConfig(self::XML_SEARCH_LAYERED_CONFIG, self::XML_SEARCH_LAYERED_DISABLED, $scope, $scopeId);
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Get Layered Navigation Status.
|
86 |
-
*
|
87 |
-
* @param $scopeId
|
88 |
-
*
|
89 |
-
* @return mixed
|
90 |
-
*/
|
91 |
-
public function getLayeredNavigationStatus($scopeId)
|
92 |
-
{
|
93 |
-
return Mage::getStoreConfig(self::XML_SEARCH_LAYERED_CONFIG, $scopeId);
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Set Authorization Key.
|
98 |
-
*
|
99 |
-
* @param $key
|
100 |
-
*/
|
101 |
-
public function setAuthorizationKey($key)
|
102 |
-
{
|
103 |
-
$this->_getMageConfig()->saveConfig(self::XML_AUTHORIZATION_KEY_CONFIG, $key);
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Get Authorization Key.
|
108 |
-
*
|
109 |
-
* @return mixed
|
110 |
-
*/
|
111 |
-
public function getAuthorizationKey()
|
112 |
-
{
|
113 |
-
return Mage::getStoreConfig(self::XML_AUTHORIZATION_KEY_CONFIG);
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Set UUID.
|
118 |
-
*
|
119 |
-
* @param $uuid
|
120 |
-
*/
|
121 |
-
public function setUUID($uuid)
|
122 |
-
{
|
123 |
-
$this->_getMageConfig()->saveConfig(self::XML_UUID_CONFIG, $uuid);
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Get UUID.
|
128 |
-
*
|
129 |
-
* @return mixed
|
130 |
-
*/
|
131 |
-
public function getUUID()
|
132 |
-
{
|
133 |
-
return Mage::getStoreConfig(self::XML_UUID_CONFIG);
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Get UUID and Authorization key.
|
138 |
-
*
|
139 |
-
* @return array
|
140 |
-
*/
|
141 |
-
public function getBothKeys()
|
142 |
-
{
|
143 |
-
return array('uuid' => $this->getUUID(), 'authkey' => $this->getAuthorizationKey());
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* Set Site URL.
|
148 |
-
*
|
149 |
-
* @param $url
|
150 |
-
*/
|
151 |
-
public function setSiteUrl($url)
|
152 |
-
{
|
153 |
-
$this->_getMageConfig()->saveConfig(self::XML_SITE_URL_CONFIG, $url);
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Get Site URL.
|
158 |
-
*
|
159 |
-
* @return mixed
|
160 |
-
*/
|
161 |
-
public function getSiteUrl()
|
162 |
-
{
|
163 |
-
return Mage::getStoreConfig(self::XML_SITE_URL_CONFIG);
|
164 |
-
}
|
165 |
-
|
166 |
-
/**
|
167 |
-
* Set Is Reachable.
|
168 |
-
*
|
169 |
-
* @param $reachable
|
170 |
-
*/
|
171 |
-
public function setIsReachable($reachable)
|
172 |
-
{
|
173 |
-
$this->_getMageConfig()->saveConfig(self::XML_IS_REACHABLE_CONFIG, $reachable);
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
* Get Is Reachable.
|
178 |
-
*
|
179 |
-
* @return mixed
|
180 |
-
*/
|
181 |
-
public function isReachable()
|
182 |
-
{
|
183 |
-
return Mage::getStoreConfig(self::XML_IS_REACHABLE_CONFIG);
|
184 |
-
}
|
185 |
-
|
186 |
-
/**
|
187 |
-
* Set Error Message.
|
188 |
-
*
|
189 |
-
* @param $message
|
190 |
-
*/
|
191 |
-
public function setErrorMessage($message)
|
192 |
-
{
|
193 |
-
$this->_getMageConfig()->saveConfig(self::XML_ERROR_MESSAGE_CONFIG, $message);
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* Get Error Message.
|
198 |
-
*
|
199 |
-
* @return mixed
|
200 |
-
*/
|
201 |
-
public function getErrorMessage()
|
202 |
-
{
|
203 |
-
return Mage::getStoreConfig(self::XML_ERROR_MESSAGE_CONFIG);
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* Get Module Version.
|
208 |
-
*
|
209 |
-
* @return mixed
|
210 |
-
*/
|
211 |
-
public function getModuleVersion()
|
212 |
-
{
|
213 |
-
return Mage::getConfig()->getModuleConfig('Autocompleteplus_Autosuggest')->version;
|
214 |
-
}
|
215 |
-
|
216 |
-
/**
|
217 |
-
* Update robots.txt file with ISP sitemap URL
|
218 |
-
* @param $responseData
|
219 |
-
*/
|
220 |
-
protected function _updateRobotsTxt($responseData)
|
221 |
-
{
|
222 |
-
$fileIo = new Varien_Io_File();
|
223 |
-
$baseDir = Mage::getBaseDir();
|
224 |
-
$fileIo->open(array('path' => $baseDir));
|
225 |
-
$robotsTxtContent = $fileIo->read('robots.txt');
|
226 |
-
$siteMapUrl = 'Sitemap:http://magento.instantsearchplus.com/ext_sitemap?u='.$responseData['uuid'].PHP_EOL;
|
227 |
-
$robotsTxtExists = $fileIo->fileExists('robots.txt');
|
228 |
-
$baseDirWritable = $fileIo->isWriteable($baseDir);
|
229 |
-
$siteMapExists = strpos($robotsTxtContent, $siteMapUrl) === false;
|
230 |
-
$robotsTxtWritable = $fileIo->isWriteable('robots.txt');
|
231 |
-
|
232 |
-
if ($robotsTxtExists && $robotsTxtWritable && !$siteMapExists) {
|
233 |
-
$fileIo->write('robots.txt', $robotsTxtContent . $siteMapUrl);
|
234 |
-
} else if (!$robotsTxtExists && $baseDirWritable) {
|
235 |
-
$fileIo->write('robots.txt', $siteMapUrl);
|
236 |
-
} else {
|
237 |
-
$this->_sendError('Unable to properly update robots.txt with ISP Sitemap');
|
238 |
-
}
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* Generate Config for AutocompletePlus.
|
243 |
-
*
|
244 |
-
* @param string $UUID
|
245 |
-
* @param string $key
|
246 |
-
*
|
247 |
-
* @return $this
|
248 |
-
*
|
249 |
-
* @throws Zend_Http_Client_Exception
|
250 |
-
*/
|
251 |
-
public function generateConfig($UUID = null, $key = null)
|
252 |
-
{
|
253 |
-
$params = array(
|
254 |
-
'site' => $this->_getHelper()->getConfigDataByFullPath('web/unsecure/base_url'),
|
255 |
-
'email' => Mage::getStoreConfig(self::XML_STORE_EMAIL_CONFIG),
|
256 |
-
'f' => $this->_getHelper()->getVersion(),
|
257 |
-
'multistore' => $this->_getHelper()->getMultiStoreDataJson(),
|
258 |
-
);
|
259 |
-
|
260 |
-
if ($UUID && $key) {
|
261 |
-
$params['uuid'] = $UUID;
|
262 |
-
$params['key'] = $key;
|
263 |
-
}
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
$
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
$
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
'
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
$
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Config extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
protected $_helper = false;
|
6 |
+
protected $_apiEndpoint = false;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Define XML Config paths and states.
|
10 |
+
*/
|
11 |
+
const XML_SEARCH_LAYERED_DISABLED = 0;
|
12 |
+
const XML_SEARCH_LAYERED_ENABLED = 1;
|
13 |
+
const XML_SEARCH_LAYERED_CONFIG = 'autocompleteplus/config/layered';
|
14 |
+
const XML_API_ENDPOINT_CONFIG = 'default/autocompleteplus/config/api_endpoint';
|
15 |
+
const XML_STORE_EMAIL_CONFIG = 'autocompleteplus/config/store_email';
|
16 |
+
const XML_AUTHORIZATION_KEY_CONFIG = 'autocompleteplus_autosuggest/config/authorization_key';
|
17 |
+
const XML_UUID_CONFIG = 'autocompleteplus_autosuggest/config/uuid';
|
18 |
+
const XML_SITE_URL_CONFIG = 'autocompleteplus_autosuggest/config/site_url';
|
19 |
+
const XML_IS_REACHABLE_CONFIG = 'autocompleteplus_autosuggest/config/is_reachable';
|
20 |
+
const XML_ERROR_MESSAGE_CONFIG = 'autocompleteplus_autosuggest/config/error_message';
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Fetch Magento Config Model.
|
24 |
+
*
|
25 |
+
* @return false|Mage_Core_Model_Config
|
26 |
+
*/
|
27 |
+
protected function _getMageConfig()
|
28 |
+
{
|
29 |
+
return Mage::getModel('core/config');
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Fetch API Endpoint URL.
|
34 |
+
*
|
35 |
+
* @return string|Mage_Core_Model_Config_Element
|
36 |
+
*/
|
37 |
+
public function getEndpoint()
|
38 |
+
{
|
39 |
+
if (!$this->_apiEndpoint) {
|
40 |
+
$this->_apiEndpoint = Mage::getConfig()->getNode(self::XML_API_ENDPOINT_CONFIG);
|
41 |
+
}
|
42 |
+
|
43 |
+
return $this->_apiEndpoint;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Fetch AA Helper.
|
48 |
+
*
|
49 |
+
* @return bool|Mage_Core_Helper_Abstract
|
50 |
+
*/
|
51 |
+
protected function _getHelper()
|
52 |
+
{
|
53 |
+
if (!$this->_helper) {
|
54 |
+
$this->_helper = Mage::helper('autocompleteplus_autosuggest');
|
55 |
+
}
|
56 |
+
|
57 |
+
return $this->_helper;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Enable Layered Navigation.
|
62 |
+
*
|
63 |
+
* @param string $scope
|
64 |
+
* @param int $scopeId
|
65 |
+
*/
|
66 |
+
public function enableLayeredNavigation($scope = 'stores', $scopeId = 0)
|
67 |
+
{
|
68 |
+
$this->_getMageConfig()->deleteConfig(self::XML_SEARCH_LAYERED_CONFIG, 'default', $scopeId);
|
69 |
+
$this->_getMageConfig()->saveConfig(self::XML_SEARCH_LAYERED_CONFIG, self::XML_SEARCH_LAYERED_ENABLED, $scope, $scopeId);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Disable Layered Navigation.
|
74 |
+
*
|
75 |
+
* @param string $scope
|
76 |
+
* @param int $scopeId
|
77 |
+
*/
|
78 |
+
public function disableLayeredNavigation($scope = 'stores', $scopeId = 0)
|
79 |
+
{
|
80 |
+
$this->_getMageConfig()->deleteConfig(self::XML_SEARCH_LAYERED_CONFIG, 'default', $scopeId);
|
81 |
+
$this->_getMageConfig()->saveConfig(self::XML_SEARCH_LAYERED_CONFIG, self::XML_SEARCH_LAYERED_DISABLED, $scope, $scopeId);
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Get Layered Navigation Status.
|
86 |
+
*
|
87 |
+
* @param $scopeId
|
88 |
+
*
|
89 |
+
* @return mixed
|
90 |
+
*/
|
91 |
+
public function getLayeredNavigationStatus($scopeId)
|
92 |
+
{
|
93 |
+
return Mage::getStoreConfig(self::XML_SEARCH_LAYERED_CONFIG, $scopeId);
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Set Authorization Key.
|
98 |
+
*
|
99 |
+
* @param $key
|
100 |
+
*/
|
101 |
+
public function setAuthorizationKey($key)
|
102 |
+
{
|
103 |
+
$this->_getMageConfig()->saveConfig(self::XML_AUTHORIZATION_KEY_CONFIG, $key);
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Get Authorization Key.
|
108 |
+
*
|
109 |
+
* @return mixed
|
110 |
+
*/
|
111 |
+
public function getAuthorizationKey()
|
112 |
+
{
|
113 |
+
return Mage::getStoreConfig(self::XML_AUTHORIZATION_KEY_CONFIG);
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Set UUID.
|
118 |
+
*
|
119 |
+
* @param $uuid
|
120 |
+
*/
|
121 |
+
public function setUUID($uuid)
|
122 |
+
{
|
123 |
+
$this->_getMageConfig()->saveConfig(self::XML_UUID_CONFIG, $uuid);
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Get UUID.
|
128 |
+
*
|
129 |
+
* @return mixed
|
130 |
+
*/
|
131 |
+
public function getUUID()
|
132 |
+
{
|
133 |
+
return Mage::getStoreConfig(self::XML_UUID_CONFIG);
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Get UUID and Authorization key.
|
138 |
+
*
|
139 |
+
* @return array
|
140 |
+
*/
|
141 |
+
public function getBothKeys()
|
142 |
+
{
|
143 |
+
return array('uuid' => $this->getUUID(), 'authkey' => $this->getAuthorizationKey());
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Set Site URL.
|
148 |
+
*
|
149 |
+
* @param $url
|
150 |
+
*/
|
151 |
+
public function setSiteUrl($url)
|
152 |
+
{
|
153 |
+
$this->_getMageConfig()->saveConfig(self::XML_SITE_URL_CONFIG, $url);
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Get Site URL.
|
158 |
+
*
|
159 |
+
* @return mixed
|
160 |
+
*/
|
161 |
+
public function getSiteUrl()
|
162 |
+
{
|
163 |
+
return Mage::getStoreConfig(self::XML_SITE_URL_CONFIG);
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Set Is Reachable.
|
168 |
+
*
|
169 |
+
* @param $reachable
|
170 |
+
*/
|
171 |
+
public function setIsReachable($reachable)
|
172 |
+
{
|
173 |
+
$this->_getMageConfig()->saveConfig(self::XML_IS_REACHABLE_CONFIG, $reachable);
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Get Is Reachable.
|
178 |
+
*
|
179 |
+
* @return mixed
|
180 |
+
*/
|
181 |
+
public function isReachable()
|
182 |
+
{
|
183 |
+
return Mage::getStoreConfig(self::XML_IS_REACHABLE_CONFIG);
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Set Error Message.
|
188 |
+
*
|
189 |
+
* @param $message
|
190 |
+
*/
|
191 |
+
public function setErrorMessage($message)
|
192 |
+
{
|
193 |
+
$this->_getMageConfig()->saveConfig(self::XML_ERROR_MESSAGE_CONFIG, $message);
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Get Error Message.
|
198 |
+
*
|
199 |
+
* @return mixed
|
200 |
+
*/
|
201 |
+
public function getErrorMessage()
|
202 |
+
{
|
203 |
+
return Mage::getStoreConfig(self::XML_ERROR_MESSAGE_CONFIG);
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Get Module Version.
|
208 |
+
*
|
209 |
+
* @return mixed
|
210 |
+
*/
|
211 |
+
public function getModuleVersion()
|
212 |
+
{
|
213 |
+
return Mage::getConfig()->getModuleConfig('Autocompleteplus_Autosuggest')->version;
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Update robots.txt file with ISP sitemap URL
|
218 |
+
* @param $responseData
|
219 |
+
*/
|
220 |
+
protected function _updateRobotsTxt($responseData)
|
221 |
+
{
|
222 |
+
$fileIo = new Varien_Io_File();
|
223 |
+
$baseDir = Mage::getBaseDir();
|
224 |
+
$fileIo->open(array('path' => $baseDir));
|
225 |
+
$robotsTxtContent = $fileIo->read('robots.txt');
|
226 |
+
$siteMapUrl = 'Sitemap:http://magento.instantsearchplus.com/ext_sitemap?u='.$responseData['uuid'].PHP_EOL;
|
227 |
+
$robotsTxtExists = $fileIo->fileExists('robots.txt');
|
228 |
+
$baseDirWritable = $fileIo->isWriteable($baseDir);
|
229 |
+
$siteMapExists = strpos($robotsTxtContent, $siteMapUrl) === false;
|
230 |
+
$robotsTxtWritable = $fileIo->isWriteable('robots.txt');
|
231 |
+
|
232 |
+
if ($robotsTxtExists && $robotsTxtWritable && !$siteMapExists) {
|
233 |
+
$fileIo->write('robots.txt', $robotsTxtContent . $siteMapUrl);
|
234 |
+
} else if (!$robotsTxtExists && $baseDirWritable) {
|
235 |
+
$fileIo->write('robots.txt', $siteMapUrl);
|
236 |
+
} else {
|
237 |
+
$this->_sendError('Unable to properly update robots.txt with ISP Sitemap');
|
238 |
+
}
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Generate Config for AutocompletePlus.
|
243 |
+
*
|
244 |
+
* @param string $UUID
|
245 |
+
* @param string $key
|
246 |
+
*
|
247 |
+
* @return $this
|
248 |
+
*
|
249 |
+
* @throws Zend_Http_Client_Exception
|
250 |
+
*/
|
251 |
+
public function generateConfig($UUID = null, $key = null)
|
252 |
+
{
|
253 |
+
$params = array(
|
254 |
+
'site' => $this->_getHelper()->getConfigDataByFullPath('web/unsecure/base_url'),
|
255 |
+
'email' => Mage::getStoreConfig(self::XML_STORE_EMAIL_CONFIG),
|
256 |
+
'f' => $this->_getHelper()->getVersion(),
|
257 |
+
'multistore' => $this->_getHelper()->getMultiStoreDataJson(),
|
258 |
+
);
|
259 |
+
|
260 |
+
if ($UUID && $key) {
|
261 |
+
$params['uuid'] = $UUID;
|
262 |
+
$params['key'] = $key;
|
263 |
+
}
|
264 |
+
|
265 |
+
$responseData = null;
|
266 |
+
|
267 |
+
// @codingStandardsIgnoreStart
|
268 |
+
/**
|
269 |
+
* Due to backward compatibility issues with Magento < 1.8.1 and cURL/Zend
|
270 |
+
* We need to use PHP's implementation of cURL directly rather than Zend or Varien
|
271 |
+
*/
|
272 |
+
$client = curl_init($this->getEndpoint() . '/install');
|
273 |
+
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
274 |
+
curl_setopt($client, CURLOPT_POSTFIELDS, $params);
|
275 |
+
|
276 |
+
$response = curl_exec($client);
|
277 |
+
curl_close($client);
|
278 |
+
// @codingStandardsIgnoreEnd
|
279 |
+
|
280 |
+
if (!$response && ($key == null || $key == '')) {
|
281 |
+
$notSecureUrl = str_replace('https', 'http', $this->getEndpoint() . '/install');
|
282 |
+
|
283 |
+
$client = curl_init($notSecureUrl);
|
284 |
+
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
285 |
+
curl_setopt($client, CURLOPT_POSTFIELDS, $params);
|
286 |
+
curl_setopt($client, CURLOPT_SSL_VERIFYPEER, 0);
|
287 |
+
curl_setopt($client, CURLOPT_SSL_VERIFYHOST, 0);
|
288 |
+
|
289 |
+
$response = curl_exec($client);
|
290 |
+
curl_close($client);
|
291 |
+
}
|
292 |
+
|
293 |
+
if ($response) {
|
294 |
+
$responseData = json_decode($response, true);
|
295 |
+
|
296 |
+
/*
|
297 |
+
* Validate uuid exists
|
298 |
+
*/
|
299 |
+
if (isset($responseData['uuid']) && strlen($responseData['uuid']) > 50) {
|
300 |
+
Mage::log('Registration failed - please check response below', null, 'autocomplete.log', true);
|
301 |
+
$this->_sendError('Could not get license string.');
|
302 |
+
return false;
|
303 |
+
} elseif (!isset($responseData['uuid'])) {
|
304 |
+
Mage::log('Registration failed - please check response below', null, 'autocomplete.log', true);
|
305 |
+
$this->_sendError('Could not get license string.');
|
306 |
+
return false;
|
307 |
+
}
|
308 |
+
|
309 |
+
$this->_updateRobotsTxt($responseData);
|
310 |
+
}
|
311 |
+
|
312 |
+
if (isset($responseData['authentication_key'])) {
|
313 |
+
$this->setAuthorizationKey($responseData['authentication_key']);
|
314 |
+
$this->setUUID($responseData['uuid']);
|
315 |
+
$this->setSiteUrl($this->_getHelper()->getConfigDataByFullPath('web/unsecure/base_url'));
|
316 |
+
$this->setIsReachable($responseData['is_reachable']);
|
317 |
+
$this->setErrorMessage(isset($errorMessage) ? $errorMessage : '');
|
318 |
+
|
319 |
+
if (!$this->isConfigDataValid($responseData['uuid'], $responseData['authentication_key'])){
|
320 |
+
$this->_sendError('UUID or Authentication key are not valid | got UUID: ' . $responseData['uuid'] .
|
321 |
+
' | authentication_key: ' . $responseData['authentication_key']);
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
|
326 |
+
Mage::dispatchEvent('autocompleteplus_autosuggest_config_creation_after',
|
327 |
+
array('config' => $this, 'response' => $response, 'responseData' => $responseData));
|
328 |
+
|
329 |
+
return $this;
|
330 |
+
}
|
331 |
+
|
332 |
+
/**
|
333 |
+
* Send error to API.
|
334 |
+
*
|
335 |
+
* @param string $message
|
336 |
+
*
|
337 |
+
* @return Zend_Http_Response
|
338 |
+
*
|
339 |
+
* @throws Zend_Http_Client_Exception
|
340 |
+
*/
|
341 |
+
protected function _sendError($message = 'No Message Provided')
|
342 |
+
{
|
343 |
+
$params = array(
|
344 |
+
'site' => $this->_getHelper()->getConfigDataByFullPath('web/unsecure/base_url'),
|
345 |
+
'msg' => $message,
|
346 |
+
'email' => Mage::getStoreConfig(self::XML_STORE_EMAIL_CONFIG),
|
347 |
+
'multistore' => $this->_getHelper()->getMultiStoreDataJson(),
|
348 |
+
'f' => $this->getModuleVersion(),
|
349 |
+
);
|
350 |
+
|
351 |
+
// @codingStandardsIgnoreStart
|
352 |
+
/**
|
353 |
+
* Due to backward compatibility issues with Magento < 1.8.1 and cURL/Zend
|
354 |
+
* We need to use PHP's implementation of cURL directly rather than Zend or Varien
|
355 |
+
*/
|
356 |
+
$client = curl_init($this->getEndpoint() . '/install_error');
|
357 |
+
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
358 |
+
curl_setopt($client, CURLOPT_POSTFIELDS, $params);
|
359 |
+
$response = curl_exec($client);
|
360 |
+
curl_close($client);
|
361 |
+
// @codingStandardsIgnoreEnd
|
362 |
+
return $response;
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Support deprecated functionality - needed? Or can we change the install scripts?
|
367 |
+
*/
|
368 |
+
public function getCollection()
|
369 |
+
{
|
370 |
+
return new Varien_Object(array(
|
371 |
+
'authkey' => $this->getAuthorizationKey(),
|
372 |
+
'licensekey' => $this->getUUID(),
|
373 |
+
));
|
374 |
+
}
|
375 |
+
|
376 |
+
public function isConfigDataValid($input_uuid = null, $input_key = null){
|
377 |
+
$uuid = ($input_uuid) ? $input_uuid : $this->getUUID();
|
378 |
+
$authentication_key = ($input_key) ? $input_key : $this->getAuthorizationKey();
|
379 |
+
|
380 |
+
if (!$uuid || strlen($uuid) != 36 || substr_count($uuid, '-') != 4){
|
381 |
+
return false;
|
382 |
+
}
|
383 |
+
if (!$authentication_key || strlen($authentication_key) == 0){
|
384 |
+
return false;
|
385 |
+
}
|
386 |
+
|
387 |
+
return true;
|
388 |
+
}
|
389 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Layer.php
CHANGED
@@ -1,130 +1,130 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento.
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
*
|
23 |
-
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
class Autocompleteplus_Autosuggest_Model_Layer extends Mage_Catalog_Model_Layer
|
27 |
-
{
|
28 |
-
const XML_PATH_DISPLAY_LAYER_COUNT = 'catalog/search/use_layered_navigation_count';
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Get current layer product collection.
|
32 |
-
*
|
33 |
-
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
|
34 |
-
*/
|
35 |
-
public function getProductCollection()
|
36 |
-
{
|
37 |
-
if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) {
|
38 |
-
$collection = $this->_productCollections[$this->getCurrentCategory()->getId()];
|
39 |
-
} else {
|
40 |
-
$collection = Mage::getResourceModel('catalogsearch/fulltext_collection');
|
41 |
-
$this->prepareProductCollection($collection);
|
42 |
-
$this->_productCollections[$this->getCurrentCategory()->getId()] = $collection;
|
43 |
-
}
|
44 |
-
|
45 |
-
return $collection;
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Prepare product collection.
|
50 |
-
*
|
51 |
-
* @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
|
52 |
-
*
|
53 |
-
* @return Mage_Catalog_Model_Layer
|
54 |
-
*/
|
55 |
-
public function prepareProductCollection($collection)
|
56 |
-
{
|
57 |
-
$collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
|
58 |
-
->addSearchFilter(Mage::helper('catalogsearch')->getQuery()->getQueryText())
|
59 |
-
->setStore(Mage::app()->getStore())
|
60 |
-
->addMinimalPrice()
|
61 |
-
->addFinalPrice()
|
62 |
-
->addTaxPercents()
|
63 |
-
->addStoreFilter()
|
64 |
-
->addUrlRewrite();
|
65 |
-
|
66 |
-
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
|
67 |
-
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
|
68 |
-
|
69 |
-
return $this;
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Get layer state key.
|
74 |
-
*
|
75 |
-
* @return string
|
76 |
-
*/
|
77 |
-
public function getStateKey()
|
78 |
-
{
|
79 |
-
if ($this->_stateKey === null) {
|
80 |
-
$this->_stateKey = 'Q_'.Mage::helper('catalogsearch')->getQuery()->getId()
|
81 |
-
.'_'.parent::getStateKey();
|
82 |
-
}
|
83 |
-
|
84 |
-
return $this->_stateKey;
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Get default tags for current layer state.
|
89 |
-
*
|
90 |
-
* @param array $additionalTags
|
91 |
-
*
|
92 |
-
* @return array
|
93 |
-
*/
|
94 |
-
public function getStateTags(array $additionalTags = array())
|
95 |
-
{
|
96 |
-
$additionalTags = parent::getStateTags($additionalTags);
|
97 |
-
$additionalTags[] = Mage_CatalogSearch_Model_Query::CACHE_TAG;
|
98 |
-
|
99 |
-
return $additionalTags;
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Add filters to attribute collection.
|
104 |
-
*
|
105 |
-
* @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Attribute_Collection $collection
|
106 |
-
*
|
107 |
-
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Attribute_Collection
|
108 |
-
*/
|
109 |
-
protected function _prepareAttributeCollection($collection)
|
110 |
-
{
|
111 |
-
$collection->addIsFilterableInSearchFilter();
|
112 |
-
|
113 |
-
return $collection;
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Prepare attribute for use in layered navigation.
|
118 |
-
*
|
119 |
-
* @param Mage_Eav_Model_Entity_Attribute $attribute
|
120 |
-
*
|
121 |
-
* @return Mage_Eav_Model_Entity_Attribute
|
122 |
-
*/
|
123 |
-
protected function _prepareAttribute($attribute)
|
124 |
-
{
|
125 |
-
$attribute = parent::_prepareAttribute($attribute);
|
126 |
-
$attribute->setIsFilterable(Mage_Catalog_Model_Layer_Filter_Attribute::OPTIONS_ONLY_WITH_RESULTS);
|
127 |
-
|
128 |
-
return $attribute;
|
129 |
-
}
|
130 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
*
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
class Autocompleteplus_Autosuggest_Model_Layer extends Mage_Catalog_Model_Layer
|
27 |
+
{
|
28 |
+
const XML_PATH_DISPLAY_LAYER_COUNT = 'catalog/search/use_layered_navigation_count';
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Get current layer product collection.
|
32 |
+
*
|
33 |
+
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
|
34 |
+
*/
|
35 |
+
public function getProductCollection()
|
36 |
+
{
|
37 |
+
if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) {
|
38 |
+
$collection = $this->_productCollections[$this->getCurrentCategory()->getId()];
|
39 |
+
} else {
|
40 |
+
$collection = Mage::getResourceModel('catalogsearch/fulltext_collection');
|
41 |
+
$this->prepareProductCollection($collection);
|
42 |
+
$this->_productCollections[$this->getCurrentCategory()->getId()] = $collection;
|
43 |
+
}
|
44 |
+
|
45 |
+
return $collection;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Prepare product collection.
|
50 |
+
*
|
51 |
+
* @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
|
52 |
+
*
|
53 |
+
* @return Mage_Catalog_Model_Layer
|
54 |
+
*/
|
55 |
+
public function prepareProductCollection($collection)
|
56 |
+
{
|
57 |
+
$collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
|
58 |
+
->addSearchFilter(Mage::helper('catalogsearch')->getQuery()->getQueryText())
|
59 |
+
->setStore(Mage::app()->getStore())
|
60 |
+
->addMinimalPrice()
|
61 |
+
->addFinalPrice()
|
62 |
+
->addTaxPercents()
|
63 |
+
->addStoreFilter()
|
64 |
+
->addUrlRewrite();
|
65 |
+
|
66 |
+
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
|
67 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
|
68 |
+
|
69 |
+
return $this;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Get layer state key.
|
74 |
+
*
|
75 |
+
* @return string
|
76 |
+
*/
|
77 |
+
public function getStateKey()
|
78 |
+
{
|
79 |
+
if ($this->_stateKey === null) {
|
80 |
+
$this->_stateKey = 'Q_'.Mage::helper('catalogsearch')->getQuery()->getId()
|
81 |
+
.'_'.parent::getStateKey();
|
82 |
+
}
|
83 |
+
|
84 |
+
return $this->_stateKey;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Get default tags for current layer state.
|
89 |
+
*
|
90 |
+
* @param array $additionalTags
|
91 |
+
*
|
92 |
+
* @return array
|
93 |
+
*/
|
94 |
+
public function getStateTags(array $additionalTags = array())
|
95 |
+
{
|
96 |
+
$additionalTags = parent::getStateTags($additionalTags);
|
97 |
+
$additionalTags[] = Mage_CatalogSearch_Model_Query::CACHE_TAG;
|
98 |
+
|
99 |
+
return $additionalTags;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Add filters to attribute collection.
|
104 |
+
*
|
105 |
+
* @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Attribute_Collection $collection
|
106 |
+
*
|
107 |
+
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Attribute_Collection
|
108 |
+
*/
|
109 |
+
protected function _prepareAttributeCollection($collection)
|
110 |
+
{
|
111 |
+
$collection->addIsFilterableInSearchFilter();
|
112 |
+
|
113 |
+
return $collection;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Prepare attribute for use in layered navigation.
|
118 |
+
*
|
119 |
+
* @param Mage_Eav_Model_Entity_Attribute $attribute
|
120 |
+
*
|
121 |
+
* @return Mage_Eav_Model_Entity_Attribute
|
122 |
+
*/
|
123 |
+
protected function _prepareAttribute($attribute)
|
124 |
+
{
|
125 |
+
$attribute = parent::_prepareAttribute($attribute);
|
126 |
+
$attribute->setIsFilterable(Mage_Catalog_Model_Layer_Filter_Attribute::OPTIONS_ONLY_WITH_RESULTS);
|
127 |
+
|
128 |
+
return $attribute;
|
129 |
+
}
|
130 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Batches.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* For Magento < 1.6 backward compatibility
|
5 |
-
*/
|
6 |
-
class Autocompleteplus_Autosuggest_Model_Mysql4_Batches extends Autocompleteplus_Autosuggest_Model_Resource_Batches
|
7 |
-
{
|
8 |
-
|
9 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* For Magento < 1.6 backward compatibility
|
5 |
+
*/
|
6 |
+
class Autocompleteplus_Autosuggest_Model_Mysql4_Batches extends Autocompleteplus_Autosuggest_Model_Resource_Batches
|
7 |
+
{
|
8 |
+
|
9 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Batches/Collection.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* For Magento < 1.6 backward compatibility
|
5 |
-
*/
|
6 |
-
class Autocompleteplus_Autosuggest_Model_Mysql4_Batches_Collection extends Autocompleteplus_Autosuggest_Model_Resource_Batches_Collection
|
7 |
-
{
|
8 |
-
|
9 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* For Magento < 1.6 backward compatibility
|
5 |
+
*/
|
6 |
+
class Autocompleteplus_Autosuggest_Model_Mysql4_Batches_Collection extends Autocompleteplus_Autosuggest_Model_Resource_Batches_Collection
|
7 |
+
{
|
8 |
+
|
9 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Checksum.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* For Magento < 1.6 backward compatibility
|
5 |
-
*/
|
6 |
-
class Autocompleteplus_Autosuggest_Model_Mysql4_Checksum extends Autocompleteplus_Autosuggest_Model_Resource_Checksum
|
7 |
-
{
|
8 |
-
|
9 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* For Magento < 1.6 backward compatibility
|
5 |
+
*/
|
6 |
+
class Autocompleteplus_Autosuggest_Model_Mysql4_Checksum extends Autocompleteplus_Autosuggest_Model_Resource_Checksum
|
7 |
+
{
|
8 |
+
|
9 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Checksum/Collection.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* For Magento < 1.6 backward compatibility
|
5 |
-
*/
|
6 |
-
class Autocompleteplus_Autosuggest_Model_Mysql4_Checksum_Collection extends Autocompleteplus_Autosuggest_Model_Resource_Checksum_Collection
|
7 |
-
{
|
8 |
-
|
9 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* For Magento < 1.6 backward compatibility
|
5 |
+
*/
|
6 |
+
class Autocompleteplus_Autosuggest_Model_Mysql4_Checksum_Collection extends Autocompleteplus_Autosuggest_Model_Resource_Checksum_Collection
|
7 |
+
{
|
8 |
+
|
9 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Fulltext/Collection.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* For Magento < 1.6 backward compatibility
|
5 |
-
*/
|
6 |
-
class Autocompleteplus_Autosuggest_Model_Mysql4_Fulltext_Collection extends Autocompleteplus_Autosuggest_Model_Resource_Fulltext_Collection
|
7 |
-
{
|
8 |
-
|
9 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* For Magento < 1.6 backward compatibility
|
5 |
+
*/
|
6 |
+
class Autocompleteplus_Autosuggest_Model_Mysql4_Fulltext_Collection extends Autocompleteplus_Autosuggest_Model_Resource_Fulltext_Collection
|
7 |
+
{
|
8 |
+
|
9 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Notifications.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* For Magento < 1.6 backward compatibility
|
5 |
-
*/
|
6 |
-
class Autocompleteplus_Autosuggest_Model_Mysql4_Notifications extends Autocompleteplus_Autosuggest_Model_Resource_Notifications
|
7 |
-
{
|
8 |
-
|
9 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* For Magento < 1.6 backward compatibility
|
5 |
+
*/
|
6 |
+
class Autocompleteplus_Autosuggest_Model_Mysql4_Notifications extends Autocompleteplus_Autosuggest_Model_Resource_Notifications
|
7 |
+
{
|
8 |
+
|
9 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Notifications/Collection.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* For Magento < 1.6 backward compatibility
|
5 |
-
*/
|
6 |
-
class Autocompleteplus_Autosuggest_Model_Mysql4_Notifications_Collection extends Autocompleteplus_Autosuggest_Model_Resource_Notifications_Collection
|
7 |
-
{
|
8 |
-
|
9 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* For Magento < 1.6 backward compatibility
|
5 |
+
*/
|
6 |
+
class Autocompleteplus_Autosuggest_Model_Mysql4_Notifications_Collection extends Autocompleteplus_Autosuggest_Model_Resource_Notifications_Collection
|
7 |
+
{
|
8 |
+
|
9 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Pusher.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* For Magento < 1.6 backward compatibility
|
5 |
-
*/
|
6 |
-
class Autocompleteplus_Autosuggest_Model_Mysql4_Pusher extends Autocompleteplus_Autosuggest_Model_Resource_Pusher
|
7 |
-
{
|
8 |
-
|
9 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* For Magento < 1.6 backward compatibility
|
5 |
+
*/
|
6 |
+
class Autocompleteplus_Autosuggest_Model_Mysql4_Pusher extends Autocompleteplus_Autosuggest_Model_Resource_Pusher
|
7 |
+
{
|
8 |
+
|
9 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Pusher/Collection.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* For Magento < 1.6 backward compatibility
|
5 |
-
*/
|
6 |
-
class Autocompleteplus_Autosuggest_Model_Mysql4_Pusher_Collection extends Autocompleteplus_Autosuggest_Model_Resource_Pusher_Collection
|
7 |
-
{
|
8 |
-
|
9 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* For Magento < 1.6 backward compatibility
|
5 |
+
*/
|
6 |
+
class Autocompleteplus_Autosuggest_Model_Mysql4_Pusher_Collection extends Autocompleteplus_Autosuggest_Model_Resource_Pusher_Collection
|
7 |
+
{
|
8 |
+
|
9 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Notifications.php
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* InstantSearchPlus (Autosuggest).
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is available through the world-wide-web at this URL:
|
9 |
-
* http://opensource.org/licenses/osl-3.0.php
|
10 |
-
*
|
11 |
-
* @category Mage
|
12 |
-
*
|
13 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
class Autocompleteplus_Autosuggest_Model_Notifications extends Mage_Core_Model_Abstract
|
17 |
-
{
|
18 |
-
protected function _construct()
|
19 |
-
{
|
20 |
-
$this->_init('autocompleteplus_autosuggest/notifications');
|
21 |
-
}
|
22 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* InstantSearchPlus (Autosuggest).
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Mage
|
12 |
+
*
|
13 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
class Autocompleteplus_Autosuggest_Model_Notifications extends Mage_Core_Model_Abstract
|
17 |
+
{
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
$this->_init('autocompleteplus_autosuggest/notifications');
|
21 |
+
}
|
22 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Observer.php
CHANGED
@@ -1,549 +1,549 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* InstantSearchPlus (Autosuggest).
|
5 |
-
*
|
6 |
-
* NOTICE OF LICENSE
|
7 |
-
*
|
8 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
-
* that is available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
*
|
12 |
-
* @category Mage
|
13 |
-
*
|
14 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
15 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
-
*/
|
17 |
-
class Autocompleteplus_Autosuggest_Model_Observer extends Mage_Core_Model_Abstract
|
18 |
-
{
|
19 |
-
const AUTOCOMPLETEPLUS_WEBHOOK_URI = 'https://acp-magento.appspot.com/ma_webhook';
|
20 |
-
const API_UPDATE_URI = 'http://magento.autocompleteplus.com/update';
|
21 |
-
const WEBHOOK_CURL_TIMEOUT_LENGTH = 2;
|
22 |
-
|
23 |
-
protected $imageField;
|
24 |
-
protected $standardImageFields = array();
|
25 |
-
protected $currency;
|
26 |
-
|
27 |
-
public function _construct()
|
28 |
-
{
|
29 |
-
$this->imageField = Mage::getStoreConfig('autocompleteplus/config/imagefield');
|
30 |
-
if (!$this->imageField) {
|
31 |
-
$this->imageField = 'thumbnail';
|
32 |
-
}
|
33 |
-
|
34 |
-
$this->standardImageFields = array('image', 'small_image', 'thumbnail');
|
35 |
-
$this->currency = Mage::app()->getStore()->getCurrentCurrencyCode();
|
36 |
-
}
|
37 |
-
|
38 |
-
public function getConfig()
|
39 |
-
{
|
40 |
-
return Mage::getModel('autocompleteplus_autosuggest/config');
|
41 |
-
}
|
42 |
-
|
43 |
-
protected function _generateProductXml($product)
|
44 |
-
{
|
45 |
-
$catalog = new SimpleXMLElement('<catalog></catalog>');
|
46 |
-
try {
|
47 |
-
if (in_array($this->imageField, $this->standardImageFields)) {
|
48 |
-
$productImage = Mage::helper('catalog/image')->init($product, $this->imageField);
|
49 |
-
} else {
|
50 |
-
$function = 'get'.$this->imageField;
|
51 |
-
$productImage = $product->$function();
|
52 |
-
}
|
53 |
-
} catch (Exception $e) {
|
54 |
-
$productImage = '';
|
55 |
-
}
|
56 |
-
$productUrl = Mage::helper('catalog/product')->getProductUrl($product->getId());
|
57 |
-
$status = $product->isInStock();
|
58 |
-
$stockItem = $product->getStockItem();
|
59 |
-
if ($stockItem && $stockItem->getIsInStock() && $status) {
|
60 |
-
$saleable = 1;
|
61 |
-
} else {
|
62 |
-
$saleable = 0;
|
63 |
-
}
|
64 |
-
|
65 |
-
// Add Magento Module Version attribute
|
66 |
-
$catalog->addAttribute('version', $this->getConfig()->getModuleVersion());
|
67 |
-
|
68 |
-
// Add Magento Version attribute
|
69 |
-
$catalog->addAttribute('magento', Mage::getVersion());
|
70 |
-
|
71 |
-
// Create product child
|
72 |
-
$productChild = $catalog->addChild('product');
|
73 |
-
|
74 |
-
$productChild->addAttribute('store', $product->getStoreId());
|
75 |
-
$productChild->addAttribute('currency', $this->currency);
|
76 |
-
$productChild->addAttribute('visibility', $product->getVisibility());
|
77 |
-
$productChild->addAttribute('price', $this->_getPrice($product));
|
78 |
-
$productChild->addAttribute('url', $productUrl);
|
79 |
-
$productChild->addAttribute('thumbs', $productImage);
|
80 |
-
$productChild->addAttribute('selleable', $saleable);
|
81 |
-
$productChild->addAttribute('action', 'update');
|
82 |
-
|
83 |
-
$productChild->addChild('description', '<![CDATA['.$product->getDescription().']]>');
|
84 |
-
$productChild->addChild('short', '<![CDATA['.$product->getShortDescription().']]>');
|
85 |
-
$productChild->addChild('name', '<![CDATA['.$product->getName().']]>');
|
86 |
-
$productChild->addChild('sku', '<![CDATA['.$product->getSku().']]>');
|
87 |
-
|
88 |
-
return $catalog->asXML();
|
89 |
-
}
|
90 |
-
|
91 |
-
public function catalog_product_save_after_depr($observer)
|
92 |
-
{
|
93 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
94 |
-
$product = $observer->getProduct();
|
95 |
-
$this->imageField = Mage::getStoreConfig('autocompleteplus/config/imagefield');
|
96 |
-
if (!$this->imageField) {
|
97 |
-
$this->imageField = 'thumbnail';
|
98 |
-
}
|
99 |
-
$this->standardImageFields = array('image', 'small_image', 'thumbnail');
|
100 |
-
$this->currency = Mage::app()->getStore()->getCurrentCurrencyCode();
|
101 |
-
$domain = Mage::getStoreConfig('web/unsecure/base_url');
|
102 |
-
$key = $this->getConfig()->getUUID();
|
103 |
-
|
104 |
-
$xml = $this->_generateProductXml($product);
|
105 |
-
$data = array(
|
106 |
-
'site' => $domain,
|
107 |
-
'key' => $key,
|
108 |
-
'catalog' => $xml,
|
109 |
-
);
|
110 |
-
$res = $this->_sendUpdate($data);
|
111 |
-
Mage::log($res, null, 'autocomplete.log');
|
112 |
-
}
|
113 |
-
|
114 |
-
protected function _getPrice($product)
|
115 |
-
{
|
116 |
-
$price = 0;
|
117 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
118 |
-
if ($product->getTypeId() == 'grouped') {
|
119 |
-
$helper->prepareGroupedProductPrice($product);
|
120 |
-
$_minimalPriceValue = $product->getPrice();
|
121 |
-
if ($_minimalPriceValue) {
|
122 |
-
$price = $_minimalPriceValue;
|
123 |
-
}
|
124 |
-
} elseif ($product->getTypeId() == 'bundle') {
|
125 |
-
if (!$product->getFinalPrice()) {
|
126 |
-
$price = $helper->getBundlePrice($product);
|
127 |
-
} else {
|
128 |
-
$price = $product->getFinalPrice();
|
129 |
-
}
|
130 |
-
} else {
|
131 |
-
$price = $product->getFinalPrice();
|
132 |
-
}
|
133 |
-
if (!$price) {
|
134 |
-
$price = 0;
|
135 |
-
}
|
136 |
-
|
137 |
-
return $price;
|
138 |
-
}
|
139 |
-
|
140 |
-
protected function _sendUpdate($data)
|
141 |
-
{
|
142 |
-
// @codingStandardsIgnoreStart
|
143 |
-
$client = curl_init(self::API_UPDATE_URI);
|
144 |
-
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
145 |
-
curl_setopt($client, CURLOPT_POSTFIELDS, $data);
|
146 |
-
$response = curl_exec($client);
|
147 |
-
curl_close($client);
|
148 |
-
// @codingStandardsIgnoreEnd
|
149 |
-
return $response;
|
150 |
-
}
|
151 |
-
|
152 |
-
public function catalog_product_save_after($observer)
|
153 |
-
{
|
154 |
-
$product = $observer->getProduct();
|
155 |
-
$origData = $observer->getProduct()->getOrigData();
|
156 |
-
$storeId = $product->getStoreId();
|
157 |
-
$productId = $product->getId();
|
158 |
-
$sku = $product->getSku();
|
159 |
-
if (is_array($origData) &&
|
160 |
-
array_key_exists('sku', $origData)) {
|
161 |
-
$oldSku = $origData['sku'];
|
162 |
-
if ($sku != $oldSku) {
|
163 |
-
$this->_writeproductDeletion($oldSku, $productId, $storeId, $product);
|
164 |
-
}
|
165 |
-
}
|
166 |
-
$dt = Mage::getSingleton('core/date')->gmtTimestamp();
|
167 |
-
|
168 |
-
$simple_product_parents = ($product->getTypeID() == 'simple') ? Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId()) : array();
|
169 |
-
|
170 |
-
$product_stores = ($storeId == 0 && method_exists($product, 'getStoreIds')) ? $product->getStoreIds() : array($storeId);
|
171 |
-
|
172 |
-
try {
|
173 |
-
foreach ($product_stores as $product_store) {
|
174 |
-
$updates = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()
|
175 |
-
->addFieldToFilter('product_id', $productId)
|
176 |
-
->addFieldToFilter('store_id', $product_store);
|
177 |
-
|
178 |
-
$updates->getSelect()
|
179 |
-
->order('update_date','DESC')
|
180 |
-
->limit(1);
|
181 |
-
|
182 |
-
if ($updates && $updates->getSize() > 0) {
|
183 |
-
// @codingStandardsIgnoreLine
|
184 |
-
$row = $updates->getFirstItem();
|
185 |
-
|
186 |
-
$row->setUpdateDate($dt)
|
187 |
-
->setAction('update');
|
188 |
-
|
189 |
-
// @codingStandardsIgnoreLine
|
190 |
-
$row->save();
|
191 |
-
} else {
|
192 |
-
$batch = Mage::getModel('autocompleteplus_autosuggest/batches');
|
193 |
-
$batch->setProductId($productId)
|
194 |
-
->setStoreId($product_store)
|
195 |
-
->setUpdateDate($dt)
|
196 |
-
->setAction('update')
|
197 |
-
->setSku($sku);
|
198 |
-
|
199 |
-
// @codingStandardsIgnoreLine
|
200 |
-
$batch->save();
|
201 |
-
}
|
202 |
-
try {
|
203 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
204 |
-
$checksum = $helper->calculateChecksum($product);
|
205 |
-
$helper->updateSavedProductChecksum($productId, $sku, $product_store, $checksum);
|
206 |
-
} catch (Exception $e) {
|
207 |
-
Mage::logException($e);
|
208 |
-
}
|
209 |
-
|
210 |
-
// trigger update for simple product's configurable parent
|
211 |
-
if (!empty($simple_product_parents)) { // simple product has configural parent
|
212 |
-
foreach ($simple_product_parents as $configurable_product) {
|
213 |
-
|
214 |
-
$batches = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()
|
215 |
-
->addFieldToFilter('product_id', $configurable_product)
|
216 |
-
->addFieldToFilter('store_id', $product_store);
|
217 |
-
|
218 |
-
$batches->getSelect()
|
219 |
-
->order('update_date','DESC')
|
220 |
-
->limit(1);
|
221 |
-
|
222 |
-
// @codingStandardsIgnoreLine
|
223 |
-
if ($batches->getSize() > 0) {
|
224 |
-
$batch = $batches->getFirstItem();
|
225 |
-
$batch->setUpdateDate($dt)
|
226 |
-
->setAction('update')
|
227 |
-
// @codingStandardsIgnoreLine
|
228 |
-
->save();
|
229 |
-
} else {
|
230 |
-
$newBatch = Mage::getModel('autocompleteplus_autosuggest/batches');
|
231 |
-
$newBatch->setProductId($configurable_product)
|
232 |
-
->setStoreId($product_store)
|
233 |
-
->setUpdateDate($dt)
|
234 |
-
->setAction('update')
|
235 |
-
->setSku('ISP_NO_SKU')
|
236 |
-
// @codingStandardsIgnoreLine
|
237 |
-
->save();
|
238 |
-
}
|
239 |
-
}
|
240 |
-
}
|
241 |
-
}
|
242 |
-
} catch (Exception $e) {
|
243 |
-
Mage::logException($e);
|
244 |
-
}
|
245 |
-
}
|
246 |
-
|
247 |
-
public function catalog_product_save_after_real($observer)
|
248 |
-
{
|
249 |
-
$product = $observer->getProduct();
|
250 |
-
|
251 |
-
$productId = $product->getId();
|
252 |
-
|
253 |
-
$sku = $product->getSku();
|
254 |
-
|
255 |
-
try {
|
256 |
-
|
257 |
-
$updates = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()
|
258 |
-
->addFieldToFilter('product_id', array('null' => true))
|
259 |
-
->addFieldToFilter('sku', $sku)
|
260 |
-
;
|
261 |
-
|
262 |
-
foreach ($updates as $update) {
|
263 |
-
$update->setProductId($productId);
|
264 |
-
|
265 |
-
$update->save();
|
266 |
-
}
|
267 |
-
|
268 |
-
} catch (Exception $e) {
|
269 |
-
Mage::logException($e);
|
270 |
-
}
|
271 |
-
}
|
272 |
-
|
273 |
-
protected function _writeproductDeletion($sku, $productId, $storeId, $product = null)
|
274 |
-
{
|
275 |
-
$dt = strtotime('now');
|
276 |
-
try {
|
277 |
-
try {
|
278 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
279 |
-
try {
|
280 |
-
if (!$product) {
|
281 |
-
$product = Mage::getModel('catalog/product')->load($productId);
|
282 |
-
}
|
283 |
-
$product_stores = ($storeId == 0 && method_exists($product, 'getStoreIds')) ? $product->getStoreIds() : array($storeId);
|
284 |
-
} catch (Exception $e) {
|
285 |
-
Mage::logException($e);
|
286 |
-
$product_stores = array($storeId);
|
287 |
-
}
|
288 |
-
if ($sku == null) {
|
289 |
-
$sku = 'dummy_sku';
|
290 |
-
}
|
291 |
-
foreach ($product_stores as $product_store) {
|
292 |
-
$batches = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()
|
293 |
-
->addFieldToFilter('product_id', $productId)
|
294 |
-
->addFieldToFilter('store_id', $product_store);
|
295 |
-
|
296 |
-
$batches->getSelect()
|
297 |
-
->order('update_date','DESC')
|
298 |
-
->limit(1);
|
299 |
-
|
300 |
-
// @codingStandardsIgnoreLine
|
301 |
-
if ($batches->getSize() > 0) {
|
302 |
-
$batch = $batches->getFirstItem();
|
303 |
-
$batch->setUpdateDate($dt)
|
304 |
-
->setAction('remove')
|
305 |
-
// @codingStandardsIgnoreLine
|
306 |
-
->save();
|
307 |
-
} else {
|
308 |
-
$newBatch = Mage::getModel('autocompleteplus_autosuggest/batches');
|
309 |
-
$newBatch->setProductId($productId)
|
310 |
-
->setStoreId($product_store)
|
311 |
-
->setUpdateDate($dt)
|
312 |
-
->setAction('remove')
|
313 |
-
->setSku($sku)
|
314 |
-
// @codingStandardsIgnoreLine
|
315 |
-
->save();
|
316 |
-
}
|
317 |
-
$helper->updateDeletedProductChecksum($productId, $sku, $product_store);
|
318 |
-
}
|
319 |
-
} catch (Exception $e) {
|
320 |
-
Mage::logException($e);
|
321 |
-
}
|
322 |
-
} catch (Exception $e) {
|
323 |
-
Mage::logException($e);
|
324 |
-
}
|
325 |
-
}
|
326 |
-
|
327 |
-
public function catalog_product_delete_before($observer)
|
328 |
-
{
|
329 |
-
$product = $observer->getProduct();
|
330 |
-
$storeId = $product->getStoreId();
|
331 |
-
$productId = $product->getId();
|
332 |
-
$sku = $product->getSku();
|
333 |
-
$this->_writeproductDeletion($sku, $productId, $storeId, $product);
|
334 |
-
}
|
335 |
-
|
336 |
-
public function adminSessionUserLoginSuccess()
|
337 |
-
{
|
338 |
-
$notifications = array();
|
339 |
-
/** @var Autocompleteplus_Autosuggest_Helper_Data $helper */
|
340 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
341 |
-
$command = 'http://magento.autocompleteplus.com/ext_info?u='.$this->getConfig()->getUUID();
|
342 |
-
$res = $helper->sendCurl($command);
|
343 |
-
$result = json_decode($res);
|
344 |
-
if (isset($result->alerts)) {
|
345 |
-
foreach ($result->alerts as $alert) {
|
346 |
-
$notification = array(
|
347 |
-
'type' => (string) $alert->type,
|
348 |
-
'message' => (string) $alert->message,
|
349 |
-
'timestamp' => (string) $alert->timestamp,
|
350 |
-
);
|
351 |
-
if (isset($alert->subject)) {
|
352 |
-
$notification['subject'] = (string) $alert->subject;
|
353 |
-
}
|
354 |
-
$notifications[] = $notification;
|
355 |
-
}
|
356 |
-
}
|
357 |
-
if (!empty($notifications)) {
|
358 |
-
Mage::getResourceModel('autocompleteplus_autosuggest/notifications')->addNotifications($notifications);
|
359 |
-
}
|
360 |
-
$this->sendNotificationMails();
|
361 |
-
}
|
362 |
-
|
363 |
-
public function sendNotificationMails()
|
364 |
-
{
|
365 |
-
/** @var Autocompleteplus_Autosuggest_Model_Mysql4_Notifications_Collection $notifications */
|
366 |
-
$notifications = Mage::getModel('autocompleteplus_autosuggest/notifications')->getCollection();
|
367 |
-
$notifications->addTypeFilter('email')->addActiveFilter();
|
368 |
-
foreach ($notifications as $notification) {
|
369 |
-
$this->_sendStatusMail($notification);
|
370 |
-
}
|
371 |
-
}
|
372 |
-
|
373 |
-
/**
|
374 |
-
* @param Autocompleteplus_Autosuggest_Model_Notifications $notification
|
375 |
-
*/
|
376 |
-
protected function _sendStatusMail($notification)
|
377 |
-
{
|
378 |
-
/** @var Autocompleteplus_Autosuggest_Helper_Data $helper */
|
379 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
380 |
-
// Getting site owner email
|
381 |
-
$storeMail = $helper->getConfigDataByFullPath('autocompleteplus/config/store_email');
|
382 |
-
if ($storeMail) {
|
383 |
-
$emailTemplate = Mage::getModel('core/email_template');
|
384 |
-
$emailTemplate->loadDefault('autosuggest_status_notification');
|
385 |
-
$emailTemplate->setTemplateSubject($notification->getSubject());
|
386 |
-
// Get General email address (Admin->Configuration->General->Store Email Addresses)
|
387 |
-
$emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_general/email'));
|
388 |
-
$emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_general/name'));
|
389 |
-
$emailTemplateVariables['message'] = $notification->getMessage();
|
390 |
-
$emailTemplate->send($storeMail, null, $emailTemplateVariables);
|
391 |
-
$notification->setIsActive(0)
|
392 |
-
->save();
|
393 |
-
}
|
394 |
-
}
|
395 |
-
|
396 |
-
/**
|
397 |
-
* The generic webhook service caller.
|
398 |
-
*
|
399 |
-
* @param Varien_Event_Observer $observer
|
400 |
-
*/
|
401 |
-
public function webhook_service_call()
|
402 |
-
{
|
403 |
-
// @codingStandardsIgnoreStart
|
404 |
-
/**
|
405 |
-
* Due to backward compatibility issues with Magento < 1.8.1 and cURL/Zend
|
406 |
-
* We need to use PHP's implementation of cURL directly rather than Zend or Varien
|
407 |
-
*/
|
408 |
-
$client = curl_init($this->_getWebhookObjectUri());
|
409 |
-
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
410 |
-
$response = curl_exec($client);
|
411 |
-
curl_close($client);
|
412 |
-
// @codingStandardsIgnoreEnd
|
413 |
-
return $response;
|
414 |
-
}
|
415 |
-
|
416 |
-
/**
|
417 |
-
* Create the webhook URI.
|
418 |
-
*
|
419 |
-
* @return string
|
420 |
-
*/
|
421 |
-
protected function _getWebhookObjectUri()
|
422 |
-
{
|
423 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
424 |
-
$parameters = array(
|
425 |
-
'event' => $this->getWebhookEventLabel(),
|
426 |
-
'UUID' => $this->getConfig()->getUUID(),
|
427 |
-
'key' => $this->getConfig()->getAuthorizationKey(),
|
428 |
-
'store_id' => Mage::app()->getStore()->getStoreId(),
|
429 |
-
'st' => $helper->getSessionId(),
|
430 |
-
'cart_token' => $this->getQuoteId(),
|
431 |
-
'serp' => '',
|
432 |
-
'cart_product' => $this->getCartContentsAsJson(),
|
433 |
-
);
|
434 |
-
|
435 |
-
return static::AUTOCOMPLETEPLUS_WEBHOOK_URI.'?'.http_build_query($parameters, '', '&');
|
436 |
-
}
|
437 |
-
|
438 |
-
/**
|
439 |
-
* Return a label for webhooks based on the current
|
440 |
-
* controller route. This cannot be handled by layout
|
441 |
-
* XML because the layout engine may not be init in all
|
442 |
-
* future uses of the webhook.
|
443 |
-
*
|
444 |
-
* @return string|void
|
445 |
-
*/
|
446 |
-
public function getWebhookEventLabel()
|
447 |
-
{
|
448 |
-
$request = Mage::app()->getRequest();
|
449 |
-
$route = $request->getRouteName();
|
450 |
-
$controller = $request->getControllerName();
|
451 |
-
$action = $request->getActionName();
|
452 |
-
if ($route != 'checkout') {
|
453 |
-
return;
|
454 |
-
}
|
455 |
-
if ($controller == 'cart' && $action == 'index') {
|
456 |
-
return 'cart';
|
457 |
-
}
|
458 |
-
if ($controller == 'onepage' && $action == 'index') {
|
459 |
-
return 'checkout';
|
460 |
-
}
|
461 |
-
if ($controller == 'onepage' && $action == 'success') {
|
462 |
-
return 'success';
|
463 |
-
}
|
464 |
-
}
|
465 |
-
|
466 |
-
/**
|
467 |
-
* Returns the quote id if it exists, otherwise it will
|
468 |
-
* return the last order id. This only is set in the session
|
469 |
-
* when an order has been recently completed. Therefore
|
470 |
-
* this call may also return null.
|
471 |
-
*
|
472 |
-
* @return string|null
|
473 |
-
*/
|
474 |
-
public function getQuoteId()
|
475 |
-
{
|
476 |
-
if ($quoteId = Mage::getSingleton('checkout/session')->getQuoteId()) {
|
477 |
-
return $quoteId;
|
478 |
-
}
|
479 |
-
|
480 |
-
return $this->getOrder()->getQuoteId();
|
481 |
-
}
|
482 |
-
|
483 |
-
/**
|
484 |
-
* Get the order associated with the previous quote id
|
485 |
-
* used as a fallback when the quote is no longer available.
|
486 |
-
*
|
487 |
-
* @return Mage_Sales_Model_Order
|
488 |
-
*/
|
489 |
-
public function getOrder()
|
490 |
-
{
|
491 |
-
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
|
492 |
-
|
493 |
-
return Mage::getModel('sales/order')->load($orderId);
|
494 |
-
}
|
495 |
-
|
496 |
-
/**
|
497 |
-
* JSON encode the cart contents.
|
498 |
-
*
|
499 |
-
* @return string
|
500 |
-
*/
|
501 |
-
public function getCartContentsAsJson()
|
502 |
-
{
|
503 |
-
return json_encode($this->_getVisibleItems());
|
504 |
-
}
|
505 |
-
|
506 |
-
/**
|
507 |
-
* Format visible cart contents into a multidimensional keyed array.
|
508 |
-
*
|
509 |
-
* @return array
|
510 |
-
*/
|
511 |
-
protected function _getVisibleItems()
|
512 |
-
{
|
513 |
-
if ($cartItems = Mage::getSingleton('checkout/session')->getQuote()->getAllVisibleItems()) {
|
514 |
-
return $this->_buildCartArray($cartItems);
|
515 |
-
}
|
516 |
-
|
517 |
-
return $this->_buildCartArray($this->getOrder()->getAllVisibleItems());
|
518 |
-
}
|
519 |
-
|
520 |
-
/**
|
521 |
-
* Return a formatted array of quote or order items.
|
522 |
-
*
|
523 |
-
* @param array $cartItems
|
524 |
-
*
|
525 |
-
* @return array
|
526 |
-
*/
|
527 |
-
protected function _buildCartArray($cartItems)
|
528 |
-
{
|
529 |
-
$items = array();
|
530 |
-
foreach ($cartItems as $item) {
|
531 |
-
if ($item instanceof Mage_Sales_Model_Order_Item) {
|
532 |
-
$quantity = (int) $item->getQtyOrdered();
|
533 |
-
} else {
|
534 |
-
$quantity = $item->getQty();
|
535 |
-
}
|
536 |
-
if (is_object($item->getProduct())) { // Fatal error fix: Call to a member function getId() on a non-object
|
537 |
-
$items[] = array(
|
538 |
-
'product_id' => $item->getProduct()->getId(),
|
539 |
-
'price' => $item->getProduct()->getFinalPrice(),
|
540 |
-
'quantity' => $quantity,
|
541 |
-
'currency' => Mage::app()->getStore()->getCurrentCurrencyCode(),
|
542 |
-
'attribution' => $item->getAddedFromSearch(),
|
543 |
-
);
|
544 |
-
}
|
545 |
-
}
|
546 |
-
|
547 |
-
return $items;
|
548 |
-
}
|
549 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* InstantSearchPlus (Autosuggest).
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* @category Mage
|
13 |
+
*
|
14 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
class Autocompleteplus_Autosuggest_Model_Observer extends Mage_Core_Model_Abstract
|
18 |
+
{
|
19 |
+
const AUTOCOMPLETEPLUS_WEBHOOK_URI = 'https://acp-magento.appspot.com/ma_webhook';
|
20 |
+
const API_UPDATE_URI = 'http://magento.autocompleteplus.com/update';
|
21 |
+
const WEBHOOK_CURL_TIMEOUT_LENGTH = 2;
|
22 |
+
|
23 |
+
protected $imageField;
|
24 |
+
protected $standardImageFields = array();
|
25 |
+
protected $currency;
|
26 |
+
|
27 |
+
public function _construct()
|
28 |
+
{
|
29 |
+
$this->imageField = Mage::getStoreConfig('autocompleteplus/config/imagefield');
|
30 |
+
if (!$this->imageField) {
|
31 |
+
$this->imageField = 'thumbnail';
|
32 |
+
}
|
33 |
+
|
34 |
+
$this->standardImageFields = array('image', 'small_image', 'thumbnail');
|
35 |
+
$this->currency = Mage::app()->getStore()->getCurrentCurrencyCode();
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getConfig()
|
39 |
+
{
|
40 |
+
return Mage::getModel('autocompleteplus_autosuggest/config');
|
41 |
+
}
|
42 |
+
|
43 |
+
protected function _generateProductXml($product)
|
44 |
+
{
|
45 |
+
$catalog = new SimpleXMLElement('<catalog></catalog>');
|
46 |
+
try {
|
47 |
+
if (in_array($this->imageField, $this->standardImageFields)) {
|
48 |
+
$productImage = Mage::helper('catalog/image')->init($product, $this->imageField);
|
49 |
+
} else {
|
50 |
+
$function = 'get'.$this->imageField;
|
51 |
+
$productImage = $product->$function();
|
52 |
+
}
|
53 |
+
} catch (Exception $e) {
|
54 |
+
$productImage = '';
|
55 |
+
}
|
56 |
+
$productUrl = Mage::helper('catalog/product')->getProductUrl($product->getId());
|
57 |
+
$status = $product->isInStock();
|
58 |
+
$stockItem = $product->getStockItem();
|
59 |
+
if ($stockItem && $stockItem->getIsInStock() && $status) {
|
60 |
+
$saleable = 1;
|
61 |
+
} else {
|
62 |
+
$saleable = 0;
|
63 |
+
}
|
64 |
+
|
65 |
+
// Add Magento Module Version attribute
|
66 |
+
$catalog->addAttribute('version', $this->getConfig()->getModuleVersion());
|
67 |
+
|
68 |
+
// Add Magento Version attribute
|
69 |
+
$catalog->addAttribute('magento', Mage::getVersion());
|
70 |
+
|
71 |
+
// Create product child
|
72 |
+
$productChild = $catalog->addChild('product');
|
73 |
+
|
74 |
+
$productChild->addAttribute('store', $product->getStoreId());
|
75 |
+
$productChild->addAttribute('currency', $this->currency);
|
76 |
+
$productChild->addAttribute('visibility', $product->getVisibility());
|
77 |
+
$productChild->addAttribute('price', $this->_getPrice($product));
|
78 |
+
$productChild->addAttribute('url', $productUrl);
|
79 |
+
$productChild->addAttribute('thumbs', $productImage);
|
80 |
+
$productChild->addAttribute('selleable', $saleable);
|
81 |
+
$productChild->addAttribute('action', 'update');
|
82 |
+
|
83 |
+
$productChild->addChild('description', '<![CDATA['.$product->getDescription().']]>');
|
84 |
+
$productChild->addChild('short', '<![CDATA['.$product->getShortDescription().']]>');
|
85 |
+
$productChild->addChild('name', '<![CDATA['.$product->getName().']]>');
|
86 |
+
$productChild->addChild('sku', '<![CDATA['.$product->getSku().']]>');
|
87 |
+
|
88 |
+
return $catalog->asXML();
|
89 |
+
}
|
90 |
+
|
91 |
+
public function catalog_product_save_after_depr($observer)
|
92 |
+
{
|
93 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
94 |
+
$product = $observer->getProduct();
|
95 |
+
$this->imageField = Mage::getStoreConfig('autocompleteplus/config/imagefield');
|
96 |
+
if (!$this->imageField) {
|
97 |
+
$this->imageField = 'thumbnail';
|
98 |
+
}
|
99 |
+
$this->standardImageFields = array('image', 'small_image', 'thumbnail');
|
100 |
+
$this->currency = Mage::app()->getStore()->getCurrentCurrencyCode();
|
101 |
+
$domain = Mage::getStoreConfig('web/unsecure/base_url');
|
102 |
+
$key = $this->getConfig()->getUUID();
|
103 |
+
|
104 |
+
$xml = $this->_generateProductXml($product);
|
105 |
+
$data = array(
|
106 |
+
'site' => $domain,
|
107 |
+
'key' => $key,
|
108 |
+
'catalog' => $xml,
|
109 |
+
);
|
110 |
+
$res = $this->_sendUpdate($data);
|
111 |
+
Mage::log($res, null, 'autocomplete.log');
|
112 |
+
}
|
113 |
+
|
114 |
+
protected function _getPrice($product)
|
115 |
+
{
|
116 |
+
$price = 0;
|
117 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
118 |
+
if ($product->getTypeId() == 'grouped') {
|
119 |
+
$helper->prepareGroupedProductPrice($product);
|
120 |
+
$_minimalPriceValue = $product->getPrice();
|
121 |
+
if ($_minimalPriceValue) {
|
122 |
+
$price = $_minimalPriceValue;
|
123 |
+
}
|
124 |
+
} elseif ($product->getTypeId() == 'bundle') {
|
125 |
+
if (!$product->getFinalPrice()) {
|
126 |
+
$price = $helper->getBundlePrice($product);
|
127 |
+
} else {
|
128 |
+
$price = $product->getFinalPrice();
|
129 |
+
}
|
130 |
+
} else {
|
131 |
+
$price = $product->getFinalPrice();
|
132 |
+
}
|
133 |
+
if (!$price) {
|
134 |
+
$price = 0;
|
135 |
+
}
|
136 |
+
|
137 |
+
return $price;
|
138 |
+
}
|
139 |
+
|
140 |
+
protected function _sendUpdate($data)
|
141 |
+
{
|
142 |
+
// @codingStandardsIgnoreStart
|
143 |
+
$client = curl_init(self::API_UPDATE_URI);
|
144 |
+
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
145 |
+
curl_setopt($client, CURLOPT_POSTFIELDS, $data);
|
146 |
+
$response = curl_exec($client);
|
147 |
+
curl_close($client);
|
148 |
+
// @codingStandardsIgnoreEnd
|
149 |
+
return $response;
|
150 |
+
}
|
151 |
+
|
152 |
+
public function catalog_product_save_after($observer)
|
153 |
+
{
|
154 |
+
$product = $observer->getProduct();
|
155 |
+
$origData = $observer->getProduct()->getOrigData();
|
156 |
+
$storeId = $product->getStoreId();
|
157 |
+
$productId = $product->getId();
|
158 |
+
$sku = $product->getSku();
|
159 |
+
if (is_array($origData) &&
|
160 |
+
array_key_exists('sku', $origData)) {
|
161 |
+
$oldSku = $origData['sku'];
|
162 |
+
if ($sku != $oldSku) {
|
163 |
+
$this->_writeproductDeletion($oldSku, $productId, $storeId, $product);
|
164 |
+
}
|
165 |
+
}
|
166 |
+
$dt = Mage::getSingleton('core/date')->gmtTimestamp();
|
167 |
+
|
168 |
+
$simple_product_parents = ($product->getTypeID() == 'simple') ? Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId()) : array();
|
169 |
+
|
170 |
+
$product_stores = ($storeId == 0 && method_exists($product, 'getStoreIds')) ? $product->getStoreIds() : array($storeId);
|
171 |
+
|
172 |
+
try {
|
173 |
+
foreach ($product_stores as $product_store) {
|
174 |
+
$updates = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()
|
175 |
+
->addFieldToFilter('product_id', $productId)
|
176 |
+
->addFieldToFilter('store_id', $product_store);
|
177 |
+
|
178 |
+
$updates->getSelect()
|
179 |
+
->order('update_date','DESC')
|
180 |
+
->limit(1);
|
181 |
+
|
182 |
+
if ($updates && $updates->getSize() > 0) {
|
183 |
+
// @codingStandardsIgnoreLine
|
184 |
+
$row = $updates->getFirstItem();
|
185 |
+
|
186 |
+
$row->setUpdateDate($dt)
|
187 |
+
->setAction('update');
|
188 |
+
|
189 |
+
// @codingStandardsIgnoreLine
|
190 |
+
$row->save();
|
191 |
+
} else {
|
192 |
+
$batch = Mage::getModel('autocompleteplus_autosuggest/batches');
|
193 |
+
$batch->setProductId($productId)
|
194 |
+
->setStoreId($product_store)
|
195 |
+
->setUpdateDate($dt)
|
196 |
+
->setAction('update')
|
197 |
+
->setSku($sku);
|
198 |
+
|
199 |
+
// @codingStandardsIgnoreLine
|
200 |
+
$batch->save();
|
201 |
+
}
|
202 |
+
try {
|
203 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
204 |
+
$checksum = $helper->calculateChecksum($product);
|
205 |
+
$helper->updateSavedProductChecksum($productId, $sku, $product_store, $checksum);
|
206 |
+
} catch (Exception $e) {
|
207 |
+
Mage::logException($e);
|
208 |
+
}
|
209 |
+
|
210 |
+
// trigger update for simple product's configurable parent
|
211 |
+
if (!empty($simple_product_parents)) { // simple product has configural parent
|
212 |
+
foreach ($simple_product_parents as $configurable_product) {
|
213 |
+
|
214 |
+
$batches = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()
|
215 |
+
->addFieldToFilter('product_id', $configurable_product)
|
216 |
+
->addFieldToFilter('store_id', $product_store);
|
217 |
+
|
218 |
+
$batches->getSelect()
|
219 |
+
->order('update_date','DESC')
|
220 |
+
->limit(1);
|
221 |
+
|
222 |
+
// @codingStandardsIgnoreLine
|
223 |
+
if ($batches->getSize() > 0) {
|
224 |
+
$batch = $batches->getFirstItem();
|
225 |
+
$batch->setUpdateDate($dt)
|
226 |
+
->setAction('update')
|
227 |
+
// @codingStandardsIgnoreLine
|
228 |
+
->save();
|
229 |
+
} else {
|
230 |
+
$newBatch = Mage::getModel('autocompleteplus_autosuggest/batches');
|
231 |
+
$newBatch->setProductId($configurable_product)
|
232 |
+
->setStoreId($product_store)
|
233 |
+
->setUpdateDate($dt)
|
234 |
+
->setAction('update')
|
235 |
+
->setSku('ISP_NO_SKU')
|
236 |
+
// @codingStandardsIgnoreLine
|
237 |
+
->save();
|
238 |
+
}
|
239 |
+
}
|
240 |
+
}
|
241 |
+
}
|
242 |
+
} catch (Exception $e) {
|
243 |
+
Mage::logException($e);
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
public function catalog_product_save_after_real($observer)
|
248 |
+
{
|
249 |
+
$product = $observer->getProduct();
|
250 |
+
|
251 |
+
$productId = $product->getId();
|
252 |
+
|
253 |
+
$sku = $product->getSku();
|
254 |
+
|
255 |
+
try {
|
256 |
+
|
257 |
+
$updates = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()
|
258 |
+
->addFieldToFilter('product_id', array('null' => true))
|
259 |
+
->addFieldToFilter('sku', $sku)
|
260 |
+
;
|
261 |
+
|
262 |
+
foreach ($updates as $update) {
|
263 |
+
$update->setProductId($productId);
|
264 |
+
|
265 |
+
$update->save();
|
266 |
+
}
|
267 |
+
|
268 |
+
} catch (Exception $e) {
|
269 |
+
Mage::logException($e);
|
270 |
+
}
|
271 |
+
}
|
272 |
+
|
273 |
+
protected function _writeproductDeletion($sku, $productId, $storeId, $product = null)
|
274 |
+
{
|
275 |
+
$dt = strtotime('now');
|
276 |
+
try {
|
277 |
+
try {
|
278 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
279 |
+
try {
|
280 |
+
if (!$product) {
|
281 |
+
$product = Mage::getModel('catalog/product')->load($productId);
|
282 |
+
}
|
283 |
+
$product_stores = ($storeId == 0 && method_exists($product, 'getStoreIds')) ? $product->getStoreIds() : array($storeId);
|
284 |
+
} catch (Exception $e) {
|
285 |
+
Mage::logException($e);
|
286 |
+
$product_stores = array($storeId);
|
287 |
+
}
|
288 |
+
if ($sku == null) {
|
289 |
+
$sku = 'dummy_sku';
|
290 |
+
}
|
291 |
+
foreach ($product_stores as $product_store) {
|
292 |
+
$batches = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()
|
293 |
+
->addFieldToFilter('product_id', $productId)
|
294 |
+
->addFieldToFilter('store_id', $product_store);
|
295 |
+
|
296 |
+
$batches->getSelect()
|
297 |
+
->order('update_date','DESC')
|
298 |
+
->limit(1);
|
299 |
+
|
300 |
+
// @codingStandardsIgnoreLine
|
301 |
+
if ($batches->getSize() > 0) {
|
302 |
+
$batch = $batches->getFirstItem();
|
303 |
+
$batch->setUpdateDate($dt)
|
304 |
+
->setAction('remove')
|
305 |
+
// @codingStandardsIgnoreLine
|
306 |
+
->save();
|
307 |
+
} else {
|
308 |
+
$newBatch = Mage::getModel('autocompleteplus_autosuggest/batches');
|
309 |
+
$newBatch->setProductId($productId)
|
310 |
+
->setStoreId($product_store)
|
311 |
+
->setUpdateDate($dt)
|
312 |
+
->setAction('remove')
|
313 |
+
->setSku($sku)
|
314 |
+
// @codingStandardsIgnoreLine
|
315 |
+
->save();
|
316 |
+
}
|
317 |
+
$helper->updateDeletedProductChecksum($productId, $sku, $product_store);
|
318 |
+
}
|
319 |
+
} catch (Exception $e) {
|
320 |
+
Mage::logException($e);
|
321 |
+
}
|
322 |
+
} catch (Exception $e) {
|
323 |
+
Mage::logException($e);
|
324 |
+
}
|
325 |
+
}
|
326 |
+
|
327 |
+
public function catalog_product_delete_before($observer)
|
328 |
+
{
|
329 |
+
$product = $observer->getProduct();
|
330 |
+
$storeId = $product->getStoreId();
|
331 |
+
$productId = $product->getId();
|
332 |
+
$sku = $product->getSku();
|
333 |
+
$this->_writeproductDeletion($sku, $productId, $storeId, $product);
|
334 |
+
}
|
335 |
+
|
336 |
+
public function adminSessionUserLoginSuccess()
|
337 |
+
{
|
338 |
+
$notifications = array();
|
339 |
+
/** @var Autocompleteplus_Autosuggest_Helper_Data $helper */
|
340 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
341 |
+
$command = 'http://magento.autocompleteplus.com/ext_info?u='.$this->getConfig()->getUUID();
|
342 |
+
$res = $helper->sendCurl($command);
|
343 |
+
$result = json_decode($res);
|
344 |
+
if (isset($result->alerts)) {
|
345 |
+
foreach ($result->alerts as $alert) {
|
346 |
+
$notification = array(
|
347 |
+
'type' => (string) $alert->type,
|
348 |
+
'message' => (string) $alert->message,
|
349 |
+
'timestamp' => (string) $alert->timestamp,
|
350 |
+
);
|
351 |
+
if (isset($alert->subject)) {
|
352 |
+
$notification['subject'] = (string) $alert->subject;
|
353 |
+
}
|
354 |
+
$notifications[] = $notification;
|
355 |
+
}
|
356 |
+
}
|
357 |
+
if (!empty($notifications)) {
|
358 |
+
Mage::getResourceModel('autocompleteplus_autosuggest/notifications')->addNotifications($notifications);
|
359 |
+
}
|
360 |
+
$this->sendNotificationMails();
|
361 |
+
}
|
362 |
+
|
363 |
+
public function sendNotificationMails()
|
364 |
+
{
|
365 |
+
/** @var Autocompleteplus_Autosuggest_Model_Mysql4_Notifications_Collection $notifications */
|
366 |
+
$notifications = Mage::getModel('autocompleteplus_autosuggest/notifications')->getCollection();
|
367 |
+
$notifications->addTypeFilter('email')->addActiveFilter();
|
368 |
+
foreach ($notifications as $notification) {
|
369 |
+
$this->_sendStatusMail($notification);
|
370 |
+
}
|
371 |
+
}
|
372 |
+
|
373 |
+
/**
|
374 |
+
* @param Autocompleteplus_Autosuggest_Model_Notifications $notification
|
375 |
+
*/
|
376 |
+
protected function _sendStatusMail($notification)
|
377 |
+
{
|
378 |
+
/** @var Autocompleteplus_Autosuggest_Helper_Data $helper */
|
379 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
380 |
+
// Getting site owner email
|
381 |
+
$storeMail = $helper->getConfigDataByFullPath('autocompleteplus/config/store_email');
|
382 |
+
if ($storeMail) {
|
383 |
+
$emailTemplate = Mage::getModel('core/email_template');
|
384 |
+
$emailTemplate->loadDefault('autosuggest_status_notification');
|
385 |
+
$emailTemplate->setTemplateSubject($notification->getSubject());
|
386 |
+
// Get General email address (Admin->Configuration->General->Store Email Addresses)
|
387 |
+
$emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_general/email'));
|
388 |
+
$emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_general/name'));
|
389 |
+
$emailTemplateVariables['message'] = $notification->getMessage();
|
390 |
+
$emailTemplate->send($storeMail, null, $emailTemplateVariables);
|
391 |
+
$notification->setIsActive(0)
|
392 |
+
->save();
|
393 |
+
}
|
394 |
+
}
|
395 |
+
|
396 |
+
/**
|
397 |
+
* The generic webhook service caller.
|
398 |
+
*
|
399 |
+
* @param Varien_Event_Observer $observer
|
400 |
+
*/
|
401 |
+
public function webhook_service_call()
|
402 |
+
{
|
403 |
+
// @codingStandardsIgnoreStart
|
404 |
+
/**
|
405 |
+
* Due to backward compatibility issues with Magento < 1.8.1 and cURL/Zend
|
406 |
+
* We need to use PHP's implementation of cURL directly rather than Zend or Varien
|
407 |
+
*/
|
408 |
+
$client = curl_init($this->_getWebhookObjectUri());
|
409 |
+
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
410 |
+
$response = curl_exec($client);
|
411 |
+
curl_close($client);
|
412 |
+
// @codingStandardsIgnoreEnd
|
413 |
+
return $response;
|
414 |
+
}
|
415 |
+
|
416 |
+
/**
|
417 |
+
* Create the webhook URI.
|
418 |
+
*
|
419 |
+
* @return string
|
420 |
+
*/
|
421 |
+
protected function _getWebhookObjectUri()
|
422 |
+
{
|
423 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
424 |
+
$parameters = array(
|
425 |
+
'event' => $this->getWebhookEventLabel(),
|
426 |
+
'UUID' => $this->getConfig()->getUUID(),
|
427 |
+
'key' => $this->getConfig()->getAuthorizationKey(),
|
428 |
+
'store_id' => Mage::app()->getStore()->getStoreId(),
|
429 |
+
'st' => $helper->getSessionId(),
|
430 |
+
'cart_token' => $this->getQuoteId(),
|
431 |
+
'serp' => '',
|
432 |
+
'cart_product' => $this->getCartContentsAsJson(),
|
433 |
+
);
|
434 |
+
|
435 |
+
return static::AUTOCOMPLETEPLUS_WEBHOOK_URI.'?'.http_build_query($parameters, '', '&');
|
436 |
+
}
|
437 |
+
|
438 |
+
/**
|
439 |
+
* Return a label for webhooks based on the current
|
440 |
+
* controller route. This cannot be handled by layout
|
441 |
+
* XML because the layout engine may not be init in all
|
442 |
+
* future uses of the webhook.
|
443 |
+
*
|
444 |
+
* @return string|void
|
445 |
+
*/
|
446 |
+
public function getWebhookEventLabel()
|
447 |
+
{
|
448 |
+
$request = Mage::app()->getRequest();
|
449 |
+
$route = $request->getRouteName();
|
450 |
+
$controller = $request->getControllerName();
|
451 |
+
$action = $request->getActionName();
|
452 |
+
if ($route != 'checkout') {
|
453 |
+
return;
|
454 |
+
}
|
455 |
+
if ($controller == 'cart' && $action == 'index') {
|
456 |
+
return 'cart';
|
457 |
+
}
|
458 |
+
if ($controller == 'onepage' && $action == 'index') {
|
459 |
+
return 'checkout';
|
460 |
+
}
|
461 |
+
if ($controller == 'onepage' && $action == 'success') {
|
462 |
+
return 'success';
|
463 |
+
}
|
464 |
+
}
|
465 |
+
|
466 |
+
/**
|
467 |
+
* Returns the quote id if it exists, otherwise it will
|
468 |
+
* return the last order id. This only is set in the session
|
469 |
+
* when an order has been recently completed. Therefore
|
470 |
+
* this call may also return null.
|
471 |
+
*
|
472 |
+
* @return string|null
|
473 |
+
*/
|
474 |
+
public function getQuoteId()
|
475 |
+
{
|
476 |
+
if ($quoteId = Mage::getSingleton('checkout/session')->getQuoteId()) {
|
477 |
+
return $quoteId;
|
478 |
+
}
|
479 |
+
|
480 |
+
return $this->getOrder()->getQuoteId();
|
481 |
+
}
|
482 |
+
|
483 |
+
/**
|
484 |
+
* Get the order associated with the previous quote id
|
485 |
+
* used as a fallback when the quote is no longer available.
|
486 |
+
*
|
487 |
+
* @return Mage_Sales_Model_Order
|
488 |
+
*/
|
489 |
+
public function getOrder()
|
490 |
+
{
|
491 |
+
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
|
492 |
+
|
493 |
+
return Mage::getModel('sales/order')->load($orderId);
|
494 |
+
}
|
495 |
+
|
496 |
+
/**
|
497 |
+
* JSON encode the cart contents.
|
498 |
+
*
|
499 |
+
* @return string
|
500 |
+
*/
|
501 |
+
public function getCartContentsAsJson()
|
502 |
+
{
|
503 |
+
return json_encode($this->_getVisibleItems());
|
504 |
+
}
|
505 |
+
|
506 |
+
/**
|
507 |
+
* Format visible cart contents into a multidimensional keyed array.
|
508 |
+
*
|
509 |
+
* @return array
|
510 |
+
*/
|
511 |
+
protected function _getVisibleItems()
|
512 |
+
{
|
513 |
+
if ($cartItems = Mage::getSingleton('checkout/session')->getQuote()->getAllVisibleItems()) {
|
514 |
+
return $this->_buildCartArray($cartItems);
|
515 |
+
}
|
516 |
+
|
517 |
+
return $this->_buildCartArray($this->getOrder()->getAllVisibleItems());
|
518 |
+
}
|
519 |
+
|
520 |
+
/**
|
521 |
+
* Return a formatted array of quote or order items.
|
522 |
+
*
|
523 |
+
* @param array $cartItems
|
524 |
+
*
|
525 |
+
* @return array
|
526 |
+
*/
|
527 |
+
protected function _buildCartArray($cartItems)
|
528 |
+
{
|
529 |
+
$items = array();
|
530 |
+
foreach ($cartItems as $item) {
|
531 |
+
if ($item instanceof Mage_Sales_Model_Order_Item) {
|
532 |
+
$quantity = (int) $item->getQtyOrdered();
|
533 |
+
} else {
|
534 |
+
$quantity = $item->getQty();
|
535 |
+
}
|
536 |
+
if (is_object($item->getProduct())) { // Fatal error fix: Call to a member function getId() on a non-object
|
537 |
+
$items[] = array(
|
538 |
+
'product_id' => $item->getProduct()->getId(),
|
539 |
+
'price' => $item->getProduct()->getFinalPrice(),
|
540 |
+
'quantity' => $quantity,
|
541 |
+
'currency' => Mage::app()->getStore()->getCurrentCurrencyCode(),
|
542 |
+
'attribution' => $item->getAddedFromSearch(),
|
543 |
+
);
|
544 |
+
}
|
545 |
+
}
|
546 |
+
|
547 |
+
return $items;
|
548 |
+
}
|
549 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Pusher.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Pusher extends Mage_Core_Model_Abstract
|
4 |
-
{
|
5 |
-
protected function _construct()
|
6 |
-
{
|
7 |
-
$this->_init('autocompleteplus_autosuggest/pusher');
|
8 |
-
}
|
9 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Pusher extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('autocompleteplus_autosuggest/pusher');
|
8 |
+
}
|
9 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Abstract.php
CHANGED
@@ -1,84 +1,84 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Renderer_Abstract extends Mage_Core_Model_Abstract
|
4 |
-
{
|
5 |
-
protected $_currency;
|
6 |
-
protected $_pageNum;
|
7 |
-
protected $_productCollection;
|
8 |
-
protected $_xmlGenerator;
|
9 |
-
protected $_imageField;
|
10 |
-
protected $_storeId;
|
11 |
-
protected $_monthInterval;
|
12 |
-
protected $_helper;
|
13 |
-
|
14 |
-
public function getStoreId()
|
15 |
-
{
|
16 |
-
if (!$this->_storeId) {
|
17 |
-
$this->_storeId = Mage::app()->getStore()->getId();
|
18 |
-
}
|
19 |
-
return $this->_storeId;
|
20 |
-
}
|
21 |
-
|
22 |
-
public function setStoreId($storeId)
|
23 |
-
{
|
24 |
-
$this->_storeId = $storeId;
|
25 |
-
return $this;
|
26 |
-
}
|
27 |
-
|
28 |
-
public function getCurrency()
|
29 |
-
{
|
30 |
-
if (!$this->_currency) {
|
31 |
-
$this->_currency = Mage::app()->getStore($this->getStoreId())->getCurrentCurrencyCode();
|
32 |
-
}
|
33 |
-
return $this->_currency;
|
34 |
-
}
|
35 |
-
|
36 |
-
public function getMonthInterval()
|
37 |
-
{
|
38 |
-
if (!$this->_monthInterval) {
|
39 |
-
$this->_monthInterval = 12;
|
40 |
-
}
|
41 |
-
return $this->_monthInterval;
|
42 |
-
}
|
43 |
-
|
44 |
-
public function setMonthInterval($monthInterval)
|
45 |
-
{
|
46 |
-
$this->_monthInterval = $monthInterval;
|
47 |
-
return $this;
|
48 |
-
}
|
49 |
-
|
50 |
-
public function getPageNum()
|
51 |
-
{
|
52 |
-
if ($this->_pageNum) {
|
53 |
-
$this->_pageNum = 1;
|
54 |
-
}
|
55 |
-
return $this->_pageNum;
|
56 |
-
}
|
57 |
-
|
58 |
-
public function setPageNum($pageNum)
|
59 |
-
{
|
60 |
-
$this->_pageNum = $pageNum;
|
61 |
-
return $this;
|
62 |
-
}
|
63 |
-
|
64 |
-
public function getHelper()
|
65 |
-
{
|
66 |
-
if (!$this->_helper) {
|
67 |
-
$this->_helper = Mage::helper('autocompleteplus_autosuggest');
|
68 |
-
}
|
69 |
-
return $this->_helper;
|
70 |
-
}
|
71 |
-
|
72 |
-
public function getProductCollection($new = false)
|
73 |
-
{
|
74 |
-
if (!$this->_productCollection) {
|
75 |
-
$this->_productCollection = Mage::getModel('catalog/product')->getCollection();
|
76 |
-
}
|
77 |
-
|
78 |
-
if ($new === true) {
|
79 |
-
return Mage::getModel('catalog/product')->getCollection();
|
80 |
-
}
|
81 |
-
|
82 |
-
return $this->_productCollection;
|
83 |
-
}
|
84 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Renderer_Abstract extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
protected $_currency;
|
6 |
+
protected $_pageNum;
|
7 |
+
protected $_productCollection;
|
8 |
+
protected $_xmlGenerator;
|
9 |
+
protected $_imageField;
|
10 |
+
protected $_storeId;
|
11 |
+
protected $_monthInterval;
|
12 |
+
protected $_helper;
|
13 |
+
|
14 |
+
public function getStoreId()
|
15 |
+
{
|
16 |
+
if (!$this->_storeId) {
|
17 |
+
$this->_storeId = Mage::app()->getStore()->getId();
|
18 |
+
}
|
19 |
+
return $this->_storeId;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function setStoreId($storeId)
|
23 |
+
{
|
24 |
+
$this->_storeId = $storeId;
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getCurrency()
|
29 |
+
{
|
30 |
+
if (!$this->_currency) {
|
31 |
+
$this->_currency = Mage::app()->getStore($this->getStoreId())->getCurrentCurrencyCode();
|
32 |
+
}
|
33 |
+
return $this->_currency;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getMonthInterval()
|
37 |
+
{
|
38 |
+
if (!$this->_monthInterval) {
|
39 |
+
$this->_monthInterval = 12;
|
40 |
+
}
|
41 |
+
return $this->_monthInterval;
|
42 |
+
}
|
43 |
+
|
44 |
+
public function setMonthInterval($monthInterval)
|
45 |
+
{
|
46 |
+
$this->_monthInterval = $monthInterval;
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function getPageNum()
|
51 |
+
{
|
52 |
+
if ($this->_pageNum) {
|
53 |
+
$this->_pageNum = 1;
|
54 |
+
}
|
55 |
+
return $this->_pageNum;
|
56 |
+
}
|
57 |
+
|
58 |
+
public function setPageNum($pageNum)
|
59 |
+
{
|
60 |
+
$this->_pageNum = $pageNum;
|
61 |
+
return $this;
|
62 |
+
}
|
63 |
+
|
64 |
+
public function getHelper()
|
65 |
+
{
|
66 |
+
if (!$this->_helper) {
|
67 |
+
$this->_helper = Mage::helper('autocompleteplus_autosuggest');
|
68 |
+
}
|
69 |
+
return $this->_helper;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getProductCollection($new = false)
|
73 |
+
{
|
74 |
+
if (!$this->_productCollection) {
|
75 |
+
$this->_productCollection = Mage::getModel('catalog/product')->getCollection();
|
76 |
+
}
|
77 |
+
|
78 |
+
if ($new === true) {
|
79 |
+
return Mage::getModel('catalog/product')->getCollection();
|
80 |
+
}
|
81 |
+
|
82 |
+
return $this->_productCollection;
|
83 |
+
}
|
84 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Batches.php
CHANGED
@@ -1,27 +1,27 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Renderer_Batches extends Autocompleteplus_Autosuggest_Model_Renderer_Abstract
|
4 |
-
{
|
5 |
-
public function setXmlElement(&$xmlGenerator)
|
6 |
-
{
|
7 |
-
$this->_xmlElement = $xmlGenerator;
|
8 |
-
return $this;
|
9 |
-
}
|
10 |
-
|
11 |
-
public function getXmlElement()
|
12 |
-
{
|
13 |
-
return $this->_xmlElement;
|
14 |
-
}
|
15 |
-
|
16 |
-
public function makeRemoveRow($batch) {
|
17 |
-
$productElement = $this->getXmlElement()->createChild('product', array(
|
18 |
-
'updatedate' => $batch['update_date'],
|
19 |
-
'action' => $batch['action'],
|
20 |
-
'id' => $batch['product_id'],
|
21 |
-
'storeid' => $batch['store_id']
|
22 |
-
));
|
23 |
-
|
24 |
-
$this->getXmlElement()->createChild('sku', false, $batch['sku'], $productElement);
|
25 |
-
$this->getXmlElement()->createChild('id', false, $batch['product_id'], $productElement);
|
26 |
-
}
|
27 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Renderer_Batches extends Autocompleteplus_Autosuggest_Model_Renderer_Abstract
|
4 |
+
{
|
5 |
+
public function setXmlElement(&$xmlGenerator)
|
6 |
+
{
|
7 |
+
$this->_xmlElement = $xmlGenerator;
|
8 |
+
return $this;
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getXmlElement()
|
12 |
+
{
|
13 |
+
return $this->_xmlElement;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function makeRemoveRow($batch) {
|
17 |
+
$productElement = $this->getXmlElement()->createChild('product', array(
|
18 |
+
'updatedate' => $batch['update_date'],
|
19 |
+
'action' => $batch['action'],
|
20 |
+
'id' => $batch['product_id'],
|
21 |
+
'storeid' => $batch['store_id']
|
22 |
+
));
|
23 |
+
|
24 |
+
$this->getXmlElement()->createChild('sku', false, $batch['sku'], $productElement);
|
25 |
+
$this->getXmlElement()->createChild('id', false, $batch['product_id'], $productElement);
|
26 |
+
}
|
27 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Catalog/Product.php
CHANGED
@@ -1,573 +1,610 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autocompleteplus_Autosuggest_Model_Renderer_Abstract
|
4 |
-
{
|
5 |
-
protected $_standardImageFields = array('image', 'small_image', 'thumbnail');
|
6 |
-
protected $_useAttributes;
|
7 |
-
protected $_attributes;
|
8 |
-
protected $_xmlGenerator;
|
9 |
-
protected $_categories;
|
10 |
-
protected $_configurableAttributes;
|
11 |
-
protected $_configurableChildren;
|
12 |
-
protected $_configurableChildrenIds;
|
13 |
-
protected $_saleable;
|
14 |
-
protected $_simpleProductIds;
|
15 |
-
protected $_xmlElement;
|
16 |
-
protected $_productAttributes;
|
17 |
-
protected $_product;
|
18 |
-
protected $_rootCategoryId;
|
19 |
-
protected $_outputHelper;
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
$this
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
return $this->
|
75 |
-
}
|
76 |
-
|
77 |
-
public function
|
78 |
-
{
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
$
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
}
|
154 |
-
}
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
'
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
$is_filterable = $attr->getIsFilterable();
|
388 |
-
$attribute_label = $attr->getFrontendLabel();
|
389 |
-
$
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
'
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
$
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
'
|
469 |
-
|
470 |
-
'
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
$this->getXmlElement()->createChild('
|
480 |
-
$
|
481 |
-
|
482 |
-
$this->
|
483 |
-
|
484 |
-
$this->
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
$this->
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
$
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
if ($
|
524 |
-
$this->getXmlElement()->createChild('
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
$this->getXmlElement()->createChild('
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
$
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autocompleteplus_Autosuggest_Model_Renderer_Abstract
|
4 |
+
{
|
5 |
+
protected $_standardImageFields = array('image', 'small_image', 'thumbnail');
|
6 |
+
protected $_useAttributes;
|
7 |
+
protected $_attributes;
|
8 |
+
protected $_xmlGenerator;
|
9 |
+
protected $_categories;
|
10 |
+
protected $_configurableAttributes;
|
11 |
+
protected $_configurableChildren;
|
12 |
+
protected $_configurableChildrenIds;
|
13 |
+
protected $_saleable;
|
14 |
+
protected $_simpleProductIds;
|
15 |
+
protected $_xmlElement;
|
16 |
+
protected $_productAttributes;
|
17 |
+
protected $_product;
|
18 |
+
protected $_rootCategoryId;
|
19 |
+
protected $_outputHelper;
|
20 |
+
protected $_attributesValuesCache;
|
21 |
+
protected $_attributesSetsCache;
|
22 |
+
|
23 |
+
const ISPKEY = 'ISPKEY_';
|
24 |
+
|
25 |
+
public function __construct()
|
26 |
+
{
|
27 |
+
$this->_attributesValuesCache = array();
|
28 |
+
$this->_attributesSetsCache = array();
|
29 |
+
}
|
30 |
+
|
31 |
+
public function setXmlElement(&$xmlGenerator)
|
32 |
+
{
|
33 |
+
$this->_xmlElement = $xmlGenerator;
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getXmlElement()
|
38 |
+
{
|
39 |
+
return $this->_xmlElement;
|
40 |
+
}
|
41 |
+
|
42 |
+
public function setProduct($product)
|
43 |
+
{
|
44 |
+
$this->_product = $product;
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getProduct()
|
49 |
+
{
|
50 |
+
return $this->_product;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function getImageField()
|
54 |
+
{
|
55 |
+
if (!$this->_imageField) {
|
56 |
+
$this->_imageField = Mage::getStoreConfig('autocompleteplus/config/imagefield');
|
57 |
+
}
|
58 |
+
return $this->_imageField;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function canUseAttributes()
|
62 |
+
{
|
63 |
+
if (!$this->_useAttributes) {
|
64 |
+
$this->_useAttributes = Mage::getStoreConfigFlag('autocompleteplus/config/attributes');
|
65 |
+
}
|
66 |
+
return $this->_useAttributes;
|
67 |
+
}
|
68 |
+
|
69 |
+
public function getRootCategoryId()
|
70 |
+
{
|
71 |
+
if (!$this->_rootCategoryId) {
|
72 |
+
$this->_rootCategoryId = Mage::app()->getStore($this->getStoreId())->getRootCategoryId();
|
73 |
+
}
|
74 |
+
return $this->_rootCategoryId;
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getSaleable()
|
78 |
+
{
|
79 |
+
return !!$this->_saleable;
|
80 |
+
}
|
81 |
+
|
82 |
+
public function getConfigurableChildren()
|
83 |
+
{
|
84 |
+
return $this->getProduct()->getTypeInstance()->getUsedProducts();
|
85 |
+
}
|
86 |
+
|
87 |
+
public function getConfigurableChildrenIds()
|
88 |
+
{
|
89 |
+
$configurableChildrenIds = array();
|
90 |
+
foreach ($this->getConfigurableChildren() as $child) {
|
91 |
+
$configurableChildrenIds[] = $child->getId();
|
92 |
+
if ($this->getProduct()->isInStock()) {
|
93 |
+
if (method_exists($child, 'isSaleable') && !$child->isSaleable()) {
|
94 |
+
// the simple product is probably disabled (because its in stock)
|
95 |
+
continue;
|
96 |
+
}
|
97 |
+
$this->_saleable = true;
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
return $configurableChildrenIds;
|
102 |
+
}
|
103 |
+
|
104 |
+
public function getProductCollection($new = false)
|
105 |
+
{
|
106 |
+
if (!$this->_productCollection) {
|
107 |
+
$this->_productCollection = Mage::getModel('catalog/product')->getCollection();
|
108 |
+
}
|
109 |
+
|
110 |
+
if ($new === true) {
|
111 |
+
return Mage::getModel('catalog/product')->getCollection();
|
112 |
+
}
|
113 |
+
|
114 |
+
return $this->_productCollection;
|
115 |
+
}
|
116 |
+
|
117 |
+
public function getCategoryMap()
|
118 |
+
{
|
119 |
+
if (!$this->_categories) {
|
120 |
+
$categoryMap = array();
|
121 |
+
$categories = Mage::getModel('catalog/category')->getCollection();
|
122 |
+
|
123 |
+
foreach ($categories as $category) {
|
124 |
+
$categoryMap[] = new Varien_Object(array(
|
125 |
+
'id' => $category->getId(),
|
126 |
+
'path' => $category->getPath(),
|
127 |
+
'parent_id' => $category->getParentId(),
|
128 |
+
));
|
129 |
+
}
|
130 |
+
$this->_categories = $categoryMap;
|
131 |
+
}
|
132 |
+
return $this->_categories;
|
133 |
+
}
|
134 |
+
|
135 |
+
public function getSimpleProductsPriceOfConfigurable()
|
136 |
+
{
|
137 |
+
$simple_products_price = array();
|
138 |
+
$pricesByAttributeValues = array();
|
139 |
+
$attributes = $this->getProduct()->getTypeInstance(true)->getConfigurableAttributes($this->getProduct());
|
140 |
+
$basePrice = $this->getProduct()->getFinalPrice();
|
141 |
+
$items = $attributes->getItems();
|
142 |
+
if (is_array($items)) {
|
143 |
+
foreach ($items as $attribute) {
|
144 |
+
$prices = $attribute->getPrices();
|
145 |
+
if (is_array($prices)) {
|
146 |
+
foreach ($prices as $price) {
|
147 |
+
if ($price['is_percent']) { //if the price is specified in percents
|
148 |
+
$pricesByAttributeValues[$price['value_index']] = (float) $price['pricing_value'] * $basePrice / 100;
|
149 |
+
} else { //if the price is absolute value
|
150 |
+
$pricesByAttributeValues[$price['value_index']] = (float) $price['pricing_value'];
|
151 |
+
}
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
foreach ($this->getConfigurableChildren() as $sProduct) {
|
158 |
+
$totalPrice = $basePrice;
|
159 |
+
foreach ($attributes as $attribute) {
|
160 |
+
$value = $sProduct->getData($attribute->getProductAttribute()->getAttributeCode());
|
161 |
+
if (isset($pricesByAttributeValues[$value])) {
|
162 |
+
$totalPrice += $pricesByAttributeValues[$value];
|
163 |
+
}
|
164 |
+
}
|
165 |
+
$simple_products_price[$sProduct->getId()] = $totalPrice;
|
166 |
+
}
|
167 |
+
|
168 |
+
return $simple_products_price;
|
169 |
+
}
|
170 |
+
|
171 |
+
public function getCategoryPathsByProduct()
|
172 |
+
{
|
173 |
+
$productCategories = $this->getProduct()->getCategoryIds();
|
174 |
+
$rootCategoryId = $this->getRootCategoryId();
|
175 |
+
$paths = array_map(function ($category) use ($productCategories, $rootCategoryId) {
|
176 |
+
if (in_array($category->getId(), $productCategories)) {
|
177 |
+
$path = explode('/', $category->getPath());
|
178 |
+
//we don't want the root category for the entire site
|
179 |
+
array_shift($path);
|
180 |
+
if ($rootCategoryId &&
|
181 |
+
is_array($path) &&
|
182 |
+
isset($path[0]) &&
|
183 |
+
$path[0] != $rootCategoryId
|
184 |
+
) {
|
185 |
+
return array();
|
186 |
+
}
|
187 |
+
//we want more specific categories first
|
188 |
+
return implode(':', array_reverse($path));
|
189 |
+
}
|
190 |
+
}, $this->getCategoryMap());
|
191 |
+
return array_filter($paths);
|
192 |
+
}
|
193 |
+
|
194 |
+
public function getConfigurableAttributes()
|
195 |
+
{
|
196 |
+
// Collect options applicable to the configurable product
|
197 |
+
$productAttributeOptions = $this->getProduct()->getTypeInstance()->getConfigurableAttributesAsArray($this->getProduct());
|
198 |
+
$configurableAttributes = array();
|
199 |
+
|
200 |
+
foreach ($productAttributeOptions as $productAttribute) {
|
201 |
+
$attributeFull = Mage::getModel('eav/config')->getAttribute('catalog_product', $productAttribute['attribute_code']);
|
202 |
+
|
203 |
+
foreach ($productAttribute['values'] as $attribute) {
|
204 |
+
$configurableAttributes[$productAttribute['store_label']]['values'][] = $attribute['store_label'];
|
205 |
+
}
|
206 |
+
|
207 |
+
$configurableAttributes[$productAttribute['store_label']]['is_filterable'] = $attributeFull['is_filterable'];
|
208 |
+
$configurableAttributes[$productAttribute['store_label']]['frontend_input'] = $attributeFull['frontend_input'];
|
209 |
+
}
|
210 |
+
|
211 |
+
return $configurableAttributes;
|
212 |
+
}
|
213 |
+
|
214 |
+
public function getProductAttributes()
|
215 |
+
{
|
216 |
+
return $this->getProduct()->getTypeInstance()->getConfigurableAttributes($this->getProduct());
|
217 |
+
}
|
218 |
+
|
219 |
+
public function getPriceRange()
|
220 |
+
{
|
221 |
+
$pricesByAttributeValues = array();
|
222 |
+
$attributes = $this->getProductAttributes();
|
223 |
+
$basePrice = $this->getProduct()->getFinalPrice();
|
224 |
+
$items = $attributes->getItems();
|
225 |
+
$min_price = null;
|
226 |
+
$max_price = null;
|
227 |
+
$totalPrice = false;
|
228 |
+
if (is_array($items)) {
|
229 |
+
foreach ($items as $attribute) {
|
230 |
+
$prices = $attribute->getPrices();
|
231 |
+
if (is_array($prices)) {
|
232 |
+
foreach ($prices as $price) {
|
233 |
+
if ($price['is_percent']) { //if the price is specified in percents
|
234 |
+
$pricesByAttributeValues[$price['value_index']] = (float)$price['pricing_value'] * $basePrice / 100;
|
235 |
+
} else { //if the price is absolute value
|
236 |
+
$pricesByAttributeValues[$price['value_index']] = (float)$price['pricing_value'];
|
237 |
+
}
|
238 |
+
}
|
239 |
+
}
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
$simple = $this->getConfigurableChildren();
|
244 |
+
foreach ($simple as $sProduct) {
|
245 |
+
$totalPrice = $basePrice;
|
246 |
+
foreach ($attributes as $attribute) {
|
247 |
+
$value = $sProduct->getData($attribute->getProductAttribute()->getAttributeCode());
|
248 |
+
if (isset($pricesByAttributeValues[$value])) {
|
249 |
+
$totalPrice += $pricesByAttributeValues[$value];
|
250 |
+
}
|
251 |
+
}
|
252 |
+
if (!$min_price || $totalPrice < $min_price){
|
253 |
+
$min_price = $totalPrice;
|
254 |
+
}
|
255 |
+
if (!$max_price || $totalPrice > $max_price){
|
256 |
+
$max_price = $totalPrice;
|
257 |
+
}
|
258 |
+
}
|
259 |
+
if (is_null($min_price)){
|
260 |
+
$min_price = 0;
|
261 |
+
}
|
262 |
+
if (is_null($max_price)){
|
263 |
+
$max_price = 0;
|
264 |
+
}
|
265 |
+
|
266 |
+
return array(
|
267 |
+
'price_min' => $min_price,
|
268 |
+
'price_max' => $max_price
|
269 |
+
);
|
270 |
+
}
|
271 |
+
|
272 |
+
public function getSimpleProductParent()
|
273 |
+
{
|
274 |
+
return Mage::getModel('catalog/product_type_configurable')
|
275 |
+
->getParentIdsByChild($this->getProduct()->getId());
|
276 |
+
}
|
277 |
+
|
278 |
+
public function getOrderCount()
|
279 |
+
{
|
280 |
+
$orderData = $this->getOrderData();
|
281 |
+
return ($this->getOrderData() != null && array_key_exists($this->getProduct()->getId(), $orderData)) ? $orderData[$this->getProduct()->getId()] : 0;
|
282 |
+
}
|
283 |
+
|
284 |
+
public function getProductResource()
|
285 |
+
{
|
286 |
+
return Mage::getResourceSingleton('catalog/product');
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* @TODO Refactor indentation/conditions
|
291 |
+
*/
|
292 |
+
public function renderProductVariantXml($productXmlElem)
|
293 |
+
{
|
294 |
+
if ($this->canUseAttributes()) {
|
295 |
+
if ($this->getProduct()->isConfigurable() && count($this->getConfigurableAttributes()) > 0) {
|
296 |
+
$variants = array();
|
297 |
+
foreach ($this->getConfigurableAttributes() as $attrName => $confAttrN) {
|
298 |
+
if (is_array($confAttrN) && array_key_exists('values', $confAttrN)) {
|
299 |
+
$variants[] = $attrName;
|
300 |
+
$values = implode(' , ', $confAttrN['values']);
|
301 |
+
$this->getXmlElement()->createChild('attribute', array(
|
302 |
+
'is_configurable' => 1,
|
303 |
+
'is_filterable' => $confAttrN['is_filterable'],
|
304 |
+
'name' => $attrName
|
305 |
+
),
|
306 |
+
$values,
|
307 |
+
$productXmlElem
|
308 |
+
);
|
309 |
+
}
|
310 |
+
}
|
311 |
+
|
312 |
+
$simple_products_price = $this->getSimpleProductsPriceOfConfigurable();
|
313 |
+
|
314 |
+
if (count($variants) > 0) {
|
315 |
+
$variantElem = $this->getXmlElement()->createChild('variants', false, false, $productXmlElem);
|
316 |
+
foreach ($this->getConfigurableChildren() as $child_product) {
|
317 |
+
if (!in_array($this->getProduct()->getStoreId(), $child_product->getStoreIds())) {
|
318 |
+
continue;
|
319 |
+
}
|
320 |
+
|
321 |
+
$is_variant_in_stock = ($child_product->getStockItem()->getIsInStock()) ? 1 : 0;
|
322 |
+
|
323 |
+
if (method_exists($child_product, 'isSaleable')) {
|
324 |
+
$is_variant_sellable = ($child_product->isSaleable()) ? 1 : 0;
|
325 |
+
} else {
|
326 |
+
$is_variant_sellable = '';
|
327 |
+
}
|
328 |
+
|
329 |
+
if (method_exists($child_product, 'getVisibility')) {
|
330 |
+
$is_variant_visible = ($child_product->getVisibility()) ? 1 : 0;
|
331 |
+
} else {
|
332 |
+
$is_variant_visible = '';
|
333 |
+
}
|
334 |
+
|
335 |
+
$variant_price = (array_key_exists($child_product->getId(), $simple_products_price)) ?
|
336 |
+
$simple_products_price[$child_product->getId()] : '';
|
337 |
+
|
338 |
+
|
339 |
+
$productVariation = $this->getXmlElement()->createChild('variant', array(
|
340 |
+
'id' => $child_product->getId(),
|
341 |
+
'type' => $child_product->getTypeID(),
|
342 |
+
'visibility' => $is_variant_visible,
|
343 |
+
'is_in_stock' => $is_variant_in_stock,
|
344 |
+
'is_seallable' => $is_variant_sellable,
|
345 |
+
'price' => $variant_price
|
346 |
+
), false, $variantElem);
|
347 |
+
|
348 |
+
$this->getXmlElement()->createChild('name', false, $child_product->getName(), $productVariation);
|
349 |
+
|
350 |
+
$attributes = $child_product->getAttributes();
|
351 |
+
foreach ($attributes as $attribute) {
|
352 |
+
if (!$attribute['is_configurable'] || !in_array($attribute['store_label'], $variants)) {
|
353 |
+
continue;
|
354 |
+
}
|
355 |
+
|
356 |
+
if (!$attribute['store_label']){
|
357 |
+
// skip variant attribute without a name
|
358 |
+
continue;
|
359 |
+
}
|
360 |
+
|
361 |
+
$this->getXmlElement()->createChild('variant_attribute', array(
|
362 |
+
'is_configurable' => 1,
|
363 |
+
'is_filterable' => $attribute->getIsFilterable(),
|
364 |
+
'name' => $attribute['store_label'],
|
365 |
+
'name_code' => $attribute->getId(),
|
366 |
+
'value_code' => $child_product->getData($attribute->getAttributeCode())
|
367 |
+
), utf8_encode(htmlspecialchars($attribute->getFrontend()->getValue($child_product))), $productVariation
|
368 |
+
);
|
369 |
+
}
|
370 |
+
}
|
371 |
+
}
|
372 |
+
}
|
373 |
+
}
|
374 |
+
}
|
375 |
+
|
376 |
+
public function renderProductAttributeXml($attr, $productXmlElem)
|
377 |
+
{
|
378 |
+
if ($this->canUseAttributes()) {
|
379 |
+
$action = $attr->getAttributeCode();
|
380 |
+
|
381 |
+
$attrValue = $this->getProduct()->getData($action);
|
382 |
+
|
383 |
+
if (!array_key_exists($action, $this->_attributesValuesCache)) {
|
384 |
+
$this->_attributesValuesCache[$action] = array();
|
385 |
+
}
|
386 |
+
|
387 |
+
$is_filterable = $attr->getIsFilterable();
|
388 |
+
$attribute_label = $attr->getFrontendLabel();
|
389 |
+
$_helper=$this->_getOutputHelper();
|
390 |
+
|
391 |
+
try {
|
392 |
+
|
393 |
+
switch ($attr->getFrontendInput()) {
|
394 |
+
case 'select':
|
395 |
+
if (method_exists($this->getProduct(), 'getAttributeText')) {
|
396 |
+
/*
|
397 |
+
* we generate key for cached attributes array
|
398 |
+
* we make it as string to avoid null to be a key
|
399 |
+
*/
|
400 |
+
$attrValidKey = $attrValue != null ? self::ISPKEY . $attrValue : self::ISPKEY;
|
401 |
+
|
402 |
+
if (!array_key_exists($attrValidKey, $this->_attributesValuesCache[$action])) {
|
403 |
+
$attrValueText = $_helper->productAttribute(
|
404 |
+
$this->getProduct(),
|
405 |
+
$this->getProduct()->getAttributeText($action),
|
406 |
+
$action
|
407 |
+
);
|
408 |
+
|
409 |
+
$this->_attributesValuesCache[$action][$attrValidKey] = $attrValueText;
|
410 |
+
$attrValue = $attrValueText;
|
411 |
+
} else {
|
412 |
+
$attrValueText = $this->_attributesValuesCache[$action][$attrValidKey];
|
413 |
+
|
414 |
+
$attrValue = $attrValueText;
|
415 |
+
}
|
416 |
+
}
|
417 |
+
|
418 |
+
break;
|
419 |
+
case 'textarea':
|
420 |
+
case 'price':
|
421 |
+
case 'text':
|
422 |
+
break;
|
423 |
+
case 'multiselect':
|
424 |
+
$attrValue = $this->getProduct()->getResource()
|
425 |
+
->getAttribute($action)->getFrontend()->getValue($this->getProduct());
|
426 |
+
break;
|
427 |
+
default:
|
428 |
+
$attrValue = null;
|
429 |
+
break;
|
430 |
+
}
|
431 |
+
|
432 |
+
} catch(Exception $e) {
|
433 |
+
Mage::log($e->getMessage(), null, 'autocomplete.log', true);
|
434 |
+
}
|
435 |
+
|
436 |
+
|
437 |
+
if ($attrValue) {
|
438 |
+
$attributeElem = $this->getXmlElement()->createChild('attribute', array(
|
439 |
+
'is_filterable' => $is_filterable,
|
440 |
+
'name' => $attr->getAttributeCode()
|
441 |
+
), false, $productXmlElem);
|
442 |
+
|
443 |
+
$this->getXmlElement()->createChild('attribute_values', false,
|
444 |
+
$attrValue, $attributeElem);
|
445 |
+
$this->getXmlElement()->createChild('attribute_label', false,
|
446 |
+
$attribute_label, $attributeElem);
|
447 |
+
}
|
448 |
+
}
|
449 |
+
}
|
450 |
+
|
451 |
+
public function renderXml()
|
452 |
+
{
|
453 |
+
$categories = $this->getCategoryPathsByProduct();
|
454 |
+
|
455 |
+
$saleable = 0;
|
456 |
+
|
457 |
+
try {
|
458 |
+
if ($this->getProduct()->isSalable()) {
|
459 |
+
$saleable = 1;
|
460 |
+
}
|
461 |
+
}catch (Exception $e) {
|
462 |
+
Mage::log($e->getMessage(), null, 'autocomplete.log', true);
|
463 |
+
}
|
464 |
+
|
465 |
+
if ($this->getProduct()->isConfigurable()) {
|
466 |
+
$priceRange = $this->getPriceRange();
|
467 |
+
} elseif ($this->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
|
468 |
+
$priceRange = array('price_min' => 0, 'price_max' => 0);
|
469 |
+
} else {
|
470 |
+
$priceRange = array('price_min' => 0, 'price_max' => 0);
|
471 |
+
}
|
472 |
+
|
473 |
+
$url = Mage::helper('catalog/product')->getProductUrl($this->getProduct());
|
474 |
+
|
475 |
+
if ($url == null || $url == '') {
|
476 |
+
$url = Mage::helper('catalog/product')->getProductUrl($this->getProduct()->getId());
|
477 |
+
}
|
478 |
+
|
479 |
+
$productElement = $this->getXmlElement()->createChild('product', array(
|
480 |
+
'price_min' => ($priceRange['price_min']),
|
481 |
+
'price_max' => ($priceRange['price_max']),
|
482 |
+
'store' => ($this->getStoreId()),
|
483 |
+
'store_id' => ($this->getStoreId()),
|
484 |
+
'storeid' => ($this->getStoreId()),
|
485 |
+
'id' => ($this->getProduct()->getId()),
|
486 |
+
'type' => ($this->getProduct()->getTypeId()),
|
487 |
+
'currency' => ($this->getCurrency()),
|
488 |
+
'visibility' => ($this->getProduct()->getVisibility()),
|
489 |
+
'price' => ($this->getProduct()->getFinalPrice()),
|
490 |
+
'url' => $url,
|
491 |
+
'thumbs' => utf8_encode(htmlspecialchars((Mage::helper('catalog/image')->init($this->getProduct(), $this->getImageField())))),
|
492 |
+
'base_image' => utf8_encode(htmlspecialchars((Mage::getModel('catalog/product_media_config')->getMediaUrl($this->getProduct()->getImage())))),
|
493 |
+
'selleable' => ($saleable),
|
494 |
+
'action' => ($this->getAction()),
|
495 |
+
'last_updated' => ($this->getProduct()->getUpdatedAt()),
|
496 |
+
'updatedate' => ($this->getUpdateDate()),
|
497 |
+
'get_by_id_status' => intval($this->getGetByIdStatus())
|
498 |
+
));
|
499 |
+
|
500 |
+
$productRating = $this->getProduct()->getRatingSummary();
|
501 |
+
$this->getXmlElement()->createChild('description', false,
|
502 |
+
$this->getProduct()->getDescription(), $productElement);
|
503 |
+
$this->getXmlElement()->createChild('short', false,
|
504 |
+
$this->getProduct()->getShortDescription(), $productElement);
|
505 |
+
$this->getXmlElement()->createChild('name', false,
|
506 |
+
$this->getProduct()->getName(), $productElement);
|
507 |
+
$this->getXmlElement()->createChild('sku', false,
|
508 |
+
$this->getProduct()->getSku(), $productElement);
|
509 |
+
|
510 |
+
|
511 |
+
$this->getXmlElement()->createChild('url_additional', false,
|
512 |
+
$this->_getAdditionalProductUrl(), $productElement);
|
513 |
+
|
514 |
+
if ($productRating) {
|
515 |
+
$this->getXmlElement()->createChild('review', false, $productRating->getRatingSummary(),
|
516 |
+
$productElement);
|
517 |
+
$this->getXmlElement()->createChild('reviews_count', false,
|
518 |
+
$productRating->getReviewsCount(), $productElement);
|
519 |
+
}
|
520 |
+
|
521 |
+
$newFromDate = $this->getProduct()->getNewsFromDate();
|
522 |
+
$newToDate = $this->getProduct()->getNewsToDate();
|
523 |
+
if ($newFromDate) {
|
524 |
+
$this->getXmlElement()->createChild('newfrom', false,
|
525 |
+
Mage::getModel('core/date')->timestamp($newFromDate), $productElement);
|
526 |
+
if ($newToDate) {
|
527 |
+
$this->getXmlElement()->createChild('newto', false,
|
528 |
+
Mage::getModel('core/date')->timestamp($newToDate), $productElement);
|
529 |
+
}
|
530 |
+
}
|
531 |
+
|
532 |
+
$this->getXmlElement()->createChild('purchase_popularity', false,
|
533 |
+
$this->getOrderCount(), $productElement);
|
534 |
+
$this->getXmlElement()->createChild('product_status', false,
|
535 |
+
(($this->getProduct()->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED) ? 1 : 0), $productElement);
|
536 |
+
$this->getXmlElement()->createChild('creation_date', false,
|
537 |
+
Mage::getModel('core/date')->timestamp($this->getProduct()->getCreatedAt()), $productElement);
|
538 |
+
$this->getXmlElement()->createChild('updated_date', false,
|
539 |
+
Mage::getModel('core/date')->timestamp($this->getProduct()->getUpdatedAt()), $productElement);
|
540 |
+
|
541 |
+
if ($this->canUseAttributes()) {
|
542 |
+
$attributeSetId = $this->getProduct()->getAttributeSetId();
|
543 |
+
|
544 |
+
if (!array_key_exists($attributeSetId, $this->_attributesSetsCache)) {
|
545 |
+
$this->_attributesSetsCache[$attributeSetId] = array();
|
546 |
+
$setAttributes = Mage::getModel('catalog/product_attribute_api')->items($attributeSetId);
|
547 |
+
|
548 |
+
foreach ($setAttributes as $attrFromSet) {
|
549 |
+
$this->_attributesSetsCache[$attributeSetId][] = $attrFromSet['code'];
|
550 |
+
}
|
551 |
+
}
|
552 |
+
|
553 |
+
foreach ($this->getAttributes() as $attr) {
|
554 |
+
if (in_array($attr->getAttributeCode(), $this->_attributesSetsCache[$attributeSetId])) {
|
555 |
+
$this->renderProductAttributeXml($attr, $productElement);
|
556 |
+
}
|
557 |
+
}
|
558 |
+
}
|
559 |
+
|
560 |
+
if ($this->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
|
561 |
+
$this->getXmlElement()->createChild('product_parents', false,
|
562 |
+
implode(',', $this->getSimpleProductParent()), $productElement);
|
563 |
+
}
|
564 |
+
|
565 |
+
if ($this->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
|
566 |
+
$this->getXmlElement()->createChild('simpleproducts', false,
|
567 |
+
implode(',', $this->getConfigurableChildrenIds()), $productElement);
|
568 |
+
$this->renderProductVariantXml($productElement);
|
569 |
+
}
|
570 |
+
|
571 |
+
$this->getXmlElement()->createChild('categories', false,
|
572 |
+
implode(';', $categories), $productElement);
|
573 |
+
|
574 |
+
$this->getXmlElement()->createChild('meta_title', false,
|
575 |
+
$this->getProduct()->getMetaTitle(), $productElement);
|
576 |
+
$this->getXmlElement()->createChild('meta_description', false,
|
577 |
+
$this->getProduct()->getMetaDescription(), $productElement);
|
578 |
+
|
579 |
+
}
|
580 |
+
|
581 |
+
protected function _getOutputHelper()
|
582 |
+
{
|
583 |
+
|
584 |
+
if($this->_outputHelper==null){
|
585 |
+
$this->_outputHelper = Mage::helper('catalog/output');
|
586 |
+
}
|
587 |
+
|
588 |
+
return $this->_outputHelper;
|
589 |
+
}
|
590 |
+
|
591 |
+
public function _getAdditionalProductUrl()
|
592 |
+
{
|
593 |
+
$is_get_url_path_supported = true;
|
594 |
+
if (method_exists('Mage' , 'getVersionInfo')){ // getUrlPath is not supported on EE 1.13... & 1.14...
|
595 |
+
$edition_info = Mage::getVersionInfo();
|
596 |
+
if ($edition_info['major'] == 1 && $edition_info['minor'] >= 13){
|
597 |
+
$is_get_url_path_supported = false;
|
598 |
+
}
|
599 |
+
}
|
600 |
+
|
601 |
+
if (method_exists($this->getProduct(), 'getUrlPath') && $is_get_url_path_supported){
|
602 |
+
$product_url = $this->getProduct()->getUrlPath();
|
603 |
+
if ($product_url != ''){
|
604 |
+
$product_url = Mage::getUrl($product_url);
|
605 |
+
return $product_url;
|
606 |
+
}
|
607 |
+
}
|
608 |
+
return '';
|
609 |
+
}
|
610 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Batches.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Resource_Batches extends Mage_Core_Model_Mysql4_Abstract
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* Resource initialization.
|
7 |
-
*/
|
8 |
-
protected function _construct()
|
9 |
-
{
|
10 |
-
$this->_init('autocompleteplus_autosuggest/batches', 'id');
|
11 |
-
}
|
12 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Resource_Batches extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Resource initialization.
|
7 |
+
*/
|
8 |
+
protected function _construct()
|
9 |
+
{
|
10 |
+
$this->_init('autocompleteplus_autosuggest/batches', 'id');
|
11 |
+
}
|
12 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Batches/Collection.php
CHANGED
@@ -1,30 +1,30 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Resource_Batches_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* Initialize resource collection.
|
7 |
-
*/
|
8 |
-
public function _construct()
|
9 |
-
{
|
10 |
-
$this->_init('autocompleteplus_autosuggest/batches');
|
11 |
-
}
|
12 |
-
|
13 |
-
protected function _getWriteAdapter() {
|
14 |
-
return Mage::getSingleton('core/resource')->getConnection('core_write');
|
15 |
-
}
|
16 |
-
|
17 |
-
public function clear() {
|
18 |
-
$dbAdapter = $this->_getWriteAdapter();
|
19 |
-
|
20 |
-
Zend_Db_Table::setDefaultAdapter($dbAdapter);
|
21 |
-
|
22 |
-
$batchesTable = new Zend_Db_Table($this->getMainTable());
|
23 |
-
|
24 |
-
$where = $batchesTable->getAdapter()->quoteInto('1 > ?', 0);
|
25 |
-
|
26 |
-
$batchesTable->delete($where);
|
27 |
-
|
28 |
-
return $this;
|
29 |
-
}
|
30 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Resource_Batches_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Initialize resource collection.
|
7 |
+
*/
|
8 |
+
public function _construct()
|
9 |
+
{
|
10 |
+
$this->_init('autocompleteplus_autosuggest/batches');
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function _getWriteAdapter() {
|
14 |
+
return Mage::getSingleton('core/resource')->getConnection('core_write');
|
15 |
+
}
|
16 |
+
|
17 |
+
public function clear() {
|
18 |
+
$dbAdapter = $this->_getWriteAdapter();
|
19 |
+
|
20 |
+
Zend_Db_Table::setDefaultAdapter($dbAdapter);
|
21 |
+
|
22 |
+
$batchesTable = new Zend_Db_Table($this->getMainTable());
|
23 |
+
|
24 |
+
$where = $batchesTable->getAdapter()->quoteInto('1 > ?', 0);
|
25 |
+
|
26 |
+
$batchesTable->delete($where);
|
27 |
+
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Checksum.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Resource_Checksum extends Mage_Core_Model_Mysql4_Abstract
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* Resource initialization.
|
7 |
-
*/
|
8 |
-
protected function _construct()
|
9 |
-
{
|
10 |
-
$this->_init('autocompleteplus_autosuggest/checksum', 'identifier');
|
11 |
-
}
|
12 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Resource_Checksum extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Resource initialization.
|
7 |
+
*/
|
8 |
+
protected function _construct()
|
9 |
+
{
|
10 |
+
$this->_init('autocompleteplus_autosuggest/checksum', 'identifier');
|
11 |
+
}
|
12 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Checksum/Collection.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Resource_Checksum_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* Initialize resource collection.
|
7 |
-
*/
|
8 |
-
public function _construct()
|
9 |
-
{
|
10 |
-
$this->_init('autocompleteplus_autosuggest/checksum');
|
11 |
-
}
|
12 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Resource_Checksum_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Initialize resource collection.
|
7 |
+
*/
|
8 |
+
public function _construct()
|
9 |
+
{
|
10 |
+
$this->_init('autocompleteplus_autosuggest/checksum');
|
11 |
+
}
|
12 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Fulltext/Collection.php
CHANGED
@@ -1,225 +1,225 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento.
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
*
|
23 |
-
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Fulltext Collection.
|
29 |
-
*
|
30 |
-
* @category Mage
|
31 |
-
*
|
32 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
-
*/
|
34 |
-
class Autocompleteplus_Autosuggest_Model_Resource_Fulltext_Collection extends Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
|
35 |
-
{
|
36 |
-
protected $list_ids = array();
|
37 |
-
protected $is_fulltext_enabled = false;
|
38 |
-
|
39 |
-
protected $is_layered_enabled = false;
|
40 |
-
|
41 |
-
public function __construct($resource = null, array $args = array())
|
42 |
-
{
|
43 |
-
$layered = Mage::getStoreConfig('autocompleteplus/config/layered');
|
44 |
-
if (isset($layered) && $layered == '1') {
|
45 |
-
$this->is_layered_enabled = true;
|
46 |
-
}
|
47 |
-
parent::__construct($resource, $args);
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Retrieve query model object.
|
52 |
-
*
|
53 |
-
* @return Mage_CatalogSearch_Model_Query
|
54 |
-
*/
|
55 |
-
protected function _getQuery()
|
56 |
-
{
|
57 |
-
if (!$this->is_layered_enabled) {
|
58 |
-
return Mage::helper('catalogsearch')->getQuery();
|
59 |
-
}
|
60 |
-
|
61 |
-
return false;
|
62 |
-
}
|
63 |
-
|
64 |
-
/* compatibility with GoMage extension */
|
65 |
-
public function getSearchedEntityIds()
|
66 |
-
{
|
67 |
-
return $this->list_ids;
|
68 |
-
}
|
69 |
-
|
70 |
-
protected function getSession()
|
71 |
-
{
|
72 |
-
return Mage::getSingleton('core/session');
|
73 |
-
}
|
74 |
-
|
75 |
-
public function clearSessionData()
|
76 |
-
{
|
77 |
-
$this->getSession()->unsIsFullTextEnable();
|
78 |
-
$this->getSession()->unsIspSearchAlternatives();
|
79 |
-
$this->getSession()->unsIspSearchResultsFor();
|
80 |
-
|
81 |
-
return $this;
|
82 |
-
}
|
83 |
-
|
84 |
-
public function setSessionData($responseObj, $query)
|
85 |
-
{
|
86 |
-
// InstantSearch+ js file will be injected to the search result page
|
87 |
-
$this->getSession()->setIsFullTextEnable(true);
|
88 |
-
// recording the query for the current 'core/session' to check it when injecting the magento_full_text.js
|
89 |
-
$this->getSession()->setIspUrlEncodeQuery(urlencode($query));
|
90 |
-
|
91 |
-
if (array_key_exists('alternatives', $responseObj) && $responseObj->alternatives) {
|
92 |
-
$this->getSession()->setIspSearchAlternatives($responseObj->alternatives);
|
93 |
-
} else {
|
94 |
-
$this->getSession()->setIspSearchAlternatives(false);
|
95 |
-
}
|
96 |
-
|
97 |
-
if (array_key_exists('results_for', $responseObj) && $responseObj->results_for) {
|
98 |
-
$this->getSession()->setIspSearchResultsFor($responseObj->results_for);
|
99 |
-
} else {
|
100 |
-
$this->getSession()->setIspSearchResultsFor(false);
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
public function prepareDefaultQuery()
|
105 |
-
{
|
106 |
-
//adding if fulltext search disabled then write regular flow
|
107 |
-
Mage::getSingleton('catalogsearch/fulltext')->prepareResult();
|
108 |
-
|
109 |
-
$this->getSelect()->joinInner(
|
110 |
-
array('search_result' => $this->getTable('catalogsearch/result')),
|
111 |
-
$this->getConnection()->quoteInto(
|
112 |
-
'search_result.product_id=e.entity_id AND search_result.query_id=?',
|
113 |
-
$this->_getQuery()->getId()
|
114 |
-
),
|
115 |
-
array('relevance' => 'relevance')
|
116 |
-
);
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Add search query filter.
|
121 |
-
*
|
122 |
-
* @param string $query
|
123 |
-
*
|
124 |
-
* @return Mage_CatalogSearch_Model_Resource_Fulltext_Collection
|
125 |
-
*/
|
126 |
-
public function addSearchFilter($query)
|
127 |
-
{
|
128 |
-
if (!$this->is_layered_enabled) {
|
129 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
130 |
-
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
131 |
-
$key = $config->getUUID();
|
132 |
-
$storeId = Mage::app()->getStore()->getStoreId();
|
133 |
-
$server_end_point = $helper->getServerEndPoint();
|
134 |
-
|
135 |
-
$url_domain = $server_end_point ? $server_end_point.'/ma_search' : 'http://magento.instantsearchplus.com/ma_search';
|
136 |
-
|
137 |
-
$extension_version = Mage::helper('autocompleteplus_autosuggest')->getVersion();
|
138 |
-
$site_url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
|
139 |
-
$url = $url_domain.'?q='.urlencode($query).'&p=1&products_per_page=1000&v='.$extension_version.'&store_id='.$storeId.'&UUID='.$key.'&h='.$site_url;
|
140 |
-
|
141 |
-
$resp = $helper->sendCurl($url);
|
142 |
-
$response_json = json_decode($resp);
|
143 |
-
$enabledFulltext = array_key_exists('fulltext_disabled', $response_json) ? !$response_json->fulltext_disabled : false;
|
144 |
-
|
145 |
-
if ($enabledFulltext) {
|
146 |
-
$enabledFulltext = ((array_key_exists('id_list', $response_json)) &&
|
147 |
-
(array_key_exists('total_results', $response_json))) ? true : false;
|
148 |
-
}
|
149 |
-
|
150 |
-
$this->clearSessionData();
|
151 |
-
|
152 |
-
if (!$enabledFulltext) {
|
153 |
-
Mage::getSingleton('core/session')->setIsFullTextEnable(false);
|
154 |
-
|
155 |
-
$this->prepareDefaultQuery();
|
156 |
-
}
|
157 |
-
|
158 |
-
if ($enabledFulltext) {
|
159 |
-
$this->is_fulltext_enabled = true;
|
160 |
-
$this->setSessionData($response_json, $query);
|
161 |
-
|
162 |
-
if ($response_json->total_results) {
|
163 |
-
$id_list = $response_json->id_list;
|
164 |
-
$product_ids = array();
|
165 |
-
//validate received ids
|
166 |
-
foreach ($id_list as $id) {
|
167 |
-
if ($id != null && is_numeric($id)) {
|
168 |
-
$product_ids[] = $id;
|
169 |
-
}
|
170 |
-
}
|
171 |
-
$this->list_ids = $product_ids;
|
172 |
-
$idStr = (count($product_ids) > 0) ? implode(',', $product_ids) : '0';
|
173 |
-
} else {
|
174 |
-
$idStr = '0';
|
175 |
-
}
|
176 |
-
|
177 |
-
if (array_key_exists('server_endpoint', $response_json)) {
|
178 |
-
if ($server_end_point != $response_json->server_endpoint) {
|
179 |
-
$helper->setServerEndPoint($response_json->server_endpoint);
|
180 |
-
}
|
181 |
-
}
|
182 |
-
|
183 |
-
$this->getSelect()->where('e.entity_id IN ('.$idStr.')');
|
184 |
-
}
|
185 |
-
}
|
186 |
-
|
187 |
-
return $this;
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Set Order field.
|
192 |
-
*
|
193 |
-
* @param string $attribute
|
194 |
-
* @param string $dir
|
195 |
-
*
|
196 |
-
* @return Mage_Catalog_Model_Resource_Product_Collection
|
197 |
-
*/
|
198 |
-
public function setOrder($attribute, $dir = parent::SORT_ORDER_ASC)
|
199 |
-
{
|
200 |
-
if (!$this->is_layered_enabled) {
|
201 |
-
if ($this->is_fulltext_enabled && $attribute == 'relevance') {
|
202 |
-
$dir = parent::SORT_ORDER_ASC;
|
203 |
-
$id_str = (count($this->list_ids) > 0) ? implode(',', $this->list_ids) : '0';
|
204 |
-
if (!empty($id_str)) {
|
205 |
-
$sort = "FIELD(e.entity_id, {$id_str}) {$dir}";
|
206 |
-
$this->getSelect()->order(new Zend_Db_Expr($sort));
|
207 |
-
}
|
208 |
-
} else {
|
209 |
-
return parent::setOrder($attribute, $dir);
|
210 |
-
}
|
211 |
-
}
|
212 |
-
|
213 |
-
return $this;
|
214 |
-
}
|
215 |
-
|
216 |
-
/**
|
217 |
-
* Stub method for campatibility with other search engines.
|
218 |
-
*
|
219 |
-
* @return Mage_CatalogSearch_Model_Resource_Fulltext_Collection
|
220 |
-
*/
|
221 |
-
public function setGeneralDefaultQuery()
|
222 |
-
{
|
223 |
-
return $this;
|
224 |
-
}
|
225 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
*
|
23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Fulltext Collection.
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
*
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class Autocompleteplus_Autosuggest_Model_Resource_Fulltext_Collection extends Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
|
35 |
+
{
|
36 |
+
protected $list_ids = array();
|
37 |
+
protected $is_fulltext_enabled = false;
|
38 |
+
|
39 |
+
protected $is_layered_enabled = false;
|
40 |
+
|
41 |
+
public function __construct($resource = null, array $args = array())
|
42 |
+
{
|
43 |
+
$layered = Mage::getStoreConfig('autocompleteplus/config/layered');
|
44 |
+
if (isset($layered) && $layered == '1') {
|
45 |
+
$this->is_layered_enabled = true;
|
46 |
+
}
|
47 |
+
parent::__construct($resource, $args);
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Retrieve query model object.
|
52 |
+
*
|
53 |
+
* @return Mage_CatalogSearch_Model_Query
|
54 |
+
*/
|
55 |
+
protected function _getQuery()
|
56 |
+
{
|
57 |
+
if (!$this->is_layered_enabled) {
|
58 |
+
return Mage::helper('catalogsearch')->getQuery();
|
59 |
+
}
|
60 |
+
|
61 |
+
return false;
|
62 |
+
}
|
63 |
+
|
64 |
+
/* compatibility with GoMage extension */
|
65 |
+
public function getSearchedEntityIds()
|
66 |
+
{
|
67 |
+
return $this->list_ids;
|
68 |
+
}
|
69 |
+
|
70 |
+
protected function getSession()
|
71 |
+
{
|
72 |
+
return Mage::getSingleton('core/session');
|
73 |
+
}
|
74 |
+
|
75 |
+
public function clearSessionData()
|
76 |
+
{
|
77 |
+
$this->getSession()->unsIsFullTextEnable();
|
78 |
+
$this->getSession()->unsIspSearchAlternatives();
|
79 |
+
$this->getSession()->unsIspSearchResultsFor();
|
80 |
+
|
81 |
+
return $this;
|
82 |
+
}
|
83 |
+
|
84 |
+
public function setSessionData($responseObj, $query)
|
85 |
+
{
|
86 |
+
// InstantSearch+ js file will be injected to the search result page
|
87 |
+
$this->getSession()->setIsFullTextEnable(true);
|
88 |
+
// recording the query for the current 'core/session' to check it when injecting the magento_full_text.js
|
89 |
+
$this->getSession()->setIspUrlEncodeQuery(urlencode($query));
|
90 |
+
|
91 |
+
if (array_key_exists('alternatives', $responseObj) && $responseObj->alternatives) {
|
92 |
+
$this->getSession()->setIspSearchAlternatives($responseObj->alternatives);
|
93 |
+
} else {
|
94 |
+
$this->getSession()->setIspSearchAlternatives(false);
|
95 |
+
}
|
96 |
+
|
97 |
+
if (array_key_exists('results_for', $responseObj) && $responseObj->results_for) {
|
98 |
+
$this->getSession()->setIspSearchResultsFor($responseObj->results_for);
|
99 |
+
} else {
|
100 |
+
$this->getSession()->setIspSearchResultsFor(false);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
public function prepareDefaultQuery()
|
105 |
+
{
|
106 |
+
//adding if fulltext search disabled then write regular flow
|
107 |
+
Mage::getSingleton('catalogsearch/fulltext')->prepareResult();
|
108 |
+
|
109 |
+
$this->getSelect()->joinInner(
|
110 |
+
array('search_result' => $this->getTable('catalogsearch/result')),
|
111 |
+
$this->getConnection()->quoteInto(
|
112 |
+
'search_result.product_id=e.entity_id AND search_result.query_id=?',
|
113 |
+
$this->_getQuery()->getId()
|
114 |
+
),
|
115 |
+
array('relevance' => 'relevance')
|
116 |
+
);
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Add search query filter.
|
121 |
+
*
|
122 |
+
* @param string $query
|
123 |
+
*
|
124 |
+
* @return Mage_CatalogSearch_Model_Resource_Fulltext_Collection
|
125 |
+
*/
|
126 |
+
public function addSearchFilter($query)
|
127 |
+
{
|
128 |
+
if (!$this->is_layered_enabled) {
|
129 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
130 |
+
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
131 |
+
$key = $config->getUUID();
|
132 |
+
$storeId = Mage::app()->getStore()->getStoreId();
|
133 |
+
$server_end_point = $helper->getServerEndPoint();
|
134 |
+
|
135 |
+
$url_domain = $server_end_point ? $server_end_point.'/ma_search' : 'http://magento.instantsearchplus.com/ma_search';
|
136 |
+
|
137 |
+
$extension_version = Mage::helper('autocompleteplus_autosuggest')->getVersion();
|
138 |
+
$site_url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
|
139 |
+
$url = $url_domain.'?q='.urlencode($query).'&p=1&products_per_page=1000&v='.$extension_version.'&store_id='.$storeId.'&UUID='.$key.'&h='.$site_url;
|
140 |
+
|
141 |
+
$resp = $helper->sendCurl($url);
|
142 |
+
$response_json = json_decode($resp);
|
143 |
+
$enabledFulltext = array_key_exists('fulltext_disabled', $response_json) ? !$response_json->fulltext_disabled : false;
|
144 |
+
|
145 |
+
if ($enabledFulltext) {
|
146 |
+
$enabledFulltext = ((array_key_exists('id_list', $response_json)) &&
|
147 |
+
(array_key_exists('total_results', $response_json))) ? true : false;
|
148 |
+
}
|
149 |
+
|
150 |
+
$this->clearSessionData();
|
151 |
+
|
152 |
+
if (!$enabledFulltext) {
|
153 |
+
Mage::getSingleton('core/session')->setIsFullTextEnable(false);
|
154 |
+
|
155 |
+
$this->prepareDefaultQuery();
|
156 |
+
}
|
157 |
+
|
158 |
+
if ($enabledFulltext) {
|
159 |
+
$this->is_fulltext_enabled = true;
|
160 |
+
$this->setSessionData($response_json, $query);
|
161 |
+
|
162 |
+
if ($response_json->total_results) {
|
163 |
+
$id_list = $response_json->id_list;
|
164 |
+
$product_ids = array();
|
165 |
+
//validate received ids
|
166 |
+
foreach ($id_list as $id) {
|
167 |
+
if ($id != null && is_numeric($id)) {
|
168 |
+
$product_ids[] = $id;
|
169 |
+
}
|
170 |
+
}
|
171 |
+
$this->list_ids = $product_ids;
|
172 |
+
$idStr = (count($product_ids) > 0) ? implode(',', $product_ids) : '0';
|
173 |
+
} else {
|
174 |
+
$idStr = '0';
|
175 |
+
}
|
176 |
+
|
177 |
+
if (array_key_exists('server_endpoint', $response_json)) {
|
178 |
+
if ($server_end_point != $response_json->server_endpoint) {
|
179 |
+
$helper->setServerEndPoint($response_json->server_endpoint);
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
$this->getSelect()->where('e.entity_id IN ('.$idStr.')');
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
return $this;
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Set Order field.
|
192 |
+
*
|
193 |
+
* @param string $attribute
|
194 |
+
* @param string $dir
|
195 |
+
*
|
196 |
+
* @return Mage_Catalog_Model_Resource_Product_Collection
|
197 |
+
*/
|
198 |
+
public function setOrder($attribute, $dir = parent::SORT_ORDER_ASC)
|
199 |
+
{
|
200 |
+
if (!$this->is_layered_enabled) {
|
201 |
+
if ($this->is_fulltext_enabled && $attribute == 'relevance') {
|
202 |
+
$dir = parent::SORT_ORDER_ASC;
|
203 |
+
$id_str = (count($this->list_ids) > 0) ? implode(',', $this->list_ids) : '0';
|
204 |
+
if (!empty($id_str)) {
|
205 |
+
$sort = "FIELD(e.entity_id, {$id_str}) {$dir}";
|
206 |
+
$this->getSelect()->order(new Zend_Db_Expr($sort));
|
207 |
+
}
|
208 |
+
} else {
|
209 |
+
return parent::setOrder($attribute, $dir);
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
return $this;
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Stub method for campatibility with other search engines.
|
218 |
+
*
|
219 |
+
* @return Mage_CatalogSearch_Model_Resource_Fulltext_Collection
|
220 |
+
*/
|
221 |
+
public function setGeneralDefaultQuery()
|
222 |
+
{
|
223 |
+
return $this;
|
224 |
+
}
|
225 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Notifications.php
CHANGED
@@ -1,40 +1,40 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* InstantSearchPlus (Autosuggest).
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is available through the world-wide-web at this URL:
|
9 |
-
* http://opensource.org/licenses/osl-3.0.php
|
10 |
-
*
|
11 |
-
* @category Mage
|
12 |
-
*
|
13 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
class Autocompleteplus_Autosuggest_Model_Resource_Notifications extends Mage_Core_Model_Mysql4_Abstract
|
17 |
-
{
|
18 |
-
protected function _construct()
|
19 |
-
{
|
20 |
-
$this->_init('autocompleteplus_autosuggest/notifications', 'notification_id');
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* @param array $notifications
|
25 |
-
*/
|
26 |
-
public function addNotifications($notifications)
|
27 |
-
{
|
28 |
-
$write = $this->_getWriteAdapter();
|
29 |
-
foreach ($notifications as $item) {
|
30 |
-
$select = $write->select()
|
31 |
-
->from($this->getMainTable())
|
32 |
-
->where('type=?', $item['type'])
|
33 |
-
->where('timestamp=?', $item['timestamp']);
|
34 |
-
$row = $write->fetchRow($select);
|
35 |
-
if (!$row) {
|
36 |
-
$write->insert($this->getMainTable(), $item);
|
37 |
-
}
|
38 |
-
}
|
39 |
-
}
|
40 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* InstantSearchPlus (Autosuggest).
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Mage
|
12 |
+
*
|
13 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
class Autocompleteplus_Autosuggest_Model_Resource_Notifications extends Mage_Core_Model_Mysql4_Abstract
|
17 |
+
{
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
$this->_init('autocompleteplus_autosuggest/notifications', 'notification_id');
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @param array $notifications
|
25 |
+
*/
|
26 |
+
public function addNotifications($notifications)
|
27 |
+
{
|
28 |
+
$write = $this->_getWriteAdapter();
|
29 |
+
foreach ($notifications as $item) {
|
30 |
+
$select = $write->select()
|
31 |
+
->from($this->getMainTable())
|
32 |
+
->where('type=?', $item['type'])
|
33 |
+
->where('timestamp=?', $item['timestamp']);
|
34 |
+
$row = $write->fetchRow($select);
|
35 |
+
if (!$row) {
|
36 |
+
$write->insert($this->getMainTable(), $item);
|
37 |
+
}
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Notifications/Collection.php
CHANGED
@@ -1,44 +1,44 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* InstantSearchPlus (Autosuggest).
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is available through the world-wide-web at this URL:
|
9 |
-
* http://opensource.org/licenses/osl-3.0.php
|
10 |
-
*
|
11 |
-
* @category Mage
|
12 |
-
*
|
13 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
class Autocompleteplus_Autosuggest_Model_Resource_Notifications_Collection
|
17 |
-
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
18 |
-
{
|
19 |
-
protected function _construct()
|
20 |
-
{
|
21 |
-
$this->_init('autocompleteplus_autosuggest/notifications');
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @param string $type
|
26 |
-
*
|
27 |
-
* @return $this
|
28 |
-
*/
|
29 |
-
public function addTypeFilter($type)
|
30 |
-
{
|
31 |
-
$this->getSelect()
|
32 |
-
->where('type=?', $type);
|
33 |
-
|
34 |
-
return $this;
|
35 |
-
}
|
36 |
-
|
37 |
-
public function addActiveFilter()
|
38 |
-
{
|
39 |
-
$this->getSelect()
|
40 |
-
->where('is_active=?', 1);
|
41 |
-
|
42 |
-
return $this;
|
43 |
-
}
|
44 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* InstantSearchPlus (Autosuggest).
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Mage
|
12 |
+
*
|
13 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
class Autocompleteplus_Autosuggest_Model_Resource_Notifications_Collection
|
17 |
+
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
18 |
+
{
|
19 |
+
protected function _construct()
|
20 |
+
{
|
21 |
+
$this->_init('autocompleteplus_autosuggest/notifications');
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @param string $type
|
26 |
+
*
|
27 |
+
* @return $this
|
28 |
+
*/
|
29 |
+
public function addTypeFilter($type)
|
30 |
+
{
|
31 |
+
$this->getSelect()
|
32 |
+
->where('type=?', $type);
|
33 |
+
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function addActiveFilter()
|
38 |
+
{
|
39 |
+
$this->getSelect()
|
40 |
+
->where('is_active=?', 1);
|
41 |
+
|
42 |
+
return $this;
|
43 |
+
}
|
44 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Pusher.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Resource_Pusher extends Mage_Core_Model_Mysql4_Abstract
|
4 |
-
{
|
5 |
-
protected function _construct()
|
6 |
-
{
|
7 |
-
$this->_init('autocompleteplus_autosuggest/pusher', 'id');
|
8 |
-
}
|
9 |
-
|
10 |
-
public function truncate()
|
11 |
-
{
|
12 |
-
$this->_getWriteAdapter()->query('TRUNCATE TABLE '.$this->getMainTable());
|
13 |
-
|
14 |
-
return $this;
|
15 |
-
}
|
16 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Resource_Pusher extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('autocompleteplus_autosuggest/pusher', 'id');
|
8 |
+
}
|
9 |
+
|
10 |
+
public function truncate()
|
11 |
+
{
|
12 |
+
$this->_getWriteAdapter()->query('TRUNCATE TABLE '.$this->getMainTable());
|
13 |
+
|
14 |
+
return $this;
|
15 |
+
}
|
16 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Pusher/Collection.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Resource_Pusher_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
-
{
|
5 |
-
public function _construct()
|
6 |
-
{
|
7 |
-
$this->_init('autocompleteplus_autosuggest/pusher');
|
8 |
-
}
|
9 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Resource_Pusher_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('autocompleteplus_autosuggest/pusher');
|
8 |
+
}
|
9 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Service.php
CHANGED
@@ -1,55 +1,55 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Model_Service
|
4 |
-
{
|
5 |
-
public function populatePusher()
|
6 |
-
{
|
7 |
-
$inserts = array();
|
8 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
9 |
-
|
10 |
-
$multistoreJson = $helper->getMultiStoreDataJson();
|
11 |
-
$storesInfo = json_decode($multistoreJson);
|
12 |
-
|
13 |
-
//truncate the log table
|
14 |
-
Mage::getResourceModel('autocompleteplus_autosuggest/pusher')->truncate();
|
15 |
-
|
16 |
-
foreach ($storesInfo->stores as $i => $store) {
|
17 |
-
$id = $store->store_id;
|
18 |
-
|
19 |
-
$productCollection = Mage::getModel('catalog/product')->getCollection()->setStoreId($id);
|
20 |
-
$productsCount = $productCollection->getSize();
|
21 |
-
|
22 |
-
$batches = ceil($productsCount / 100);
|
23 |
-
$offset = 0;
|
24 |
-
|
25 |
-
for ($j = 1;$j <= $batches;++$j) {
|
26 |
-
$inserts[] = array(
|
27 |
-
'store_id' => $id,
|
28 |
-
'to_send' => $productsCount,
|
29 |
-
'offset' => $offset,
|
30 |
-
'batch_number' => $j,
|
31 |
-
'total_batches' => $batches,
|
32 |
-
'sent' => 0,
|
33 |
-
);
|
34 |
-
|
35 |
-
$offset += 100;
|
36 |
-
}
|
37 |
-
}
|
38 |
-
|
39 |
-
if ($inserts) {
|
40 |
-
$write = $this->_getWriteAdapter();
|
41 |
-
$tableName = $this->_getTable('autocompleteplus_autosuggest/pusher');
|
42 |
-
$write->insertMultiple($tableName, $inserts);
|
43 |
-
}
|
44 |
-
}
|
45 |
-
|
46 |
-
protected function _getWriteAdapter()
|
47 |
-
{
|
48 |
-
return Mage::getSingleton('core/resource')->getConnection('core_write');
|
49 |
-
}
|
50 |
-
|
51 |
-
protected function _getTable($resourceName)
|
52 |
-
{
|
53 |
-
return Mage::getSingleton('core/resource')->getTableName($resourceName);
|
54 |
-
}
|
55 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Model_Service
|
4 |
+
{
|
5 |
+
public function populatePusher()
|
6 |
+
{
|
7 |
+
$inserts = array();
|
8 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
9 |
+
|
10 |
+
$multistoreJson = $helper->getMultiStoreDataJson();
|
11 |
+
$storesInfo = json_decode($multistoreJson);
|
12 |
+
|
13 |
+
//truncate the log table
|
14 |
+
Mage::getResourceModel('autocompleteplus_autosuggest/pusher')->truncate();
|
15 |
+
|
16 |
+
foreach ($storesInfo->stores as $i => $store) {
|
17 |
+
$id = $store->store_id;
|
18 |
+
|
19 |
+
$productCollection = Mage::getModel('catalog/product')->getCollection()->setStoreId($id);
|
20 |
+
$productsCount = $productCollection->getSize();
|
21 |
+
|
22 |
+
$batches = ceil($productsCount / 100);
|
23 |
+
$offset = 0;
|
24 |
+
|
25 |
+
for ($j = 1;$j <= $batches;++$j) {
|
26 |
+
$inserts[] = array(
|
27 |
+
'store_id' => $id,
|
28 |
+
'to_send' => $productsCount,
|
29 |
+
'offset' => $offset,
|
30 |
+
'batch_number' => $j,
|
31 |
+
'total_batches' => $batches,
|
32 |
+
'sent' => 0,
|
33 |
+
);
|
34 |
+
|
35 |
+
$offset += 100;
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
if ($inserts) {
|
40 |
+
$write = $this->_getWriteAdapter();
|
41 |
+
$tableName = $this->_getTable('autocompleteplus_autosuggest/pusher');
|
42 |
+
$write->insertMultiple($tableName, $inserts);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
protected function _getWriteAdapter()
|
47 |
+
{
|
48 |
+
return Mage::getSingleton('core/resource')->getConnection('core_write');
|
49 |
+
}
|
50 |
+
|
51 |
+
protected function _getTable($resourceName)
|
52 |
+
{
|
53 |
+
return Mage::getSingleton('core/resource')->getTableName($resourceName);
|
54 |
+
}
|
55 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/controllers/Adminhtml/Autocompleteplus/PushController.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Adminhtml_Autocompleteplus_PushController extends Mage_Adminhtml_Controller_Action
|
4 |
-
{
|
5 |
-
public function startpushAction()
|
6 |
-
{
|
7 |
-
$service = Mage::getModel('autocompleteplus_autosuggest/service');
|
8 |
-
$service->populatePusher();
|
9 |
-
|
10 |
-
$this->loadLayout();
|
11 |
-
$this->renderLayout();
|
12 |
-
}
|
13 |
-
|
14 |
-
protected function _isAllowed()
|
15 |
-
{
|
16 |
-
return Mage::getSingleton('admin/session')->isAllowed('system/config/autocompleteplus');
|
17 |
-
}
|
18 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Adminhtml_Autocompleteplus_PushController extends Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
public function startpushAction()
|
6 |
+
{
|
7 |
+
$service = Mage::getModel('autocompleteplus_autosuggest/service');
|
8 |
+
$service->populatePusher();
|
9 |
+
|
10 |
+
$this->loadLayout();
|
11 |
+
$this->renderLayout();
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _isAllowed()
|
15 |
+
{
|
16 |
+
return Mage::getSingleton('admin/session')->isAllowed('system/config/autocompleteplus');
|
17 |
+
}
|
18 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/controllers/Adminhtml/Autocompleteplus/RedirectController.php
CHANGED
@@ -1,39 +1,39 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Adminhtml_Autocompleteplus_RedirectController extends Mage_Adminhtml_Controller_Action
|
4 |
-
{
|
5 |
-
const ISP_SITE_URL = 'https://magento.instantsearchplus.com/';
|
6 |
-
const REDIRECT_STATUS_CODE = 302;
|
7 |
-
|
8 |
-
protected function _getConfig()
|
9 |
-
{
|
10 |
-
return Mage::getModel('autocompleteplus_autosuggest/config');
|
11 |
-
}
|
12 |
-
|
13 |
-
public function gotoAction()
|
14 |
-
{
|
15 |
-
$kwys = $this->_getConfig()->getBothKeys();
|
16 |
-
$response = $this->getResponse();
|
17 |
-
|
18 |
-
$response->clearHeaders();
|
19 |
-
$response->setRedirect($this->_getIspLoginUrl($kwys), self::REDIRECT_STATUS_CODE);
|
20 |
-
$response->sendResponse();
|
21 |
-
}
|
22 |
-
|
23 |
-
protected function _getIspLoginUrl($kwys)
|
24 |
-
{
|
25 |
-
$uuid = $kwys['uuid'];
|
26 |
-
$authkey = $kwys['authkey'];
|
27 |
-
|
28 |
-
if (!isset($uuid) || !isset($authkey)) {
|
29 |
-
return self::ISP_SITE_URL.'login';
|
30 |
-
}
|
31 |
-
|
32 |
-
return self::ISP_SITE_URL."ma_dashboard?site_id=$uuid&authentication_key=$authkey";
|
33 |
-
}
|
34 |
-
|
35 |
-
protected function _isAllowed()
|
36 |
-
{
|
37 |
-
return Mage::getSingleton('admin/session')->isAllowed('system/config/autocompleteplus');
|
38 |
-
}
|
39 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Adminhtml_Autocompleteplus_RedirectController extends Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
const ISP_SITE_URL = 'https://magento.instantsearchplus.com/';
|
6 |
+
const REDIRECT_STATUS_CODE = 302;
|
7 |
+
|
8 |
+
protected function _getConfig()
|
9 |
+
{
|
10 |
+
return Mage::getModel('autocompleteplus_autosuggest/config');
|
11 |
+
}
|
12 |
+
|
13 |
+
public function gotoAction()
|
14 |
+
{
|
15 |
+
$kwys = $this->_getConfig()->getBothKeys();
|
16 |
+
$response = $this->getResponse();
|
17 |
+
|
18 |
+
$response->clearHeaders();
|
19 |
+
$response->setRedirect($this->_getIspLoginUrl($kwys), self::REDIRECT_STATUS_CODE);
|
20 |
+
$response->sendResponse();
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _getIspLoginUrl($kwys)
|
24 |
+
{
|
25 |
+
$uuid = $kwys['uuid'];
|
26 |
+
$authkey = $kwys['authkey'];
|
27 |
+
|
28 |
+
if (!isset($uuid) || !isset($authkey)) {
|
29 |
+
return self::ISP_SITE_URL.'login';
|
30 |
+
}
|
31 |
+
|
32 |
+
return self::ISP_SITE_URL."ma_dashboard?site_id=$uuid&authentication_key=$authkey";
|
33 |
+
}
|
34 |
+
|
35 |
+
protected function _isAllowed()
|
36 |
+
{
|
37 |
+
return Mage::getSingleton('admin/session')->isAllowed('system/config/autocompleteplus');
|
38 |
+
}
|
39 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/controllers/CatalogSearch/ResultController.php
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once 'Mage/CatalogSearch/controllers/ResultController.php';
|
4 |
-
|
5 |
-
class Autocompleteplus_Autosuggest_CatalogSearch_ResultController extends Mage_CatalogSearch_ResultController
|
6 |
-
{
|
7 |
-
public function indexAction()
|
8 |
-
{
|
9 |
-
try {
|
10 |
-
$layered = Mage::getStoreConfig('autocompleteplus/config/layered');
|
11 |
-
} catch (Exception $e) {
|
12 |
-
Mage::log('ResultController::indexAction() exception: '.$e->getMessage(), null, 'autocompleteplus.log');
|
13 |
-
}
|
14 |
-
if (isset($layered) && $layered == 1) {
|
15 |
-
$this->loadLayout();
|
16 |
-
$this->renderLayout();
|
17 |
-
} else {
|
18 |
-
parent::indexAction();
|
19 |
-
}
|
20 |
-
}
|
21 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once 'Mage/CatalogSearch/controllers/ResultController.php';
|
4 |
+
|
5 |
+
class Autocompleteplus_Autosuggest_CatalogSearch_ResultController extends Mage_CatalogSearch_ResultController
|
6 |
+
{
|
7 |
+
public function indexAction()
|
8 |
+
{
|
9 |
+
try {
|
10 |
+
$layered = Mage::getStoreConfig('autocompleteplus/config/layered');
|
11 |
+
} catch (Exception $e) {
|
12 |
+
Mage::log('ResultController::indexAction() exception: '.$e->getMessage(), null, 'autocompleteplus.log');
|
13 |
+
}
|
14 |
+
if (isset($layered) && $layered == 1) {
|
15 |
+
$this->loadLayout();
|
16 |
+
$this->renderLayout();
|
17 |
+
} else {
|
18 |
+
parent::indexAction();
|
19 |
+
}
|
20 |
+
}
|
21 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/controllers/CatalogsearchController.php
CHANGED
@@ -1,87 +1,87 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento.
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
*
|
23 |
-
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Catalog Search Controller.
|
29 |
-
*/
|
30 |
-
class Autocompleteplus_Autosuggest_CatalogSearchController extends Mage_Core_Controller_Front_Action
|
31 |
-
{
|
32 |
-
/**
|
33 |
-
* Retrieve catalog session.
|
34 |
-
*
|
35 |
-
* @return Mage_Catalog_Model_Session
|
36 |
-
*/
|
37 |
-
protected function _getSession()
|
38 |
-
{
|
39 |
-
return Mage::getSingleton('catalog/session');
|
40 |
-
}
|
41 |
-
/**
|
42 |
-
* Display search result.
|
43 |
-
*/
|
44 |
-
public function indexAction()
|
45 |
-
{
|
46 |
-
$query = Mage::helper('catalogsearch')->getQuery();
|
47 |
-
/* @var $query Mage_CatalogSearch_Model_Query */
|
48 |
-
|
49 |
-
$query->setStoreId(Mage::app()->getStore()->getId());
|
50 |
-
|
51 |
-
if ($query->getQueryText()) {
|
52 |
-
if (Mage::helper('catalogsearch')->isMinQueryLength()) {
|
53 |
-
$query->setId(0)
|
54 |
-
->setIsActive(1)
|
55 |
-
->setIsProcessed(1);
|
56 |
-
} else {
|
57 |
-
if ($query->getId()) {
|
58 |
-
$query->setPopularity($query->getPopularity() + 1);
|
59 |
-
} else {
|
60 |
-
$query->setPopularity(1);
|
61 |
-
}
|
62 |
-
|
63 |
-
if ($query->getRedirect()) {
|
64 |
-
$query->save();
|
65 |
-
$this->getResponse()->setRedirect($query->getRedirect());
|
66 |
-
|
67 |
-
return;
|
68 |
-
} else {
|
69 |
-
$query->prepare();
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
Mage::helper('catalogsearch')->checkNotes();
|
74 |
-
|
75 |
-
$this->loadLayout();
|
76 |
-
$this->_initLayoutMessages('catalog/session');
|
77 |
-
$this->_initLayoutMessages('checkout/session');
|
78 |
-
$this->renderLayout();
|
79 |
-
|
80 |
-
if (!Mage::helper('catalogsearch')->isMinQueryLength()) {
|
81 |
-
$query->save();
|
82 |
-
}
|
83 |
-
} else {
|
84 |
-
$this->_redirectReferer();
|
85 |
-
}
|
86 |
-
}
|
87 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
*
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Catalog Search Controller.
|
29 |
+
*/
|
30 |
+
class Autocompleteplus_Autosuggest_CatalogSearchController extends Mage_Core_Controller_Front_Action
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* Retrieve catalog session.
|
34 |
+
*
|
35 |
+
* @return Mage_Catalog_Model_Session
|
36 |
+
*/
|
37 |
+
protected function _getSession()
|
38 |
+
{
|
39 |
+
return Mage::getSingleton('catalog/session');
|
40 |
+
}
|
41 |
+
/**
|
42 |
+
* Display search result.
|
43 |
+
*/
|
44 |
+
public function indexAction()
|
45 |
+
{
|
46 |
+
$query = Mage::helper('catalogsearch')->getQuery();
|
47 |
+
/* @var $query Mage_CatalogSearch_Model_Query */
|
48 |
+
|
49 |
+
$query->setStoreId(Mage::app()->getStore()->getId());
|
50 |
+
|
51 |
+
if ($query->getQueryText()) {
|
52 |
+
if (Mage::helper('catalogsearch')->isMinQueryLength()) {
|
53 |
+
$query->setId(0)
|
54 |
+
->setIsActive(1)
|
55 |
+
->setIsProcessed(1);
|
56 |
+
} else {
|
57 |
+
if ($query->getId()) {
|
58 |
+
$query->setPopularity($query->getPopularity() + 1);
|
59 |
+
} else {
|
60 |
+
$query->setPopularity(1);
|
61 |
+
}
|
62 |
+
|
63 |
+
if ($query->getRedirect()) {
|
64 |
+
$query->save();
|
65 |
+
$this->getResponse()->setRedirect($query->getRedirect());
|
66 |
+
|
67 |
+
return;
|
68 |
+
} else {
|
69 |
+
$query->prepare();
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
Mage::helper('catalogsearch')->checkNotes();
|
74 |
+
|
75 |
+
$this->loadLayout();
|
76 |
+
$this->_initLayoutMessages('catalog/session');
|
77 |
+
$this->_initLayoutMessages('checkout/session');
|
78 |
+
$this->renderLayout();
|
79 |
+
|
80 |
+
if (!Mage::helper('catalogsearch')->isMinQueryLength()) {
|
81 |
+
$query->save();
|
82 |
+
}
|
83 |
+
} else {
|
84 |
+
$this->_redirectReferer();
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/controllers/CategoriesController.php
CHANGED
@@ -1,116 +1,116 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* InstantSearchPlus (Autosuggest).
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is available through the world-wide-web at this URL:
|
9 |
-
* http://opensource.org/licenses/osl-3.0.php
|
10 |
-
*
|
11 |
-
* @category Mage
|
12 |
-
*
|
13 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
class Autocompleteplus_Autosuggest_CategoriesController extends Mage_Core_Controller_Front_Action
|
17 |
-
{
|
18 |
-
public function sendAction()
|
19 |
-
{
|
20 |
-
$categories = $this->loadTree();
|
21 |
-
|
22 |
-
$response = $this->getResponse();
|
23 |
-
$response->clearHeaders();
|
24 |
-
$response->setHeader('Content-type', 'application/json');
|
25 |
-
|
26 |
-
$response->setBody(json_encode($categories));
|
27 |
-
}
|
28 |
-
|
29 |
-
protected function nodeToArray(Varien_Data_Tree_Node $node, $mediaUrl, $baseUrl, $store)
|
30 |
-
{
|
31 |
-
$thumbnail = '';
|
32 |
-
|
33 |
-
try {
|
34 |
-
if ($thumbImg = $node->getThumbnail()) {
|
35 |
-
$thumbnail = sprintf('%scatalog/category/%s', $mediaUrl, $node->getThumbnail());
|
36 |
-
}
|
37 |
-
} catch (Exception $e) {
|
38 |
-
Mage::logException($e);
|
39 |
-
}
|
40 |
-
|
41 |
-
$category = Mage::getModel('catalog/category')->setStoreId($store)->load($node->getId());
|
42 |
-
|
43 |
-
$result = array(
|
44 |
-
'category_id' => $node->getId(),
|
45 |
-
'image' => sprintf('%scatalog/category/%s', $mediaUrl, $node->getImage()),
|
46 |
-
'thumbnail' => $thumbnail,
|
47 |
-
'description' => strip_tags($node->getDescription()),
|
48 |
-
'parent_id' => $node->getParentId(),
|
49 |
-
'name' => $node->getName(),
|
50 |
-
'url_path' => $category->getUrl(),
|
51 |
-
'is_active' => $node->getIsActive(),
|
52 |
-
'children' => array(),
|
53 |
-
);
|
54 |
-
|
55 |
-
foreach ($node->getChildren() as $child) {
|
56 |
-
$result['children'][] = $this->nodeToArray($child, $mediaUrl, $baseUrl, $store);
|
57 |
-
}
|
58 |
-
|
59 |
-
return $result;
|
60 |
-
}
|
61 |
-
|
62 |
-
protected function loadTree()
|
63 |
-
{
|
64 |
-
$storeContext = Mage::app()->getStore()->getStoreId();
|
65 |
-
$tree = Mage::getResourceSingleton('catalog/category_tree')->load();
|
66 |
-
$store = $this->getRequest()->getParam('store', $storeContext);
|
67 |
-
$parentId = Mage::app()->getStore($store)->getRootCategoryId();
|
68 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
69 |
-
|
70 |
-
$root = $tree->getNodeById($parentId);
|
71 |
-
|
72 |
-
if ($root && $root->getId() == 1) {
|
73 |
-
$root->setName(Mage::helper('catalog')->__('Root'));
|
74 |
-
}
|
75 |
-
|
76 |
-
$collection = Mage::getModel('catalog/category')->getCollection()
|
77 |
-
->setStoreId($store)
|
78 |
-
->addAttributeToSelect('name')
|
79 |
-
->addAttributeToSelect('url_path')
|
80 |
-
->addAttributeToFilter('is_active', array('eq' => true));
|
81 |
-
|
82 |
-
if (!$helper->getConfigDataByFullPath('catalog/frontend/flat_catalog_category')) {
|
83 |
-
$collection=$collection->addAttributeToSelect('image')
|
84 |
-
->addAttributeToSelect('description')
|
85 |
-
->addAttributeToSelect('thumbnail');
|
86 |
-
} else {
|
87 |
-
$resource = Mage::getSingleton('core/resource');
|
88 |
-
|
89 |
-
$readConnection = $resource->getConnection('core_read');
|
90 |
-
|
91 |
-
$tableName=$resource->getTableName('catalog/category_flat') . '_store_' . $store;
|
92 |
-
|
93 |
-
$tableInfo=$readConnection->describeTable($tableName);
|
94 |
-
|
95 |
-
if (array_key_exists('thumbnail',$tableInfo)) {
|
96 |
-
$collection=$collection->addAttributeToSelect('thumbnail');
|
97 |
-
}
|
98 |
-
|
99 |
-
if (array_key_exists('image',$tableInfo)) {
|
100 |
-
$collection=$collection->addAttributeToSelect('image');
|
101 |
-
}
|
102 |
-
|
103 |
-
if (array_key_exists('description',$tableInfo)) {
|
104 |
-
$collection=$collection->addAttributeToSelect('description');
|
105 |
-
}
|
106 |
-
|
107 |
-
}
|
108 |
-
|
109 |
-
$tree->addCollectionData($collection, true);
|
110 |
-
|
111 |
-
$mediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
112 |
-
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
113 |
-
|
114 |
-
return $this->nodeToArray($root, $mediaUrl, $baseUrl, $store);
|
115 |
-
}
|
116 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* InstantSearchPlus (Autosuggest).
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Mage
|
12 |
+
*
|
13 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
class Autocompleteplus_Autosuggest_CategoriesController extends Mage_Core_Controller_Front_Action
|
17 |
+
{
|
18 |
+
public function sendAction()
|
19 |
+
{
|
20 |
+
$categories = $this->loadTree();
|
21 |
+
|
22 |
+
$response = $this->getResponse();
|
23 |
+
$response->clearHeaders();
|
24 |
+
$response->setHeader('Content-type', 'application/json');
|
25 |
+
|
26 |
+
$response->setBody(json_encode($categories));
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function nodeToArray(Varien_Data_Tree_Node $node, $mediaUrl, $baseUrl, $store)
|
30 |
+
{
|
31 |
+
$thumbnail = '';
|
32 |
+
|
33 |
+
try {
|
34 |
+
if ($thumbImg = $node->getThumbnail()) {
|
35 |
+
$thumbnail = sprintf('%scatalog/category/%s', $mediaUrl, $node->getThumbnail());
|
36 |
+
}
|
37 |
+
} catch (Exception $e) {
|
38 |
+
Mage::logException($e);
|
39 |
+
}
|
40 |
+
|
41 |
+
$category = Mage::getModel('catalog/category')->setStoreId($store)->load($node->getId());
|
42 |
+
|
43 |
+
$result = array(
|
44 |
+
'category_id' => $node->getId(),
|
45 |
+
'image' => sprintf('%scatalog/category/%s', $mediaUrl, $node->getImage()),
|
46 |
+
'thumbnail' => $thumbnail,
|
47 |
+
'description' => strip_tags($node->getDescription()),
|
48 |
+
'parent_id' => $node->getParentId(),
|
49 |
+
'name' => $node->getName(),
|
50 |
+
'url_path' => $category->getUrl(),
|
51 |
+
'is_active' => $node->getIsActive(),
|
52 |
+
'children' => array(),
|
53 |
+
);
|
54 |
+
|
55 |
+
foreach ($node->getChildren() as $child) {
|
56 |
+
$result['children'][] = $this->nodeToArray($child, $mediaUrl, $baseUrl, $store);
|
57 |
+
}
|
58 |
+
|
59 |
+
return $result;
|
60 |
+
}
|
61 |
+
|
62 |
+
protected function loadTree()
|
63 |
+
{
|
64 |
+
$storeContext = Mage::app()->getStore()->getStoreId();
|
65 |
+
$tree = Mage::getResourceSingleton('catalog/category_tree')->load();
|
66 |
+
$store = $this->getRequest()->getParam('store', $storeContext);
|
67 |
+
$parentId = Mage::app()->getStore($store)->getRootCategoryId();
|
68 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
69 |
+
|
70 |
+
$root = $tree->getNodeById($parentId);
|
71 |
+
|
72 |
+
if ($root && $root->getId() == 1) {
|
73 |
+
$root->setName(Mage::helper('catalog')->__('Root'));
|
74 |
+
}
|
75 |
+
|
76 |
+
$collection = Mage::getModel('catalog/category')->getCollection()
|
77 |
+
->setStoreId($store)
|
78 |
+
->addAttributeToSelect('name')
|
79 |
+
->addAttributeToSelect('url_path')
|
80 |
+
->addAttributeToFilter('is_active', array('eq' => true));
|
81 |
+
|
82 |
+
if (!$helper->getConfigDataByFullPath('catalog/frontend/flat_catalog_category')) {
|
83 |
+
$collection=$collection->addAttributeToSelect('image')
|
84 |
+
->addAttributeToSelect('description')
|
85 |
+
->addAttributeToSelect('thumbnail');
|
86 |
+
} else {
|
87 |
+
$resource = Mage::getSingleton('core/resource');
|
88 |
+
|
89 |
+
$readConnection = $resource->getConnection('core_read');
|
90 |
+
|
91 |
+
$tableName=$resource->getTableName('catalog/category_flat') . '_store_' . $store;
|
92 |
+
|
93 |
+
$tableInfo=$readConnection->describeTable($tableName);
|
94 |
+
|
95 |
+
if (array_key_exists('thumbnail',$tableInfo)) {
|
96 |
+
$collection=$collection->addAttributeToSelect('thumbnail');
|
97 |
+
}
|
98 |
+
|
99 |
+
if (array_key_exists('image',$tableInfo)) {
|
100 |
+
$collection=$collection->addAttributeToSelect('image');
|
101 |
+
}
|
102 |
+
|
103 |
+
if (array_key_exists('description',$tableInfo)) {
|
104 |
+
$collection=$collection->addAttributeToSelect('description');
|
105 |
+
}
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
$tree->addCollectionData($collection, true);
|
110 |
+
|
111 |
+
$mediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
112 |
+
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
113 |
+
|
114 |
+
return $this->nodeToArray($root, $mediaUrl, $baseUrl, $store);
|
115 |
+
}
|
116 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/controllers/LayeredController.php
CHANGED
@@ -1,129 +1,129 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controller_Front_Action
|
4 |
-
{
|
5 |
-
public function preDispatch()
|
6 |
-
{
|
7 |
-
parent::preDispatch();
|
8 |
-
|
9 |
-
$this->getResponse()->clearHeaders();
|
10 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
11 |
-
}
|
12 |
-
|
13 |
-
protected function _getConfig()
|
14 |
-
{
|
15 |
-
return Mage::getModel('autocompleteplus_autosuggest/config');
|
16 |
-
}
|
17 |
-
|
18 |
-
public function setLayeredSearchOnAction()
|
19 |
-
{
|
20 |
-
$response = $this->getResponse();
|
21 |
-
$request = $this->getRequest();
|
22 |
-
$authkey = $request->getParam('authentication_key');
|
23 |
-
$uuid = $request->getParam('uuid');
|
24 |
-
$scope = $request->getParam('scope', 'stores');
|
25 |
-
$scopeId = $request->getParam('store_id', 1);
|
26 |
-
|
27 |
-
if (!$this->valid($uuid, $authkey)) {
|
28 |
-
$resp = json_encode(array('status' => 'error: '.'Authentication failed'));
|
29 |
-
$response->setBody($resp);
|
30 |
-
|
31 |
-
return;
|
32 |
-
}
|
33 |
-
|
34 |
-
try {
|
35 |
-
$this->_getConfig()->enableLayeredNavigation($scope, $scopeId);
|
36 |
-
Mage::app()->getCacheInstance()->cleanType('config');
|
37 |
-
} catch (Exception $e) {
|
38 |
-
$resp = json_encode(array('status' => 'error: '.print_r($e->getMessage(), true)));
|
39 |
-
$response->setBody($resp);
|
40 |
-
|
41 |
-
Mage::logException($e);
|
42 |
-
|
43 |
-
return;
|
44 |
-
}
|
45 |
-
|
46 |
-
$resp = array('new_state' => 1,
|
47 |
-
'status' => 'ok',
|
48 |
-
);
|
49 |
-
|
50 |
-
$response->setBody(json_encode($resp));
|
51 |
-
}
|
52 |
-
|
53 |
-
public function setLayeredSearchOffAction()
|
54 |
-
{
|
55 |
-
$request = $this->getRequest();
|
56 |
-
$response = $this->getResponse();
|
57 |
-
$authkey = $request->getParam('authentication_key');
|
58 |
-
$uuid = $request->getParam('uuid');
|
59 |
-
$scope = $request->getParam('scope', 'stores');
|
60 |
-
$scopeId = $request->getParam('store_id', 1);
|
61 |
-
|
62 |
-
if (!$this->valid($uuid, $authkey)) {
|
63 |
-
$resp = json_encode(array('status' => 'error: '.'Authentication failed'));
|
64 |
-
|
65 |
-
$response->setBody($resp);
|
66 |
-
|
67 |
-
return;
|
68 |
-
}
|
69 |
-
|
70 |
-
try {
|
71 |
-
$this->_getConfig()->disableLayeredNavigation($scope, $scopeId);
|
72 |
-
Mage::app()->getCacheInstance()->cleanType('config');
|
73 |
-
} catch (Exception $e) {
|
74 |
-
$resp = json_encode(array('status' => 'error: '.print_r($e->getMessage(), true)));
|
75 |
-
$response->setBody($resp);
|
76 |
-
|
77 |
-
Mage::logException($e);
|
78 |
-
|
79 |
-
return;
|
80 |
-
}
|
81 |
-
|
82 |
-
$resp = array('new_state' => 0,
|
83 |
-
'status' => 'ok',
|
84 |
-
);
|
85 |
-
|
86 |
-
$response->setBody(json_encode($resp));
|
87 |
-
}
|
88 |
-
|
89 |
-
public function getLayeredSearchConfigAction()
|
90 |
-
{
|
91 |
-
$request = $this->getRequest();
|
92 |
-
$response = $this->getResponse();
|
93 |
-
|
94 |
-
$authkey = $request->getParam('authentication_key');
|
95 |
-
$uuid = $request->getParam('uuid');
|
96 |
-
$scopeId = $request->getParam('store_id', 1);
|
97 |
-
|
98 |
-
if (!$this->valid($uuid, $authkey)) {
|
99 |
-
$resp = json_encode(array('status' => $this->__('error: Authentication failed')));
|
100 |
-
$response->setBody($resp);
|
101 |
-
|
102 |
-
return;
|
103 |
-
}
|
104 |
-
try {
|
105 |
-
Mage::app()->getCacheInstance()->cleanType('config');
|
106 |
-
$current_state = $this->_getConfig()->getLayeredNavigationStatus($scopeId);
|
107 |
-
} catch (Exception $e) {
|
108 |
-
$resp = json_encode(array('status' => 'error: '.print_r($e->getMessage(), true)));
|
109 |
-
$response->setBody($resp);
|
110 |
-
|
111 |
-
Mage::logException($e);
|
112 |
-
|
113 |
-
return;
|
114 |
-
}
|
115 |
-
|
116 |
-
$resp = json_encode(array('current_state' => $current_state));
|
117 |
-
$response->setBody($resp);
|
118 |
-
}
|
119 |
-
|
120 |
-
protected function valid($uuid, $authkey)
|
121 |
-
{
|
122 |
-
if ($this->_getConfig()->getAuthorizationKey() == $authkey
|
123 |
-
&& $this->_getConfig()->getUUID() == $uuid) {
|
124 |
-
return true;
|
125 |
-
}
|
126 |
-
|
127 |
-
return false;
|
128 |
-
}
|
129 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controller_Front_Action
|
4 |
+
{
|
5 |
+
public function preDispatch()
|
6 |
+
{
|
7 |
+
parent::preDispatch();
|
8 |
+
|
9 |
+
$this->getResponse()->clearHeaders();
|
10 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function _getConfig()
|
14 |
+
{
|
15 |
+
return Mage::getModel('autocompleteplus_autosuggest/config');
|
16 |
+
}
|
17 |
+
|
18 |
+
public function setLayeredSearchOnAction()
|
19 |
+
{
|
20 |
+
$response = $this->getResponse();
|
21 |
+
$request = $this->getRequest();
|
22 |
+
$authkey = $request->getParam('authentication_key');
|
23 |
+
$uuid = $request->getParam('uuid');
|
24 |
+
$scope = $request->getParam('scope', 'stores');
|
25 |
+
$scopeId = $request->getParam('store_id', 1);
|
26 |
+
|
27 |
+
if (!$this->valid($uuid, $authkey)) {
|
28 |
+
$resp = json_encode(array('status' => 'error: '.'Authentication failed'));
|
29 |
+
$response->setBody($resp);
|
30 |
+
|
31 |
+
return;
|
32 |
+
}
|
33 |
+
|
34 |
+
try {
|
35 |
+
$this->_getConfig()->enableLayeredNavigation($scope, $scopeId);
|
36 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
37 |
+
} catch (Exception $e) {
|
38 |
+
$resp = json_encode(array('status' => 'error: '.print_r($e->getMessage(), true)));
|
39 |
+
$response->setBody($resp);
|
40 |
+
|
41 |
+
Mage::logException($e);
|
42 |
+
|
43 |
+
return;
|
44 |
+
}
|
45 |
+
|
46 |
+
$resp = array('new_state' => 1,
|
47 |
+
'status' => 'ok',
|
48 |
+
);
|
49 |
+
|
50 |
+
$response->setBody(json_encode($resp));
|
51 |
+
}
|
52 |
+
|
53 |
+
public function setLayeredSearchOffAction()
|
54 |
+
{
|
55 |
+
$request = $this->getRequest();
|
56 |
+
$response = $this->getResponse();
|
57 |
+
$authkey = $request->getParam('authentication_key');
|
58 |
+
$uuid = $request->getParam('uuid');
|
59 |
+
$scope = $request->getParam('scope', 'stores');
|
60 |
+
$scopeId = $request->getParam('store_id', 1);
|
61 |
+
|
62 |
+
if (!$this->valid($uuid, $authkey)) {
|
63 |
+
$resp = json_encode(array('status' => 'error: '.'Authentication failed'));
|
64 |
+
|
65 |
+
$response->setBody($resp);
|
66 |
+
|
67 |
+
return;
|
68 |
+
}
|
69 |
+
|
70 |
+
try {
|
71 |
+
$this->_getConfig()->disableLayeredNavigation($scope, $scopeId);
|
72 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
73 |
+
} catch (Exception $e) {
|
74 |
+
$resp = json_encode(array('status' => 'error: '.print_r($e->getMessage(), true)));
|
75 |
+
$response->setBody($resp);
|
76 |
+
|
77 |
+
Mage::logException($e);
|
78 |
+
|
79 |
+
return;
|
80 |
+
}
|
81 |
+
|
82 |
+
$resp = array('new_state' => 0,
|
83 |
+
'status' => 'ok',
|
84 |
+
);
|
85 |
+
|
86 |
+
$response->setBody(json_encode($resp));
|
87 |
+
}
|
88 |
+
|
89 |
+
public function getLayeredSearchConfigAction()
|
90 |
+
{
|
91 |
+
$request = $this->getRequest();
|
92 |
+
$response = $this->getResponse();
|
93 |
+
|
94 |
+
$authkey = $request->getParam('authentication_key');
|
95 |
+
$uuid = $request->getParam('uuid');
|
96 |
+
$scopeId = $request->getParam('store_id', 1);
|
97 |
+
|
98 |
+
if (!$this->valid($uuid, $authkey)) {
|
99 |
+
$resp = json_encode(array('status' => $this->__('error: Authentication failed')));
|
100 |
+
$response->setBody($resp);
|
101 |
+
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
try {
|
105 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
106 |
+
$current_state = $this->_getConfig()->getLayeredNavigationStatus($scopeId);
|
107 |
+
} catch (Exception $e) {
|
108 |
+
$resp = json_encode(array('status' => 'error: '.print_r($e->getMessage(), true)));
|
109 |
+
$response->setBody($resp);
|
110 |
+
|
111 |
+
Mage::logException($e);
|
112 |
+
|
113 |
+
return;
|
114 |
+
}
|
115 |
+
|
116 |
+
$resp = json_encode(array('current_state' => $current_state));
|
117 |
+
$response->setBody($resp);
|
118 |
+
}
|
119 |
+
|
120 |
+
protected function valid($uuid, $authkey)
|
121 |
+
{
|
122 |
+
if ($this->_getConfig()->getAuthorizationKey() == $authkey
|
123 |
+
&& $this->_getConfig()->getUUID() == $uuid) {
|
124 |
+
return true;
|
125 |
+
}
|
126 |
+
|
127 |
+
return false;
|
128 |
+
}
|
129 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/controllers/ProductsController.php
CHANGED
@@ -1,559 +1,560 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* InstantSearchPlus (Autosuggest).
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is available through the world-wide-web at this URL:
|
9 |
-
* http://opensource.org/licenses/osl-3.0.php
|
10 |
-
*
|
11 |
-
* @category Mage
|
12 |
-
*
|
13 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_Autosuggest_Controller_Abstract
|
17 |
-
{
|
18 |
-
protected $_storeId;
|
19 |
-
const MAX_NUM_OF_PRODUCTS_CHECKSUM_ITERATION = 250;
|
20 |
-
const MISSING_PARAMETER = 'false';
|
21 |
-
const PUSH_IN_PROGRESS = 1;
|
22 |
-
const PUSH_COMPLETE = 2;
|
23 |
-
const POST_MESSAGE_OK = 'ok';
|
24 |
-
const URL_EMAIL_UPDATE = 'http://magento.autocompleteplus.com/ext_update_email';
|
25 |
-
const URL_UUID_UPDATE = 'http://magento.instantsearchplus.com/update_uuid';
|
26 |
-
const XML_CONFIG_STORE_EMAIL = 'autocompleteplus/config/store_email';
|
27 |
-
|
28 |
-
protected function _getConfig()
|
29 |
-
{
|
30 |
-
return Mage::getModel('autocompleteplus_autosuggest/config');
|
31 |
-
}
|
32 |
-
|
33 |
-
public function sendAction()
|
34 |
-
{
|
35 |
-
Varien_Profiler::start('Autocompleteplus_Autosuggest_Products_Send');
|
36 |
-
$response = $this->getResponse();
|
37 |
-
$request = $this->getRequest();
|
38 |
-
$startInd = $request->getParam('offset', 0);
|
39 |
-
$count = $request->getParam('count', 100);
|
40 |
-
$store = $request->getParam('store_id', '');
|
41 |
-
$storeId = $request->getParam('store', $store);
|
42 |
-
$orders = $request->getParam('orders', '');
|
43 |
-
$monthInterval = $request->getParam('month_interval',
|
44 |
-
$checksum = $request->getParam('checksum', '');
|
45 |
-
$catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
|
46 |
-
|
47 |
-
Mage::app()->setCurrentStore($storeId);
|
48 |
-
|
49 |
-
$xml = $catalogModel->renderCatalogXml($startInd, $count, $storeId, $orders, $monthInterval, $checksum);
|
50 |
-
|
51 |
-
$response->setHeader('Content-type', 'text/xml');
|
52 |
-
$response->setBody($xml);
|
53 |
-
Varien_Profiler::stop('Autocompleteplus_Autosuggest_Products_Send');
|
54 |
-
}
|
55 |
-
|
56 |
-
public function sendupdatedAction()
|
57 |
-
{
|
58 |
-
$request = $this->getRequest();
|
59 |
-
$response = $this->getResponse();
|
60 |
-
|
61 |
-
$currentTime = Mage::getSingleton('core/date')->gmtTimestamp();
|
62 |
-
|
63 |
-
$count = $request->getParam('count');
|
64 |
-
$from = $request->getParam('from');
|
65 |
-
$to = $request->getParam('to', $currentTime);
|
66 |
-
$storeId = $request->getParam('store_id', false);
|
67 |
-
|
68 |
-
if (!$storeId) {
|
69 |
-
$returnArr = array(
|
70 |
-
'status' => self::STATUS_FAILURE,
|
71 |
-
'error_code' => self::MISSING_PARAMETER,
|
72 |
-
'error_details' => $this->__('The "store id" parameter is mandatory'),
|
73 |
-
);
|
74 |
-
$response->setHeader('Content-type', 'application/json');
|
75 |
-
$response->setHttpResponseCode(400);
|
76 |
-
$response->setBody(json_encode($returnArr));
|
77 |
-
|
78 |
-
return;
|
79 |
-
}
|
80 |
-
|
81 |
-
Mage::app()->setCurrentStore($storeId);
|
82 |
-
|
83 |
-
$catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
|
84 |
-
|
85 |
-
$xml = $catalogModel->renderUpdatesCatalogXml($count, $from, $to, $storeId);
|
86 |
-
|
87 |
-
$response->clearHeaders();
|
88 |
-
$response->setHeader('Content-type', 'text/xml');
|
89 |
-
$response->setBody($xml);
|
90 |
-
}
|
91 |
-
|
92 |
-
public function checkinstallAction()
|
93 |
-
{
|
94 |
-
$response = $this->getResponse();
|
95 |
-
$installStatus = $this->_getInstallStatus();
|
96 |
-
|
97 |
-
$response->setBody($installStatus);
|
98 |
-
}
|
99 |
-
|
100 |
-
protected function _getInstallStatus()
|
101 |
-
{
|
102 |
-
if (strlen($this->_getConfig()->getUUID()) > 0 && $this->_getConfig()->getUUID() != 'failed') {
|
103 |
-
return $this->__('the key exists');
|
104 |
-
}
|
105 |
-
|
106 |
-
return $this->__('no key inside');
|
107 |
-
}
|
108 |
-
|
109 |
-
public function versAction()
|
110 |
-
{
|
111 |
-
$response = $this->getResponse();
|
112 |
-
$get_modules = $this->getRequest()->getParam('modules', false);
|
113 |
-
$mage = Mage::getVersion();
|
114 |
-
$ext = Mage::helper('autocompleteplus_autosuggest')->getVersion();
|
115 |
-
$edition = method_exists('Mage', 'getEdition') ? Mage::getEdition() : 'Community';
|
116 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
117 |
-
$uuid = $this->_getConfig()->getUUID();
|
118 |
-
$site_url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
|
119 |
-
$store_id = Mage::app()->getStore()->getStoreId();
|
120 |
-
$installedModules = array();
|
121 |
-
|
122 |
-
$enabled=Mage::getStoreConfigFlag('autocompleteplus/config/enabled',0);
|
123 |
-
|
124 |
-
try {
|
125 |
-
$num_of_products = Mage::getModel('catalog/product')->getCollection()
|
126 |
-
->addStoreFilter($store_id)
|
127 |
-
->getSize();
|
128 |
-
} catch (Exception $e) {
|
129 |
-
$num_of_products = -1;
|
130 |
-
}
|
131 |
-
|
132 |
-
if ($get_modules) {
|
133 |
-
try {
|
134 |
-
$modules = Mage::getConfig()->getNode('modules')->children();
|
135 |
-
foreach ($modules as $name => $module) {
|
136 |
-
if ($module->codePool != 'core' && $module->active == 'true') {
|
137 |
-
$installedModules[$name] = $module;
|
138 |
-
}
|
139 |
-
}
|
140 |
-
} catch (Exception $e) {
|
141 |
-
$installedModules = array();
|
142 |
-
}
|
143 |
-
}
|
144 |
-
|
145 |
-
$result = array(
|
146 |
-
'mage' => $mage,
|
147 |
-
'ext' => $ext,
|
148 |
-
'num_of_products' => $num_of_products,
|
149 |
-
'edition' => $edition,
|
150 |
-
'uuid' => $uuid,
|
151 |
-
'site_url' => $site_url,
|
152 |
-
'store_id' => $store_id,
|
153 |
-
'modules' => $installedModules,
|
154 |
-
'enabled' => $enabled
|
155 |
-
);
|
156 |
-
|
157 |
-
$response->clearHeaders();
|
158 |
-
$response->setHeader('Content-type', 'application/json');
|
159 |
-
$response->setBody(json_encode($result));
|
160 |
-
}
|
161 |
-
|
162 |
-
public function getNumOfProductsAction()
|
163 |
-
{
|
164 |
-
$catalogReport = Mage::getModel('autocompleteplus_autosuggest/catalogreport');
|
165 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
166 |
-
|
167 |
-
$result = array('num_of_products' => $catalogReport->getEnabledProductsCount(),
|
168 |
-
'num_of_disabled_products' => $catalogReport->getDisabledProductsCount(),
|
169 |
-
'num_of_searchable_products' => $catalogReport->getSearchableProductsCount(),
|
170 |
-
'num_of_searchable_products2' => $catalogReport->getSearchableProducts2Count(),
|
171 |
-
'uuid' => $this->_getConfig()->getUUID(),
|
172 |
-
'site_url' => $helper->getConfigDataByFullPath('web/unsecure/base_url'),
|
173 |
-
'store_id' => $catalogReport->getCurrentStoreId(),
|
174 |
-
);
|
175 |
-
|
176 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
177 |
-
$this->getResponse()->setBody(json_encode($result));
|
178 |
-
}
|
179 |
-
|
180 |
-
public function getConflictAction()
|
181 |
-
{
|
182 |
-
$response = $this->getResponse();
|
183 |
-
$request = $this->getRequest();
|
184 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
185 |
-
|
186 |
-
//check for extension conflicts
|
187 |
-
$conflicts = (bool) $request->getParam('all');
|
188 |
-
$result = $helper->getExtensionConflict($conflicts);
|
189 |
-
|
190 |
-
$response->clearHeaders();
|
191 |
-
$response->setHeader('Content-type', 'application/json');
|
192 |
-
$response->setBody(json_encode($result));
|
193 |
-
}
|
194 |
-
|
195 |
-
public function getstoresAction()
|
196 |
-
{
|
197 |
-
$response = $this->getResponse();
|
198 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
199 |
-
|
200 |
-
$response->
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
$
|
216 |
-
$
|
217 |
-
$
|
218 |
-
$
|
219 |
-
$io
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
$
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
$data
|
241 |
-
$data['
|
242 |
-
$
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
$data
|
256 |
-
$data['
|
257 |
-
$
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
$response
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
$
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
$
|
286 |
-
$
|
287 |
-
$
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
'
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
$
|
296 |
-
$
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
$
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
$
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
$
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
$
|
330 |
-
$collection
|
331 |
-
$
|
332 |
-
|
333 |
-
|
334 |
-
$
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
$
|
340 |
-
$
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
$
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
'
|
351 |
-
'
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
$response->
|
356 |
-
$response->
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
$
|
363 |
-
$
|
364 |
-
$
|
365 |
-
$
|
366 |
-
$
|
367 |
-
$
|
368 |
-
$
|
369 |
-
$
|
370 |
-
$
|
371 |
-
$
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
$
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
$log_msg
|
402 |
-
$
|
403 |
-
$
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
$
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
$
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
'
|
428 |
-
'
|
429 |
-
'
|
430 |
-
'
|
431 |
-
'
|
432 |
-
'
|
433 |
-
'
|
434 |
-
'
|
435 |
-
'
|
436 |
-
'
|
437 |
-
'
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
*
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
$
|
466 |
-
|
467 |
-
|
468 |
-
$response->
|
469 |
-
$
|
470 |
-
$
|
471 |
-
$
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
$
|
476 |
-
$response->
|
477 |
-
$response->
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
$
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
$
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
$
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
$pusher->
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
$
|
499 |
-
$
|
500 |
-
$
|
501 |
-
$
|
502 |
-
$
|
503 |
-
$
|
504 |
-
$
|
505 |
-
$
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
$data['
|
510 |
-
$data['
|
511 |
-
$data['
|
512 |
-
$data['
|
513 |
-
$data['
|
514 |
-
$data['
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
$
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
$
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
$pusher->
|
534 |
-
|
535 |
-
|
536 |
-
$
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
$
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
'
|
550 |
-
'
|
551 |
-
'
|
552 |
-
'
|
553 |
-
'
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
}
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* InstantSearchPlus (Autosuggest).
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Mage
|
12 |
+
*
|
13 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_Autosuggest_Controller_Abstract
|
17 |
+
{
|
18 |
+
protected $_storeId;
|
19 |
+
const MAX_NUM_OF_PRODUCTS_CHECKSUM_ITERATION = 250;
|
20 |
+
const MISSING_PARAMETER = 'false';
|
21 |
+
const PUSH_IN_PROGRESS = 1;
|
22 |
+
const PUSH_COMPLETE = 2;
|
23 |
+
const POST_MESSAGE_OK = 'ok';
|
24 |
+
const URL_EMAIL_UPDATE = 'http://magento.autocompleteplus.com/ext_update_email';
|
25 |
+
const URL_UUID_UPDATE = 'http://magento.instantsearchplus.com/update_uuid';
|
26 |
+
const XML_CONFIG_STORE_EMAIL = 'autocompleteplus/config/store_email';
|
27 |
+
|
28 |
+
protected function _getConfig()
|
29 |
+
{
|
30 |
+
return Mage::getModel('autocompleteplus_autosuggest/config');
|
31 |
+
}
|
32 |
+
|
33 |
+
public function sendAction()
|
34 |
+
{
|
35 |
+
Varien_Profiler::start('Autocompleteplus_Autosuggest_Products_Send');
|
36 |
+
$response = $this->getResponse();
|
37 |
+
$request = $this->getRequest();
|
38 |
+
$startInd = $request->getParam('offset', 0);
|
39 |
+
$count = $request->getParam('count', 100);
|
40 |
+
$store = $request->getParam('store_id', '');
|
41 |
+
$storeId = $request->getParam('store', $store);
|
42 |
+
$orders = $request->getParam('orders', '');
|
43 |
+
$monthInterval = $request->getParam('month_interval', 12);
|
44 |
+
$checksum = $request->getParam('checksum', '');
|
45 |
+
$catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
|
46 |
+
|
47 |
+
Mage::app()->setCurrentStore($storeId);
|
48 |
+
|
49 |
+
$xml = $catalogModel->renderCatalogXml($startInd, $count, $storeId, $orders, $monthInterval, $checksum);
|
50 |
+
|
51 |
+
$response->setHeader('Content-type', 'text/xml');
|
52 |
+
$response->setBody($xml);
|
53 |
+
Varien_Profiler::stop('Autocompleteplus_Autosuggest_Products_Send');
|
54 |
+
}
|
55 |
+
|
56 |
+
public function sendupdatedAction()
|
57 |
+
{
|
58 |
+
$request = $this->getRequest();
|
59 |
+
$response = $this->getResponse();
|
60 |
+
|
61 |
+
$currentTime = Mage::getSingleton('core/date')->gmtTimestamp();
|
62 |
+
|
63 |
+
$count = $request->getParam('count');
|
64 |
+
$from = $request->getParam('from');
|
65 |
+
$to = $request->getParam('to', $currentTime);
|
66 |
+
$storeId = $request->getParam('store_id', false);
|
67 |
+
|
68 |
+
if (!$storeId) {
|
69 |
+
$returnArr = array(
|
70 |
+
'status' => self::STATUS_FAILURE,
|
71 |
+
'error_code' => self::MISSING_PARAMETER,
|
72 |
+
'error_details' => $this->__('The "store id" parameter is mandatory'),
|
73 |
+
);
|
74 |
+
$response->setHeader('Content-type', 'application/json');
|
75 |
+
$response->setHttpResponseCode(400);
|
76 |
+
$response->setBody(json_encode($returnArr));
|
77 |
+
|
78 |
+
return;
|
79 |
+
}
|
80 |
+
|
81 |
+
Mage::app()->setCurrentStore($storeId);
|
82 |
+
|
83 |
+
$catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
|
84 |
+
|
85 |
+
$xml = $catalogModel->renderUpdatesCatalogXml($count, $from, $to, $storeId);
|
86 |
+
|
87 |
+
$response->clearHeaders();
|
88 |
+
$response->setHeader('Content-type', 'text/xml');
|
89 |
+
$response->setBody($xml);
|
90 |
+
}
|
91 |
+
|
92 |
+
public function checkinstallAction()
|
93 |
+
{
|
94 |
+
$response = $this->getResponse();
|
95 |
+
$installStatus = $this->_getInstallStatus();
|
96 |
+
|
97 |
+
$response->setBody($installStatus);
|
98 |
+
}
|
99 |
+
|
100 |
+
protected function _getInstallStatus()
|
101 |
+
{
|
102 |
+
if (strlen($this->_getConfig()->getUUID()) > 0 && $this->_getConfig()->getUUID() != 'failed') {
|
103 |
+
return $this->__('the key exists');
|
104 |
+
}
|
105 |
+
|
106 |
+
return $this->__('no key inside');
|
107 |
+
}
|
108 |
+
|
109 |
+
public function versAction()
|
110 |
+
{
|
111 |
+
$response = $this->getResponse();
|
112 |
+
$get_modules = $this->getRequest()->getParam('modules', false);
|
113 |
+
$mage = Mage::getVersion();
|
114 |
+
$ext = Mage::helper('autocompleteplus_autosuggest')->getVersion();
|
115 |
+
$edition = method_exists('Mage', 'getEdition') ? Mage::getEdition() : 'Community';
|
116 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
117 |
+
$uuid = $this->_getConfig()->getUUID();
|
118 |
+
$site_url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
|
119 |
+
$store_id = Mage::app()->getStore()->getStoreId();
|
120 |
+
$installedModules = array();
|
121 |
+
|
122 |
+
$enabled=Mage::getStoreConfigFlag('autocompleteplus/config/enabled',0);
|
123 |
+
|
124 |
+
try {
|
125 |
+
$num_of_products = Mage::getModel('catalog/product')->getCollection()
|
126 |
+
->addStoreFilter($store_id)
|
127 |
+
->getSize();
|
128 |
+
} catch (Exception $e) {
|
129 |
+
$num_of_products = -1;
|
130 |
+
}
|
131 |
+
|
132 |
+
if ($get_modules) {
|
133 |
+
try {
|
134 |
+
$modules = Mage::getConfig()->getNode('modules')->children();
|
135 |
+
foreach ($modules as $name => $module) {
|
136 |
+
if ($module->codePool != 'core' && $module->active == 'true') {
|
137 |
+
$installedModules[$name] = $module;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
} catch (Exception $e) {
|
141 |
+
$installedModules = array();
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
$result = array(
|
146 |
+
'mage' => $mage,
|
147 |
+
'ext' => $ext,
|
148 |
+
'num_of_products' => $num_of_products,
|
149 |
+
'edition' => $edition,
|
150 |
+
'uuid' => $uuid,
|
151 |
+
'site_url' => $site_url,
|
152 |
+
'store_id' => $store_id,
|
153 |
+
'modules' => $installedModules,
|
154 |
+
'enabled' => $enabled
|
155 |
+
);
|
156 |
+
|
157 |
+
$response->clearHeaders();
|
158 |
+
$response->setHeader('Content-type', 'application/json');
|
159 |
+
$response->setBody(json_encode($result));
|
160 |
+
}
|
161 |
+
|
162 |
+
public function getNumOfProductsAction()
|
163 |
+
{
|
164 |
+
$catalogReport = Mage::getModel('autocompleteplus_autosuggest/catalogreport');
|
165 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
166 |
+
|
167 |
+
$result = array('num_of_products' => $catalogReport->getEnabledProductsCount(),
|
168 |
+
'num_of_disabled_products' => $catalogReport->getDisabledProductsCount(),
|
169 |
+
'num_of_searchable_products' => $catalogReport->getSearchableProductsCount(),
|
170 |
+
'num_of_searchable_products2' => $catalogReport->getSearchableProducts2Count(),
|
171 |
+
'uuid' => $this->_getConfig()->getUUID(),
|
172 |
+
'site_url' => $helper->getConfigDataByFullPath('web/unsecure/base_url'),
|
173 |
+
'store_id' => $catalogReport->getCurrentStoreId(),
|
174 |
+
);
|
175 |
+
|
176 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
177 |
+
$this->getResponse()->setBody(json_encode($result));
|
178 |
+
}
|
179 |
+
|
180 |
+
public function getConflictAction()
|
181 |
+
{
|
182 |
+
$response = $this->getResponse();
|
183 |
+
$request = $this->getRequest();
|
184 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
185 |
+
|
186 |
+
//check for extension conflicts
|
187 |
+
$conflicts = (bool) $request->getParam('all');
|
188 |
+
$result = $helper->getExtensionConflict($conflicts);
|
189 |
+
|
190 |
+
$response->clearHeaders();
|
191 |
+
$response->setHeader('Content-type', 'application/json');
|
192 |
+
$response->setBody(json_encode($result));
|
193 |
+
}
|
194 |
+
|
195 |
+
public function getstoresAction()
|
196 |
+
{
|
197 |
+
$response = $this->getResponse();
|
198 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
199 |
+
$response->clearHeaders();
|
200 |
+
$response->setHeader('Content-type', 'application/json');
|
201 |
+
$response->setBody($helper->getMultiStoreDataJson());
|
202 |
+
}
|
203 |
+
|
204 |
+
protected function _getRobotsPath()
|
205 |
+
{
|
206 |
+
if (!$this->_robotsPath) {
|
207 |
+
$this->_robotsPath = Mage::getBaseDir().DS.'robots.txt';
|
208 |
+
}
|
209 |
+
|
210 |
+
return $this->_robotsPath;
|
211 |
+
}
|
212 |
+
|
213 |
+
public function updatesitemapAction()
|
214 |
+
{
|
215 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
216 |
+
$key = $this->_getConfig()->getUUID();
|
217 |
+
$url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
|
218 |
+
$robotsPath = $this->_getRobotsPath();
|
219 |
+
$io = new Varien_Io_File();
|
220 |
+
$io->open(array('path' => $io->dirName($robotsPath)));
|
221 |
+
|
222 |
+
if ($this->validateUuid($key)) {
|
223 |
+
$sitemapUrl = 'Sitemap:http://magento.instantsearchplus.com/ext_sitemap?u='.$key;
|
224 |
+
$write = false;
|
225 |
+
|
226 |
+
if ($io->fileExists($robotsPath)) {
|
227 |
+
if (strpos($io->read($robotsPath), $sitemapUrl) == false) {
|
228 |
+
$write = true;
|
229 |
+
}
|
230 |
+
} else {
|
231 |
+
if ($io->isWritable(Mage::getBaseDir())) {
|
232 |
+
|
233 |
+
//create robots sitemap
|
234 |
+
$io->write($robotsPath, $sitemapUrl);
|
235 |
+
} else {
|
236 |
+
|
237 |
+
//write message that directory is not writteble
|
238 |
+
$command = 'http://magento.autocompleteplus.com/install_error';
|
239 |
+
|
240 |
+
$data = array();
|
241 |
+
$data['site'] = $url;
|
242 |
+
$data['msg'] = $this->__('Directory %s is not writable.', Mage::getBaseDir());
|
243 |
+
$res = $helper->sendPostCurl($command, $data);
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
if ($write) {
|
248 |
+
if ($io->isWritable($robotsPath)) {
|
249 |
+
//append sitemap
|
250 |
+
$io->write($robotsPath, $sitemapUrl, FILE_APPEND | LOCK_EX);
|
251 |
+
} else {
|
252 |
+
//write message that file is not writteble
|
253 |
+
$command = 'http://magento.autocompleteplus.com/install_error';
|
254 |
+
|
255 |
+
$data = array();
|
256 |
+
$data['site'] = $url;
|
257 |
+
$data['msg'] = 'File '.$robotsPath.' is not writable.';
|
258 |
+
$res = $helper->sendPostCurl($command, $data);
|
259 |
+
}
|
260 |
+
}
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
protected function _setUUID($uuid)
|
265 |
+
{
|
266 |
+
$this->_getConfig()->setUUID($uuid);
|
267 |
+
}
|
268 |
+
|
269 |
+
public function getIspUuidAction()
|
270 |
+
{
|
271 |
+
$response = $this->getResponse();
|
272 |
+
$response->setBody($this->_getConfig()->getUUID());
|
273 |
+
}
|
274 |
+
|
275 |
+
public function geterrormessageAction()
|
276 |
+
{
|
277 |
+
$response = $this->getResponse();
|
278 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
279 |
+
|
280 |
+
$response->setBody($helper->getErrormessage());
|
281 |
+
}
|
282 |
+
|
283 |
+
public function setIspUuidAction()
|
284 |
+
{
|
285 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
286 |
+
$url_domain = self::URL_UUID_UPDATE;
|
287 |
+
$storeId = Mage::app()->getStore()->getStoreId();
|
288 |
+
$site_url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
|
289 |
+
|
290 |
+
$url = $url_domain.http_build_query(array(
|
291 |
+
'store_id' => $storeId,
|
292 |
+
'site_url' => $site_url,
|
293 |
+
));
|
294 |
+
|
295 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
296 |
+
$resp = $helper->sendCurl($url);
|
297 |
+
$response_json = json_decode($resp);
|
298 |
+
|
299 |
+
if ($helper->validateUuid($response_json->uuid)) {
|
300 |
+
$this->_setUUID($response_json->uuid);
|
301 |
+
}
|
302 |
+
}
|
303 |
+
|
304 |
+
public function checkDeletedAction()
|
305 |
+
{
|
306 |
+
$response = $this->getResponse();
|
307 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
308 |
+
if (!$helper->isChecksumTableExists()) {
|
309 |
+
return;
|
310 |
+
}
|
311 |
+
$time_stamp = time();
|
312 |
+
|
313 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
314 |
+
$table_prefix = (string) Mage::getConfig()->getTablePrefix();
|
315 |
+
|
316 |
+
$post = $this->getRequest()->getParams();
|
317 |
+
if (array_key_exists('store_id', $post)) {
|
318 |
+
$store_id = $post['store_id'];
|
319 |
+
} else {
|
320 |
+
$store_id = Mage::app()->getStore()->getStoreId(); // default
|
321 |
+
}
|
322 |
+
|
323 |
+
$sql_fetch = 'SELECT identifier FROM '.$table_prefix.'autocompleteplus_checksum WHERE store_id=?';
|
324 |
+
$updates = $read->fetchPairs($sql_fetch, array($store_id)); // empty array if fails
|
325 |
+
if (empty($updates)) {
|
326 |
+
return;
|
327 |
+
}
|
328 |
+
|
329 |
+
$checksum_ids = array_keys($updates); // array of all checksum table identifiers
|
330 |
+
$collection = Mage::getResourceModel('catalog/product_collection');
|
331 |
+
$collection->addFieldToFilter('entity_id', array('in' => $checksum_ids));
|
332 |
+
$found_ids = $collection->getAllIds();
|
333 |
+
|
334 |
+
$removed_products_list = array_diff($checksum_ids, $found_ids); // list of identifiers that are not present in the store (removed at some point)
|
335 |
+
$removed_ids = array();
|
336 |
+
|
337 |
+
// removing non-existing identifiers from checksum table
|
338 |
+
if (!empty($removed_products_list)) {
|
339 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
340 |
+
$sql_delete = 'DELETE FROM '.$table_prefix.'autocompleteplus_checksum WHERE identifier IN ('.implode(',', $removed_products_list).')';
|
341 |
+
$write->query($sql_delete);
|
342 |
+
|
343 |
+
foreach ($removed_products_list as $product_id) {
|
344 |
+
$helper->deleteProductFromTables($read, $write, $table_prefix, $product_id, $store_id);
|
345 |
+
$removed_ids[] = $product_id;
|
346 |
+
}
|
347 |
+
}
|
348 |
+
|
349 |
+
$args = array('removed_ids' => $removed_ids,
|
350 |
+
'uuid' => $this->_getConfig()->getUUID(),
|
351 |
+
'store_id' => $store_id,
|
352 |
+
'latency' => time() - $time_stamp, // seconds
|
353 |
+
);
|
354 |
+
|
355 |
+
$response->clearHeaders();
|
356 |
+
$response->setHeader('Content-type', 'application/json');
|
357 |
+
$response->setBody(json_encode($args)); // returning the summary
|
358 |
+
}
|
359 |
+
|
360 |
+
public function checksumAction()
|
361 |
+
{
|
362 |
+
$request = $this->getRequest();
|
363 |
+
$response = $this->getResponse();
|
364 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
365 |
+
$store_id = $request->getParam('store_id', Mage::app()->getStore()->getStoreId());
|
366 |
+
$count = $request->getParam('count', self::MAX_NUM_OF_PRODUCTS_CHECKSUM_ITERATION);
|
367 |
+
$start_index = $request->getParam('offset', 0);
|
368 |
+
$php_timeout = $request->getParam('timeout', -1);
|
369 |
+
$is_single = $request->getParam('is_single', 0);
|
370 |
+
$uuid = $this->_getConfig()->getUUID();
|
371 |
+
$checksum_server = $helper->getServerUrl();
|
372 |
+
$collection = Mage::getModel('catalog/product')->getCollection();
|
373 |
+
|
374 |
+
if (!$helper->isChecksumTableExists()) {
|
375 |
+
$helper->ispErrorLog('checksum table not exist');
|
376 |
+
$response->setBody(json_encode(array('status' => 'checksum table not exist')));
|
377 |
+
|
378 |
+
return;
|
379 |
+
}
|
380 |
+
|
381 |
+
$max_exe_time = -1;
|
382 |
+
|
383 |
+
if ($count > self::MAX_NUM_OF_PRODUCTS_CHECKSUM_ITERATION && $php_timeout != -1) {
|
384 |
+
$max_exe_time = ini_get('max_execution_time');
|
385 |
+
ini_set('max_execution_time', $php_timeout);
|
386 |
+
}
|
387 |
+
|
388 |
+
$site_url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
|
389 |
+
|
390 |
+
if ($store_id) {
|
391 |
+
$collection->addStoreFilter($store_id);
|
392 |
+
}
|
393 |
+
|
394 |
+
$num_of_products = $collection->getSize();
|
395 |
+
|
396 |
+
if ($count + $start_index > $num_of_products) {
|
397 |
+
$count = $num_of_products - $start_index;
|
398 |
+
}
|
399 |
+
|
400 |
+
// sending log to the server
|
401 |
+
$log_msg = 'Update checksum is starting...';
|
402 |
+
$log_msg .= (' number of products in this store: '.$num_of_products.' | from: '.$start_index.', to: '.($start_index + $count));
|
403 |
+
$server_url = $checksum_server.'/magento_logging_record';
|
404 |
+
$request = $server_url.'?uuid='.$uuid.'&site_url='.$site_url.'&msg='.urlencode($log_msg);
|
405 |
+
if ($store_id) {
|
406 |
+
$request .= '&store_id='.$store_id;
|
407 |
+
}
|
408 |
+
$resp = $helper->sendCurl($request);
|
409 |
+
|
410 |
+
$start_time = time();
|
411 |
+
$num_of_updated_checksum = 0;
|
412 |
+
if ($count > self::MAX_NUM_OF_PRODUCTS_CHECKSUM_ITERATION) {
|
413 |
+
$iter = $start_index;
|
414 |
+
while ($iter < $count) {
|
415 |
+
// start updating the checksum table if needed
|
416 |
+
$num_of_updated_checksum += $helper->compareProductsChecksum($iter, self::MAX_NUM_OF_PRODUCTS_CHECKSUM_ITERATION, $store_id);
|
417 |
+
$iter += self::MAX_NUM_OF_PRODUCTS_CHECKSUM_ITERATION;
|
418 |
+
}
|
419 |
+
} else {
|
420 |
+
// start updating the checksum table if needed
|
421 |
+
$num_of_updated_checksum = $helper->compareProductsChecksum($start_index, $count, $store_id);
|
422 |
+
}
|
423 |
+
|
424 |
+
$process_time = time() - $start_time;
|
425 |
+
// sending confirmation/summary to the server
|
426 |
+
$args = array(
|
427 |
+
'uuid' => $uuid,
|
428 |
+
'site_url' => $site_url,
|
429 |
+
'store_id' => $store_id,
|
430 |
+
'updated_checksum' => $num_of_updated_checksum,
|
431 |
+
'total_checksum' => $count,
|
432 |
+
'num_of_products' => $num_of_products,
|
433 |
+
'start_index' => $start_index,
|
434 |
+
'end_index' => $start_index + $count,
|
435 |
+
'count' => $count,
|
436 |
+
'ext_version' => (string) Mage::getConfig()->getNode()->modules->Autocompleteplus_Autosuggest->version,
|
437 |
+
'mage_version' => Mage::getVersion(),
|
438 |
+
'latency' => $process_time,
|
439 |
+
);
|
440 |
+
if ($is_single) {
|
441 |
+
$args['is_single'] = 1;
|
442 |
+
}
|
443 |
+
|
444 |
+
$response->setBody(json_encode($args));
|
445 |
+
|
446 |
+
$resp = $helper->sendCurl($checksum_server.'/magento_checksum_iterator?'.http_build_query($args));
|
447 |
+
|
448 |
+
if ($max_exe_time != -1) { // restore php max execution time
|
449 |
+
ini_set('max_execution_time', $max_exe_time);
|
450 |
+
}
|
451 |
+
}
|
452 |
+
|
453 |
+
public function connectionAction()
|
454 |
+
{
|
455 |
+
$this->getResponse()->setBody(1);
|
456 |
+
}
|
457 |
+
|
458 |
+
/**
|
459 |
+
* Bulk Push to ISP with JSON
|
460 |
+
* @return void
|
461 |
+
*/
|
462 |
+
public function pushbulkAction()
|
463 |
+
{
|
464 |
+
set_time_limit(1800);
|
465 |
+
$request = $this->getRequest();
|
466 |
+
$response = $this->getResponse();
|
467 |
+
|
468 |
+
$response->clearHeaders();
|
469 |
+
$response->setHeader('Content-type', 'application/json');
|
470 |
+
$pushId = $request->getParam('pushid', null);
|
471 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
472 |
+
$data = array();
|
473 |
+
|
474 |
+
if(!isset($pushId)){
|
475 |
+
$responseArr = array('success'=>false,'message'=>'Missing pushid!');
|
476 |
+
$response->clearHeaders();
|
477 |
+
$response->setHeader('Content-type', 'application/json');
|
478 |
+
$response->setBody(json_encode($responseArr));
|
479 |
+
return;
|
480 |
+
}
|
481 |
+
|
482 |
+
$pusher = Mage::getModel('autocompleteplus_autosuggest/pusher')->load($pushId);
|
483 |
+
$sent = $pusher->getSent();
|
484 |
+
|
485 |
+
if($sent==1){
|
486 |
+
$responseArr = array('success'=>false,'message'=>'push is in process');
|
487 |
+
$response->setBody(json_encode($responseArr));
|
488 |
+
return;
|
489 |
+
} elseif ($sent==2){
|
490 |
+
$responseArr = array('success'=>false,'message'=>'push was already sent');
|
491 |
+
$response->setBody(json_encode($responseArr));
|
492 |
+
return;
|
493 |
+
} else {
|
494 |
+
$pusher->setSent(1);
|
495 |
+
$pusher->save();
|
496 |
+
}
|
497 |
+
|
498 |
+
$offset = $pusher->getoffset();
|
499 |
+
$count = 100;
|
500 |
+
$storeId = $pusher->getstore_id();
|
501 |
+
$to_send = $pusher->getto_send();
|
502 |
+
$total_batches = $pusher->gettotal_batches();
|
503 |
+
$catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
|
504 |
+
$url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
|
505 |
+
$server_url = $helper->getServerUrl();
|
506 |
+
$cmd_url = $server_url . '/magento_fetch_products';
|
507 |
+
|
508 |
+
// setting post data and command url
|
509 |
+
$data['uuid'] = $helper->getUUID();
|
510 |
+
$data['site_url'] = $url;
|
511 |
+
$data['store_id'] = $storeId;
|
512 |
+
$data['authentication_key'] = $helper->getKey();
|
513 |
+
$data['total_batches'] = $total_batches;
|
514 |
+
$data['batch_number'] = $pusher->getbatch_number();
|
515 |
+
$data['products'] = $catalogModel->renderCatalogXml($offset,$count,$storeId,'','','');
|
516 |
+
|
517 |
+
if ($offset+$count > $to_send) {
|
518 |
+
$data['is_last'] = 1;
|
519 |
+
$count=$to_send-$offset;
|
520 |
+
}
|
521 |
+
|
522 |
+
// sending products
|
523 |
+
$res2 = $helper->sendPostCurl($cmd_url, $data);
|
524 |
+
unset($data['products']);
|
525 |
+
|
526 |
+
if($res2 !== 'ok') {
|
527 |
+
$responseArr = array('success'=>false,'message'=>$res2);
|
528 |
+
$response->setBody($responseArr);
|
529 |
+
return;
|
530 |
+
}
|
531 |
+
|
532 |
+
|
533 |
+
$pusher->setSent(2);
|
534 |
+
$pusher->save();
|
535 |
+
|
536 |
+
$nextPushId = $helper->getPushId();
|
537 |
+
$nextPushUrl = '';
|
538 |
+
|
539 |
+
if($nextPushId!=''){
|
540 |
+
$nextPushUrl=$helper->getPushUrl($nextPushId);
|
541 |
+
}
|
542 |
+
|
543 |
+
$totalPushes = Mage::getModel('autocompleteplus_autosuggest/pusher')->getCollection()->getSize();
|
544 |
+
|
545 |
+
$updatedStatus = 'Syncing: push ' . $nextPushId . '/' . $totalPushes;
|
546 |
+
$updatedSuccessStatus = 'Successfully synced '. $count .' products';
|
547 |
+
|
548 |
+
$responseArr = array(
|
549 |
+
'success' => true,
|
550 |
+
'updatedStatus' => $updatedStatus,
|
551 |
+
'updatedSuccessStatus' => $updatedSuccessStatus,
|
552 |
+
'message' => '',
|
553 |
+
'nextPushUrl' => $nextPushUrl,
|
554 |
+
'count' => $count
|
555 |
+
);
|
556 |
+
|
557 |
+
$response->setBody(json_encode($responseArr));
|
558 |
+
|
559 |
+
}
|
560 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/controllers/ProductsbyidController.php
CHANGED
@@ -1,66 +1,66 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* InstantSearchPlus (Autosuggest).
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is available through the world-wide-web at this URL:
|
9 |
-
* http://opensource.org/licenses/osl-3.0.php
|
10 |
-
*
|
11 |
-
* @category Mage
|
12 |
-
*
|
13 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
class Autocompleteplus_Autosuggest_ProductsbyidController extends Autocompleteplus_Autosuggest_Controller_Abstract
|
17 |
-
{
|
18 |
-
public function getbyidAction()
|
19 |
-
{
|
20 |
-
$request = $this->getRequest();
|
21 |
-
$response = $this->getResponse();
|
22 |
-
$storeId = $request->getParam('store', 1);
|
23 |
-
$id = $request->getParam('id');
|
24 |
-
|
25 |
-
Mage::app()->setCurrentStore($storeId);
|
26 |
-
|
27 |
-
if (!$id) {
|
28 |
-
$returnArr = array(
|
29 |
-
'status' => self::STATUS_FAILURE,
|
30 |
-
'error_code' => self::MISSING_PARAMETER,
|
31 |
-
'error_details' => $this->__('The "id" parameter is mandatory'),
|
32 |
-
);
|
33 |
-
$response->setHeader('Content-type', 'application/json');
|
34 |
-
$response->setHttpResponseCode(400);
|
35 |
-
$response->setBody(json_encode($returnArr));
|
36 |
-
|
37 |
-
return;
|
38 |
-
}
|
39 |
-
|
40 |
-
$ids = explode(',', $id);
|
41 |
-
$catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
|
42 |
-
$xml = $catalogModel->renderCatalogByIds($ids, $storeId);
|
43 |
-
|
44 |
-
$response->clearHeaders();
|
45 |
-
$response->setHeader('Content-type', 'text/xml');
|
46 |
-
$response->setBody($xml);
|
47 |
-
}
|
48 |
-
|
49 |
-
public function getfromidAction()
|
50 |
-
{
|
51 |
-
$request = $this->getRequest();
|
52 |
-
$response = $this->getResponse();
|
53 |
-
$fromId = $request->getParam('id', 0);
|
54 |
-
$storeId = $request->getParam('store', 1);
|
55 |
-
$count = $request->getParam('count', 100);
|
56 |
-
|
57 |
-
Mage::app()->setCurrentStore($storeId);
|
58 |
-
|
59 |
-
$catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
|
60 |
-
$xml = $catalogModel->renderCatalogFromIds($count, $fromId, $storeId);
|
61 |
-
|
62 |
-
$response->clearHeaders();
|
63 |
-
$response->setHeader('Content-type', 'text/xml');
|
64 |
-
$response->setBody($xml);
|
65 |
-
}
|
66 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* InstantSearchPlus (Autosuggest).
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Mage
|
12 |
+
*
|
13 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
class Autocompleteplus_Autosuggest_ProductsbyidController extends Autocompleteplus_Autosuggest_Controller_Abstract
|
17 |
+
{
|
18 |
+
public function getbyidAction()
|
19 |
+
{
|
20 |
+
$request = $this->getRequest();
|
21 |
+
$response = $this->getResponse();
|
22 |
+
$storeId = $request->getParam('store', 1);
|
23 |
+
$id = $request->getParam('id');
|
24 |
+
|
25 |
+
Mage::app()->setCurrentStore($storeId);
|
26 |
+
|
27 |
+
if (!$id) {
|
28 |
+
$returnArr = array(
|
29 |
+
'status' => self::STATUS_FAILURE,
|
30 |
+
'error_code' => self::MISSING_PARAMETER,
|
31 |
+
'error_details' => $this->__('The "id" parameter is mandatory'),
|
32 |
+
);
|
33 |
+
$response->setHeader('Content-type', 'application/json');
|
34 |
+
$response->setHttpResponseCode(400);
|
35 |
+
$response->setBody(json_encode($returnArr));
|
36 |
+
|
37 |
+
return;
|
38 |
+
}
|
39 |
+
|
40 |
+
$ids = explode(',', $id);
|
41 |
+
$catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
|
42 |
+
$xml = $catalogModel->renderCatalogByIds($ids, $storeId);
|
43 |
+
|
44 |
+
$response->clearHeaders();
|
45 |
+
$response->setHeader('Content-type', 'text/xml');
|
46 |
+
$response->setBody($xml);
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getfromidAction()
|
50 |
+
{
|
51 |
+
$request = $this->getRequest();
|
52 |
+
$response = $this->getResponse();
|
53 |
+
$fromId = $request->getParam('id', 0);
|
54 |
+
$storeId = $request->getParam('store', 1);
|
55 |
+
$count = $request->getParam('count', 100);
|
56 |
+
|
57 |
+
Mage::app()->setCurrentStore($storeId);
|
58 |
+
|
59 |
+
$catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
|
60 |
+
$xml = $catalogModel->renderCatalogFromIds($count, $fromId, $storeId);
|
61 |
+
|
62 |
+
$response->clearHeaders();
|
63 |
+
$response->setHeader('Content-type', 'text/xml');
|
64 |
+
$response->setBody($xml);
|
65 |
+
}
|
66 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/controllers/ResultController.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once Mage::getModuleDir('controllers', 'Mage_CatalogSearch').DS.'ResultController.php';
|
4 |
-
|
5 |
-
class Autocompleteplus_Autosuggest_ResultController extends Mage_CatalogSearch_ResultController
|
6 |
-
{
|
7 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once Mage::getModuleDir('controllers', 'Mage_CatalogSearch').DS.'ResultController.php';
|
4 |
+
|
5 |
+
class Autocompleteplus_Autosuggest_ResultController extends Mage_CatalogSearch_ResultController
|
6 |
+
{
|
7 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/controllers/SearchesController.php
CHANGED
@@ -1,109 +1,109 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* InstantSearchPlus (Autosuggest).
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is available through the world-wide-web at this URL:
|
9 |
-
* http://opensource.org/licenses/osl-3.0.php
|
10 |
-
*
|
11 |
-
* @category Mage
|
12 |
-
*
|
13 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
class Autocompleteplus_Autosuggest_SearchesController extends Mage_Core_Controller_Front_Action
|
17 |
-
{
|
18 |
-
public function sendAction()
|
19 |
-
{
|
20 |
-
set_time_limit(1800);
|
21 |
-
|
22 |
-
$post = $this->getRequest()->getParams();
|
23 |
-
|
24 |
-
$response = $this->getResponse();
|
25 |
-
|
26 |
-
$startInd = $post['offset'];
|
27 |
-
if (!$startInd) {
|
28 |
-
$startInd = 0;
|
29 |
-
}
|
30 |
-
|
31 |
-
$count = $post['count'];
|
32 |
-
|
33 |
-
//maxim products on one page is 10000
|
34 |
-
if (!$count || $count > 10000) {
|
35 |
-
$count = 10000;
|
36 |
-
}
|
37 |
-
//retrieving page number
|
38 |
-
|
39 |
-
//retrieving products collection to check if the offset is not bigger that the product count
|
40 |
-
$collection = Mage::getModel('catalogsearch/query')->getCollection();
|
41 |
-
|
42 |
-
$searchesCount = $collection->count();
|
43 |
-
|
44 |
-
/* since the retreiving of product count will load the entire collection of products,
|
45 |
-
* we need to annul it in order to get the specified page only
|
46 |
-
*/
|
47 |
-
unset($collection);
|
48 |
-
|
49 |
-
$xml = '<?xml version="1.0"?>';
|
50 |
-
$xml .= '<searches>';
|
51 |
-
|
52 |
-
if ($searchesCount < $startInd) {
|
53 |
-
$xml .= '</searches>';
|
54 |
-
|
55 |
-
$response->clearHeaders();
|
56 |
-
$response->setHeader('Content-type', 'text/xml');
|
57 |
-
$response->setBody($xml);
|
58 |
-
|
59 |
-
return;
|
60 |
-
}
|
61 |
-
|
62 |
-
$connection = $this->_getConnection('core_write');
|
63 |
-
$sql = 'SELECT * FROM '.$this->_getTableName('catalogsearch_query').' ORDER BY `popularity` DESC LIMIT '.$startInd.', '.$count;
|
64 |
-
$searches = $connection->fetchAll($sql);
|
65 |
-
|
66 |
-
//setting page+products on the page
|
67 |
-
|
68 |
-
foreach ($searches as $search) {
|
69 |
-
$search_term = htmlspecialchars($search['query_text']);
|
70 |
-
$search_term = $this->_xmlEscape($search_term);
|
71 |
-
$popularity = $search['popularity'];
|
72 |
-
|
73 |
-
$row = '<search term="'.$search_term.'" count="'.$popularity.'" ></search>';
|
74 |
-
$xml .= $row;
|
75 |
-
}
|
76 |
-
|
77 |
-
$xml .= '</searches>';
|
78 |
-
|
79 |
-
$response->clearHeaders();
|
80 |
-
$response->setHeader('Content-type', 'text/xml');
|
81 |
-
$response->setBody($xml);
|
82 |
-
}
|
83 |
-
|
84 |
-
private function _xmlEscape($term)
|
85 |
-
{
|
86 |
-
$arr = array(
|
87 |
-
'&' => '&',
|
88 |
-
'"' => '"',
|
89 |
-
'<' => '<',
|
90 |
-
'>' => '>',
|
91 |
-
);
|
92 |
-
|
93 |
-
foreach ($arr as $key => $val) {
|
94 |
-
$term = str_replace($key, $val, $term);
|
95 |
-
}
|
96 |
-
|
97 |
-
return $term;
|
98 |
-
}
|
99 |
-
|
100 |
-
protected function _getConnection($type = 'core_read')
|
101 |
-
{
|
102 |
-
return Mage::getSingleton('core/resource')->getConnection($type);
|
103 |
-
}
|
104 |
-
|
105 |
-
protected function _getTableName($tableName)
|
106 |
-
{
|
107 |
-
return Mage::getSingleton('core/resource')->getTableName($tableName);
|
108 |
-
}
|
109 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* InstantSearchPlus (Autosuggest).
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Mage
|
12 |
+
*
|
13 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
class Autocompleteplus_Autosuggest_SearchesController extends Mage_Core_Controller_Front_Action
|
17 |
+
{
|
18 |
+
public function sendAction()
|
19 |
+
{
|
20 |
+
set_time_limit(1800);
|
21 |
+
|
22 |
+
$post = $this->getRequest()->getParams();
|
23 |
+
|
24 |
+
$response = $this->getResponse();
|
25 |
+
|
26 |
+
$startInd = $post['offset'];
|
27 |
+
if (!$startInd) {
|
28 |
+
$startInd = 0;
|
29 |
+
}
|
30 |
+
|
31 |
+
$count = $post['count'];
|
32 |
+
|
33 |
+
//maxim products on one page is 10000
|
34 |
+
if (!$count || $count > 10000) {
|
35 |
+
$count = 10000;
|
36 |
+
}
|
37 |
+
//retrieving page number
|
38 |
+
|
39 |
+
//retrieving products collection to check if the offset is not bigger that the product count
|
40 |
+
$collection = Mage::getModel('catalogsearch/query')->getCollection();
|
41 |
+
|
42 |
+
$searchesCount = $collection->count();
|
43 |
+
|
44 |
+
/* since the retreiving of product count will load the entire collection of products,
|
45 |
+
* we need to annul it in order to get the specified page only
|
46 |
+
*/
|
47 |
+
unset($collection);
|
48 |
+
|
49 |
+
$xml = '<?xml version="1.0"?>';
|
50 |
+
$xml .= '<searches>';
|
51 |
+
|
52 |
+
if ($searchesCount < $startInd) {
|
53 |
+
$xml .= '</searches>';
|
54 |
+
|
55 |
+
$response->clearHeaders();
|
56 |
+
$response->setHeader('Content-type', 'text/xml');
|
57 |
+
$response->setBody($xml);
|
58 |
+
|
59 |
+
return;
|
60 |
+
}
|
61 |
+
|
62 |
+
$connection = $this->_getConnection('core_write');
|
63 |
+
$sql = 'SELECT * FROM '.$this->_getTableName('catalogsearch_query').' ORDER BY `popularity` DESC LIMIT '.$startInd.', '.$count;
|
64 |
+
$searches = $connection->fetchAll($sql);
|
65 |
+
|
66 |
+
//setting page+products on the page
|
67 |
+
|
68 |
+
foreach ($searches as $search) {
|
69 |
+
$search_term = htmlspecialchars($search['query_text']);
|
70 |
+
$search_term = $this->_xmlEscape($search_term);
|
71 |
+
$popularity = $search['popularity'];
|
72 |
+
|
73 |
+
$row = '<search term="'.$search_term.'" count="'.$popularity.'" ></search>';
|
74 |
+
$xml .= $row;
|
75 |
+
}
|
76 |
+
|
77 |
+
$xml .= '</searches>';
|
78 |
+
|
79 |
+
$response->clearHeaders();
|
80 |
+
$response->setHeader('Content-type', 'text/xml');
|
81 |
+
$response->setBody($xml);
|
82 |
+
}
|
83 |
+
|
84 |
+
private function _xmlEscape($term)
|
85 |
+
{
|
86 |
+
$arr = array(
|
87 |
+
'&' => '&',
|
88 |
+
'"' => '"',
|
89 |
+
'<' => '<',
|
90 |
+
'>' => '>',
|
91 |
+
);
|
92 |
+
|
93 |
+
foreach ($arr as $key => $val) {
|
94 |
+
$term = str_replace($key, $val, $term);
|
95 |
+
}
|
96 |
+
|
97 |
+
return $term;
|
98 |
+
}
|
99 |
+
|
100 |
+
protected function _getConnection($type = 'core_read')
|
101 |
+
{
|
102 |
+
return Mage::getSingleton('core/resource')->getConnection($type);
|
103 |
+
}
|
104 |
+
|
105 |
+
protected function _getTableName($tableName)
|
106 |
+
{
|
107 |
+
return Mage::getSingleton('core/resource')->getTableName($tableName);
|
108 |
+
}
|
109 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/data/autosuggest_setup/data-install-3.0.0.5.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$batchCollection = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection();
|
4 |
-
|
5 |
-
foreach ($batchCollection as $batch) {
|
6 |
-
$currentTime = $batch->getUpdateDate();
|
7 |
-
$batch->setUpdateDate($currentTime)->save();
|
8 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$batchCollection = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection();
|
4 |
+
|
5 |
+
foreach ($batchCollection as $batch) {
|
6 |
+
$currentTime = $batch->getUpdateDate();
|
7 |
+
$batch->setUpdateDate($currentTime)->save();
|
8 |
}
|
app/code/local/Autocompleteplus/Autosuggest/data/autosuggest_setup/data-upgrade-3.0.0.9-3.0.0.10.php
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()->clear();
|
1 |
+
<?php
|
2 |
+
|
3 |
Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()->clear();
|
app/code/local/Autocompleteplus/Autosuggest/etc/adminhtml.xml
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<acl>
|
4 |
-
<resources>
|
5 |
-
<admin>
|
6 |
-
<children>
|
7 |
-
<system>
|
8 |
-
<children>
|
9 |
-
<config>
|
10 |
-
<children>
|
11 |
-
<autocompleteplus translate="label" module="autocompleteplus_autosuggest">
|
12 |
-
<title>AutocompletePlus</title>
|
13 |
-
</autocompleteplus>
|
14 |
-
</children>
|
15 |
-
</config>
|
16 |
-
</children>
|
17 |
-
</system>
|
18 |
-
</children>
|
19 |
-
</admin>
|
20 |
-
</resources>
|
21 |
-
</acl>
|
22 |
-
<menu>
|
23 |
-
<autocompleteplus>
|
24 |
-
<title>InstantSearch+</title>
|
25 |
-
<sort_order>999</sort_order>
|
26 |
-
<action>adminhtml/autocompleteplus_redirect/goto</action>
|
27 |
-
</autocompleteplus>
|
28 |
-
</menu>
|
29 |
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<admin>
|
6 |
+
<children>
|
7 |
+
<system>
|
8 |
+
<children>
|
9 |
+
<config>
|
10 |
+
<children>
|
11 |
+
<autocompleteplus translate="label" module="autocompleteplus_autosuggest">
|
12 |
+
<title>AutocompletePlus</title>
|
13 |
+
</autocompleteplus>
|
14 |
+
</children>
|
15 |
+
</config>
|
16 |
+
</children>
|
17 |
+
</system>
|
18 |
+
</children>
|
19 |
+
</admin>
|
20 |
+
</resources>
|
21 |
+
</acl>
|
22 |
+
<menu>
|
23 |
+
<autocompleteplus>
|
24 |
+
<title>InstantSearch+</title>
|
25 |
+
<sort_order>999</sort_order>
|
26 |
+
<action>adminhtml/autocompleteplus_redirect/goto</action>
|
27 |
+
</autocompleteplus>
|
28 |
+
</menu>
|
29 |
</config>
|
app/code/local/Autocompleteplus/Autosuggest/etc/cache.xml
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<config>
|
3 |
-
<placeholders>
|
4 |
-
<autocompleteplus_autosuggest>
|
5 |
-
<block>autocompleteplus_autosuggest/inject</block>
|
6 |
-
<placeholder>AUTOCOMPLETEPLUS_INJECTION</placeholder>
|
7 |
-
<container>Enterprise_PageCache_Model_Container_Sidebar_Cart</container>
|
8 |
-
<cache_lifetime>86400</cache_lifetime>
|
9 |
-
</autocompleteplus_autosuggest>
|
10 |
-
</placeholders>
|
11 |
</config>
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<placeholders>
|
4 |
+
<autocompleteplus_autosuggest>
|
5 |
+
<block>autocompleteplus_autosuggest/inject</block>
|
6 |
+
<placeholder>AUTOCOMPLETEPLUS_INJECTION</placeholder>
|
7 |
+
<container>Enterprise_PageCache_Model_Container_Sidebar_Cart</container>
|
8 |
+
<cache_lifetime>86400</cache_lifetime>
|
9 |
+
</autocompleteplus_autosuggest>
|
10 |
+
</placeholders>
|
11 |
</config>
|
app/code/local/Autocompleteplus/Autosuggest/etc/config.xml
CHANGED
@@ -1,213 +1,213 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<modules>
|
4 |
-
<Autocompleteplus_Autosuggest>
|
5 |
-
<version>3.0.0.
|
6 |
-
<url>http://autocompleteplus.com/</url>
|
7 |
-
<modulename>Autocompleteplus_Autosuggest</modulename>
|
8 |
-
</Autocompleteplus_Autosuggest>
|
9 |
-
</modules>
|
10 |
-
<global>
|
11 |
-
<models>
|
12 |
-
<autocompleteplus_autosuggest>
|
13 |
-
<class>Autocompleteplus_Autosuggest_Model</class>
|
14 |
-
<resourceModel>autocompleteplus_autosuggest_resource</resourceModel>
|
15 |
-
</autocompleteplus_autosuggest>
|
16 |
-
<autocompleteplus_autosuggest_resource>
|
17 |
-
<class>Autocompleteplus_Autosuggest_Model_Resource</class>
|
18 |
-
<deprecatedNode>autocompleteplus_mysql4</deprecatedNode>
|
19 |
-
<entities>
|
20 |
-
<notifications>
|
21 |
-
<table>autocompleteplus_notifications</table>
|
22 |
-
</notifications>
|
23 |
-
<pusher>
|
24 |
-
<table>autocompleteplus_pusher</table>
|
25 |
-
</pusher>
|
26 |
-
<config>
|
27 |
-
<table>autocompleteplus_config</table>
|
28 |
-
</config>
|
29 |
-
<batches>
|
30 |
-
<table>autocompleteplus_batches</table>
|
31 |
-
</batches>
|
32 |
-
</entities>
|
33 |
-
</autocompleteplus_autosuggest_resource>
|
34 |
-
<catalogsearch_resource>
|
35 |
-
<rewrite>
|
36 |
-
<fulltext_collection>Autocompleteplus_Autosuggest_Model_Resource_Fulltext_Collection</fulltext_collection>
|
37 |
-
</rewrite>
|
38 |
-
</catalogsearch_resource>
|
39 |
-
</models>
|
40 |
-
<events>
|
41 |
-
<controller_action_postdispatch_checkout_cart_index>
|
42 |
-
<observers>
|
43 |
-
<autocompleteplus_autosuggest>
|
44 |
-
<class>autocompleteplus_autosuggest/observer</class>
|
45 |
-
<method>webhook_service_call</method>
|
46 |
-
</autocompleteplus_autosuggest>
|
47 |
-
</observers>
|
48 |
-
</controller_action_postdispatch_checkout_cart_index>
|
49 |
-
<controller_action_postdispatch_checkout_onepage_index>
|
50 |
-
<observers>
|
51 |
-
<autocompleteplus_autosuggest>
|
52 |
-
<class>autocompleteplus_autosuggest/observer</class>
|
53 |
-
<method>webhook_service_call</method>
|
54 |
-
</autocompleteplus_autosuggest>
|
55 |
-
</observers>
|
56 |
-
</controller_action_postdispatch_checkout_onepage_index>
|
57 |
-
<controller_action_postdispatch_checkout_onepage_success>
|
58 |
-
<observers>
|
59 |
-
<autocompleteplus_autosuggest>
|
60 |
-
<class>autocompleteplus_autosuggest/observer</class>
|
61 |
-
<method>webhook_service_call</method>
|
62 |
-
</autocompleteplus_autosuggest>
|
63 |
-
</observers>
|
64 |
-
</controller_action_postdispatch_checkout_onepage_success>
|
65 |
-
<catalog_product_save_before>
|
66 |
-
<observers>
|
67 |
-
<autocompleteplus_autosuggest>
|
68 |
-
<type>singleton</type>
|
69 |
-
<class>autocompleteplus_autosuggest/observer</class>
|
70 |
-
<method>catalog_product_save_after</method>
|
71 |
-
</autocompleteplus_autosuggest>
|
72 |
-
</observers>
|
73 |
-
</catalog_product_save_before>
|
74 |
-
<catalog_product_save_after>
|
75 |
-
<observers>
|
76 |
-
<autocompleteplus_autosuggest>
|
77 |
-
<type>singleton</type>
|
78 |
-
<class>autocompleteplus_autosuggest/observer</class>
|
79 |
-
<method>catalog_product_save_after_real</method>
|
80 |
-
</autocompleteplus_autosuggest>
|
81 |
-
</observers>
|
82 |
-
</catalog_product_save_after>
|
83 |
-
<catalog_product_delete_before>
|
84 |
-
<observers>
|
85 |
-
<autocompleteplus_autosuggest>
|
86 |
-
<type>singleton</type>
|
87 |
-
<class>autocompleteplus_autosuggest/observer</class>
|
88 |
-
<method>catalog_product_delete_before</method>
|
89 |
-
</autocompleteplus_autosuggest>
|
90 |
-
</observers>
|
91 |
-
</catalog_product_delete_before>
|
92 |
-
<adminhtml_controller_catalogrule_prepare_save>
|
93 |
-
<observers>
|
94 |
-
<autocompleteplus_autosuggest>
|
95 |
-
<type>singleton</type>
|
96 |
-
<class>autocompleteplus_autosuggest/observer</class>
|
97 |
-
<method>adminhtml_controller_catalogrule_prepare_save</method>
|
98 |
-
</autocompleteplus_autosuggest>
|
99 |
-
</observers>
|
100 |
-
</adminhtml_controller_catalogrule_prepare_save>
|
101 |
-
</events>
|
102 |
-
<resources>
|
103 |
-
<autosuggest_setup>
|
104 |
-
<setup>
|
105 |
-
<module>Autocompleteplus_Autosuggest</module>
|
106 |
-
</setup>
|
107 |
-
<connection>
|
108 |
-
<use>core_setup</use>
|
109 |
-
</connection>
|
110 |
-
</autosuggest_setup>
|
111 |
-
<autosuggest_write>
|
112 |
-
<connection>
|
113 |
-
<use>core_write</use>
|
114 |
-
</connection>
|
115 |
-
</autosuggest_write>
|
116 |
-
<autosuggest_read>
|
117 |
-
<connection>
|
118 |
-
<use>core_read</use>
|
119 |
-
</connection>
|
120 |
-
</autosuggest_read>
|
121 |
-
</resources>
|
122 |
-
<blocks>
|
123 |
-
<autocompleteplus_autosuggest>
|
124 |
-
<class>Autocompleteplus_Autosuggest_Block</class>
|
125 |
-
</autocompleteplus_autosuggest>
|
126 |
-
</blocks>
|
127 |
-
<template>
|
128 |
-
<email>
|
129 |
-
<autosuggest_status_notification module="autocompleteplus_autosuggest">
|
130 |
-
<label>Autocompleteplus status notification</label>
|
131 |
-
<file>autocompleteplus/status_notification.html</file>
|
132 |
-
<type>html</type>
|
133 |
-
</autosuggest_status_notification>
|
134 |
-
</email>
|
135 |
-
</template>
|
136 |
-
<helpers>
|
137 |
-
<autocompleteplus_autosuggest>
|
138 |
-
<class>Autocompleteplus_Autosuggest_Helper</class>
|
139 |
-
</autocompleteplus_autosuggest>
|
140 |
-
</helpers>
|
141 |
-
<sales>
|
142 |
-
<quote>
|
143 |
-
<item>
|
144 |
-
<product_attributes>
|
145 |
-
<added_from_search />
|
146 |
-
</product_attributes>
|
147 |
-
</item>
|
148 |
-
</quote>
|
149 |
-
</sales>
|
150 |
-
</global>
|
151 |
-
<frontend>
|
152 |
-
<layout>
|
153 |
-
<updates>
|
154 |
-
<autosuggest>
|
155 |
-
<file>autocompleteplus.xml</file>
|
156 |
-
</autosuggest>
|
157 |
-
</updates>
|
158 |
-
</layout>
|
159 |
-
<routers>
|
160 |
-
<instantsearchplus>
|
161 |
-
<use>standard</use>
|
162 |
-
<args>
|
163 |
-
<module>Autocompleteplus_Autosuggest</module>
|
164 |
-
<frontName>instantsearchplus</frontName>
|
165 |
-
</args>
|
166 |
-
</instantsearchplus>
|
167 |
-
<autocompleteplus>
|
168 |
-
<use>standard</use>
|
169 |
-
<args>
|
170 |
-
<module>Autocompleteplus_Autosuggest</module>
|
171 |
-
<frontName>autocompleteplus</frontName>
|
172 |
-
</args>
|
173 |
-
</autocompleteplus>
|
174 |
-
<catalogsearch>
|
175 |
-
<args>
|
176 |
-
<modules>
|
177 |
-
<Autocompleteplus_Autosuggest before="Mage_CatalogSearch">Autocompleteplus_Autosuggest_CatalogSearch</Autocompleteplus_Autosuggest>
|
178 |
-
</modules>
|
179 |
-
</args>
|
180 |
-
</catalogsearch>
|
181 |
-
</routers>
|
182 |
-
</frontend>
|
183 |
-
<admin>
|
184 |
-
<routers>
|
185 |
-
<adminhtml>
|
186 |
-
<args>
|
187 |
-
<modules>
|
188 |
-
<autocompleteplus after="Mage_Adminhtml">Autocompleteplus_Autosuggest_Adminhtml</autocompleteplus>
|
189 |
-
</modules>
|
190 |
-
</args>
|
191 |
-
</adminhtml>
|
192 |
-
</routers>
|
193 |
-
</admin>
|
194 |
-
<adminhtml>
|
195 |
-
<layout>
|
196 |
-
<updates>
|
197 |
-
<autosuggest>
|
198 |
-
<file>autocompleteplus.xml</file>
|
199 |
-
</autosuggest>
|
200 |
-
</updates>
|
201 |
-
</layout>
|
202 |
-
</adminhtml>
|
203 |
-
<default>
|
204 |
-
<autocompleteplus>
|
205 |
-
<config>
|
206 |
-
<imagefield>thumbnail</imagefield>
|
207 |
-
<attributes>1</attributes>
|
208 |
-
<layered>0</layered>
|
209 |
-
<api_endpoint><![CDATA[https://magento.instantsearchplus.com]]></api_endpoint>
|
210 |
-
</config>
|
211 |
-
</autocompleteplus>
|
212 |
-
</default>
|
213 |
-
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Autocompleteplus_Autosuggest>
|
5 |
+
<version>3.0.0.11</version>
|
6 |
+
<url>http://autocompleteplus.com/</url>
|
7 |
+
<modulename>Autocompleteplus_Autosuggest</modulename>
|
8 |
+
</Autocompleteplus_Autosuggest>
|
9 |
+
</modules>
|
10 |
+
<global>
|
11 |
+
<models>
|
12 |
+
<autocompleteplus_autosuggest>
|
13 |
+
<class>Autocompleteplus_Autosuggest_Model</class>
|
14 |
+
<resourceModel>autocompleteplus_autosuggest_resource</resourceModel>
|
15 |
+
</autocompleteplus_autosuggest>
|
16 |
+
<autocompleteplus_autosuggest_resource>
|
17 |
+
<class>Autocompleteplus_Autosuggest_Model_Resource</class>
|
18 |
+
<deprecatedNode>autocompleteplus_mysql4</deprecatedNode>
|
19 |
+
<entities>
|
20 |
+
<notifications>
|
21 |
+
<table>autocompleteplus_notifications</table>
|
22 |
+
</notifications>
|
23 |
+
<pusher>
|
24 |
+
<table>autocompleteplus_pusher</table>
|
25 |
+
</pusher>
|
26 |
+
<config>
|
27 |
+
<table>autocompleteplus_config</table>
|
28 |
+
</config>
|
29 |
+
<batches>
|
30 |
+
<table>autocompleteplus_batches</table>
|
31 |
+
</batches>
|
32 |
+
</entities>
|
33 |
+
</autocompleteplus_autosuggest_resource>
|
34 |
+
<catalogsearch_resource>
|
35 |
+
<rewrite>
|
36 |
+
<fulltext_collection>Autocompleteplus_Autosuggest_Model_Resource_Fulltext_Collection</fulltext_collection>
|
37 |
+
</rewrite>
|
38 |
+
</catalogsearch_resource>
|
39 |
+
</models>
|
40 |
+
<events>
|
41 |
+
<controller_action_postdispatch_checkout_cart_index>
|
42 |
+
<observers>
|
43 |
+
<autocompleteplus_autosuggest>
|
44 |
+
<class>autocompleteplus_autosuggest/observer</class>
|
45 |
+
<method>webhook_service_call</method>
|
46 |
+
</autocompleteplus_autosuggest>
|
47 |
+
</observers>
|
48 |
+
</controller_action_postdispatch_checkout_cart_index>
|
49 |
+
<controller_action_postdispatch_checkout_onepage_index>
|
50 |
+
<observers>
|
51 |
+
<autocompleteplus_autosuggest>
|
52 |
+
<class>autocompleteplus_autosuggest/observer</class>
|
53 |
+
<method>webhook_service_call</method>
|
54 |
+
</autocompleteplus_autosuggest>
|
55 |
+
</observers>
|
56 |
+
</controller_action_postdispatch_checkout_onepage_index>
|
57 |
+
<controller_action_postdispatch_checkout_onepage_success>
|
58 |
+
<observers>
|
59 |
+
<autocompleteplus_autosuggest>
|
60 |
+
<class>autocompleteplus_autosuggest/observer</class>
|
61 |
+
<method>webhook_service_call</method>
|
62 |
+
</autocompleteplus_autosuggest>
|
63 |
+
</observers>
|
64 |
+
</controller_action_postdispatch_checkout_onepage_success>
|
65 |
+
<catalog_product_save_before>
|
66 |
+
<observers>
|
67 |
+
<autocompleteplus_autosuggest>
|
68 |
+
<type>singleton</type>
|
69 |
+
<class>autocompleteplus_autosuggest/observer</class>
|
70 |
+
<method>catalog_product_save_after</method>
|
71 |
+
</autocompleteplus_autosuggest>
|
72 |
+
</observers>
|
73 |
+
</catalog_product_save_before>
|
74 |
+
<catalog_product_save_after>
|
75 |
+
<observers>
|
76 |
+
<autocompleteplus_autosuggest>
|
77 |
+
<type>singleton</type>
|
78 |
+
<class>autocompleteplus_autosuggest/observer</class>
|
79 |
+
<method>catalog_product_save_after_real</method>
|
80 |
+
</autocompleteplus_autosuggest>
|
81 |
+
</observers>
|
82 |
+
</catalog_product_save_after>
|
83 |
+
<catalog_product_delete_before>
|
84 |
+
<observers>
|
85 |
+
<autocompleteplus_autosuggest>
|
86 |
+
<type>singleton</type>
|
87 |
+
<class>autocompleteplus_autosuggest/observer</class>
|
88 |
+
<method>catalog_product_delete_before</method>
|
89 |
+
</autocompleteplus_autosuggest>
|
90 |
+
</observers>
|
91 |
+
</catalog_product_delete_before>
|
92 |
+
<adminhtml_controller_catalogrule_prepare_save>
|
93 |
+
<observers>
|
94 |
+
<autocompleteplus_autosuggest>
|
95 |
+
<type>singleton</type>
|
96 |
+
<class>autocompleteplus_autosuggest/observer</class>
|
97 |
+
<method>adminhtml_controller_catalogrule_prepare_save</method>
|
98 |
+
</autocompleteplus_autosuggest>
|
99 |
+
</observers>
|
100 |
+
</adminhtml_controller_catalogrule_prepare_save>
|
101 |
+
</events>
|
102 |
+
<resources>
|
103 |
+
<autosuggest_setup>
|
104 |
+
<setup>
|
105 |
+
<module>Autocompleteplus_Autosuggest</module>
|
106 |
+
</setup>
|
107 |
+
<connection>
|
108 |
+
<use>core_setup</use>
|
109 |
+
</connection>
|
110 |
+
</autosuggest_setup>
|
111 |
+
<autosuggest_write>
|
112 |
+
<connection>
|
113 |
+
<use>core_write</use>
|
114 |
+
</connection>
|
115 |
+
</autosuggest_write>
|
116 |
+
<autosuggest_read>
|
117 |
+
<connection>
|
118 |
+
<use>core_read</use>
|
119 |
+
</connection>
|
120 |
+
</autosuggest_read>
|
121 |
+
</resources>
|
122 |
+
<blocks>
|
123 |
+
<autocompleteplus_autosuggest>
|
124 |
+
<class>Autocompleteplus_Autosuggest_Block</class>
|
125 |
+
</autocompleteplus_autosuggest>
|
126 |
+
</blocks>
|
127 |
+
<template>
|
128 |
+
<email>
|
129 |
+
<autosuggest_status_notification module="autocompleteplus_autosuggest">
|
130 |
+
<label>Autocompleteplus status notification</label>
|
131 |
+
<file>autocompleteplus/status_notification.html</file>
|
132 |
+
<type>html</type>
|
133 |
+
</autosuggest_status_notification>
|
134 |
+
</email>
|
135 |
+
</template>
|
136 |
+
<helpers>
|
137 |
+
<autocompleteplus_autosuggest>
|
138 |
+
<class>Autocompleteplus_Autosuggest_Helper</class>
|
139 |
+
</autocompleteplus_autosuggest>
|
140 |
+
</helpers>
|
141 |
+
<sales>
|
142 |
+
<quote>
|
143 |
+
<item>
|
144 |
+
<product_attributes>
|
145 |
+
<added_from_search />
|
146 |
+
</product_attributes>
|
147 |
+
</item>
|
148 |
+
</quote>
|
149 |
+
</sales>
|
150 |
+
</global>
|
151 |
+
<frontend>
|
152 |
+
<layout>
|
153 |
+
<updates>
|
154 |
+
<autosuggest>
|
155 |
+
<file>autocompleteplus.xml</file>
|
156 |
+
</autosuggest>
|
157 |
+
</updates>
|
158 |
+
</layout>
|
159 |
+
<routers>
|
160 |
+
<instantsearchplus>
|
161 |
+
<use>standard</use>
|
162 |
+
<args>
|
163 |
+
<module>Autocompleteplus_Autosuggest</module>
|
164 |
+
<frontName>instantsearchplus</frontName>
|
165 |
+
</args>
|
166 |
+
</instantsearchplus>
|
167 |
+
<autocompleteplus>
|
168 |
+
<use>standard</use>
|
169 |
+
<args>
|
170 |
+
<module>Autocompleteplus_Autosuggest</module>
|
171 |
+
<frontName>autocompleteplus</frontName>
|
172 |
+
</args>
|
173 |
+
</autocompleteplus>
|
174 |
+
<catalogsearch>
|
175 |
+
<args>
|
176 |
+
<modules>
|
177 |
+
<Autocompleteplus_Autosuggest before="Mage_CatalogSearch">Autocompleteplus_Autosuggest_CatalogSearch</Autocompleteplus_Autosuggest>
|
178 |
+
</modules>
|
179 |
+
</args>
|
180 |
+
</catalogsearch>
|
181 |
+
</routers>
|
182 |
+
</frontend>
|
183 |
+
<admin>
|
184 |
+
<routers>
|
185 |
+
<adminhtml>
|
186 |
+
<args>
|
187 |
+
<modules>
|
188 |
+
<autocompleteplus after="Mage_Adminhtml">Autocompleteplus_Autosuggest_Adminhtml</autocompleteplus>
|
189 |
+
</modules>
|
190 |
+
</args>
|
191 |
+
</adminhtml>
|
192 |
+
</routers>
|
193 |
+
</admin>
|
194 |
+
<adminhtml>
|
195 |
+
<layout>
|
196 |
+
<updates>
|
197 |
+
<autosuggest>
|
198 |
+
<file>autocompleteplus.xml</file>
|
199 |
+
</autosuggest>
|
200 |
+
</updates>
|
201 |
+
</layout>
|
202 |
+
</adminhtml>
|
203 |
+
<default>
|
204 |
+
<autocompleteplus>
|
205 |
+
<config>
|
206 |
+
<imagefield>thumbnail</imagefield>
|
207 |
+
<attributes>1</attributes>
|
208 |
+
<layered>0</layered>
|
209 |
+
<api_endpoint><![CDATA[https://magento.instantsearchplus.com]]></api_endpoint>
|
210 |
+
</config>
|
211 |
+
</autocompleteplus>
|
212 |
+
</default>
|
213 |
+
</config>
|
app/code/local/Autocompleteplus/Autosuggest/etc/system.xml
CHANGED
@@ -1,74 +1,74 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<tabs>
|
4 |
-
<autocompleteplus_autosuggest translate="label" module="autocompleteplus_autosuggest">
|
5 |
-
<label>InstantSearch+</label>
|
6 |
-
<sort_order>195</sort_order>
|
7 |
-
</autocompleteplus_autosuggest>
|
8 |
-
</tabs>
|
9 |
-
<sections>
|
10 |
-
<autocompleteplus translate="label" module="autocompleteplus_autosuggest">
|
11 |
-
<label>InstantSearch+</label>
|
12 |
-
<tab>autocompleteplus_autosuggest</tab>
|
13 |
-
<frontend_type>text</frontend_type>
|
14 |
-
<sort_order>100</sort_order>
|
15 |
-
<show_in_default>1</show_in_default>
|
16 |
-
<show_in_website>1</show_in_website>
|
17 |
-
<show_in_store>1</show_in_store>
|
18 |
-
<groups>
|
19 |
-
<config translate="label">
|
20 |
-
<label>General Settings</label>
|
21 |
-
<frontend_type>text</frontend_type>
|
22 |
-
<sort_order>1</sort_order>
|
23 |
-
<show_in_default>1</show_in_default>
|
24 |
-
<show_in_website>1</show_in_website>
|
25 |
-
<show_in_store>1</show_in_store>
|
26 |
-
<fields>
|
27 |
-
<enabled translate="label">
|
28 |
-
<label>Enable InstantSearch+</label>
|
29 |
-
<frontend_type>select</frontend_type>
|
30 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
31 |
-
<sort_order>1</sort_order>
|
32 |
-
<show_in_default>1</show_in_default>
|
33 |
-
<show_in_website>1</show_in_website>
|
34 |
-
<show_in_store>1</show_in_store>
|
35 |
-
</enabled>
|
36 |
-
<imagefield translate="label">
|
37 |
-
<label>Magento field for product thumbnail image</label>
|
38 |
-
<frontend_type>select</frontend_type>
|
39 |
-
<source_model>autocompleteplus_autosuggest/adminhtml_attributes</source_model>
|
40 |
-
<sort_order>3</sort_order>
|
41 |
-
<show_in_default>1</show_in_default>
|
42 |
-
<show_in_website>1</show_in_website>
|
43 |
-
<show_in_store>1</show_in_store>
|
44 |
-
</imagefield>
|
45 |
-
<attributes translate="label">
|
46 |
-
<label>Sync custom attributes</label>
|
47 |
-
<comment>Allow users to search by your shop custom attributes</comment>
|
48 |
-
<frontend_type>select</frontend_type>
|
49 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
50 |
-
<sort_order>4</sort_order>
|
51 |
-
<show_in_default>1</show_in_default>
|
52 |
-
<show_in_website>1</show_in_website>
|
53 |
-
<show_in_store>1</show_in_store>
|
54 |
-
</attributes>
|
55 |
-
<sync translate="label">
|
56 |
-
<label>Sync products with InstantSearch+</label>
|
57 |
-
<comment>Sync store products with InstantSearch+ initially, as well as subsequent product updates</comment>
|
58 |
-
<frontend_type>button</frontend_type>
|
59 |
-
<frontend_model>autocompleteplus_autosuggest/adminhtml_sync</frontend_model>
|
60 |
-
<sort_order>21</sort_order>
|
61 |
-
<show_in_default>1</show_in_default>
|
62 |
-
<show_in_website>1</show_in_website>
|
63 |
-
<show_in_store>1</show_in_store>
|
64 |
-
</sync>
|
65 |
-
</fields>
|
66 |
-
<comment>
|
67 |
-
<b style="font-size:1.2em;" >Visit InstantSearch+ Dashboard to customize additional settings.</b><br>
|
68 |
-
InstantSearch+ brings your users relevant personal product and searches suggestions using a dedicated world-class cloud service.
|
69 |
-
</comment>
|
70 |
-
</config>
|
71 |
-
</groups>
|
72 |
-
</autocompleteplus>
|
73 |
-
</sections>
|
74 |
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<autocompleteplus_autosuggest translate="label" module="autocompleteplus_autosuggest">
|
5 |
+
<label>InstantSearch+</label>
|
6 |
+
<sort_order>195</sort_order>
|
7 |
+
</autocompleteplus_autosuggest>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<autocompleteplus translate="label" module="autocompleteplus_autosuggest">
|
11 |
+
<label>InstantSearch+</label>
|
12 |
+
<tab>autocompleteplus_autosuggest</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>100</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<config translate="label">
|
20 |
+
<label>General Settings</label>
|
21 |
+
<frontend_type>text</frontend_type>
|
22 |
+
<sort_order>1</sort_order>
|
23 |
+
<show_in_default>1</show_in_default>
|
24 |
+
<show_in_website>1</show_in_website>
|
25 |
+
<show_in_store>1</show_in_store>
|
26 |
+
<fields>
|
27 |
+
<enabled translate="label">
|
28 |
+
<label>Enable InstantSearch+</label>
|
29 |
+
<frontend_type>select</frontend_type>
|
30 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
31 |
+
<sort_order>1</sort_order>
|
32 |
+
<show_in_default>1</show_in_default>
|
33 |
+
<show_in_website>1</show_in_website>
|
34 |
+
<show_in_store>1</show_in_store>
|
35 |
+
</enabled>
|
36 |
+
<imagefield translate="label">
|
37 |
+
<label>Magento field for product thumbnail image</label>
|
38 |
+
<frontend_type>select</frontend_type>
|
39 |
+
<source_model>autocompleteplus_autosuggest/adminhtml_attributes</source_model>
|
40 |
+
<sort_order>3</sort_order>
|
41 |
+
<show_in_default>1</show_in_default>
|
42 |
+
<show_in_website>1</show_in_website>
|
43 |
+
<show_in_store>1</show_in_store>
|
44 |
+
</imagefield>
|
45 |
+
<attributes translate="label">
|
46 |
+
<label>Sync custom attributes</label>
|
47 |
+
<comment>Allow users to search by your shop custom attributes</comment>
|
48 |
+
<frontend_type>select</frontend_type>
|
49 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
50 |
+
<sort_order>4</sort_order>
|
51 |
+
<show_in_default>1</show_in_default>
|
52 |
+
<show_in_website>1</show_in_website>
|
53 |
+
<show_in_store>1</show_in_store>
|
54 |
+
</attributes>
|
55 |
+
<sync translate="label">
|
56 |
+
<label>Sync products with InstantSearch+</label>
|
57 |
+
<comment>Sync store products with InstantSearch+ initially, as well as subsequent product updates</comment>
|
58 |
+
<frontend_type>button</frontend_type>
|
59 |
+
<frontend_model>autocompleteplus_autosuggest/adminhtml_sync</frontend_model>
|
60 |
+
<sort_order>21</sort_order>
|
61 |
+
<show_in_default>1</show_in_default>
|
62 |
+
<show_in_website>1</show_in_website>
|
63 |
+
<show_in_store>1</show_in_store>
|
64 |
+
</sync>
|
65 |
+
</fields>
|
66 |
+
<comment>
|
67 |
+
<b style="font-size:1.2em;" >Visit InstantSearch+ Dashboard to customize additional settings.</b><br>
|
68 |
+
InstantSearch+ brings your users relevant personal product and searches suggestions using a dedicated world-class cloud service.
|
69 |
+
</comment>
|
70 |
+
</config>
|
71 |
+
</groups>
|
72 |
+
</autocompleteplus>
|
73 |
+
</sections>
|
74 |
</config>
|
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-install-2.0.1.1.php
CHANGED
@@ -1,25 +1,25 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* InstantSearchPlus (Autosuggest).
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is available through the world-wide-web at this URL:
|
9 |
-
* http://opensource.org/licenses/osl-3.0.php
|
10 |
-
*
|
11 |
-
* @category Mage
|
12 |
-
*
|
13 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
17 |
-
|
18 |
-
Mage::log(__FILE__ . ' triggered', null, 'autocomplete.log', true);
|
19 |
-
|
20 |
-
//getting site owner email
|
21 |
-
$storeMail = $helper->getConfigDataByFullPath('trans_email/ident_general/email');
|
22 |
-
Mage::log($storeMail, null, 'autocomplete.log');
|
23 |
-
Mage::getModel('core/config')->saveConfig('autocompleteplus/config/store_email', $storeMail);
|
24 |
-
|
25 |
-
Mage::getModel('core/config')->saveConfig('autocompleteplus/config/enabled', 1);
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* InstantSearchPlus (Autosuggest).
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Mage
|
12 |
+
*
|
13 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
17 |
+
|
18 |
+
Mage::log(__FILE__ . ' triggered', null, 'autocomplete.log', true);
|
19 |
+
|
20 |
+
//getting site owner email
|
21 |
+
$storeMail = $helper->getConfigDataByFullPath('trans_email/ident_general/email');
|
22 |
+
Mage::log($storeMail, null, 'autocomplete.log');
|
23 |
+
Mage::getModel('core/config')->saveConfig('autocompleteplus/config/store_email', $storeMail);
|
24 |
+
|
25 |
+
Mage::getModel('core/config')->saveConfig('autocompleteplus/config/enabled', 1);
|
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.1.3-2.0.2.2.php
CHANGED
@@ -1,32 +1,32 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* InstantSearchPlus (Autosuggest).
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is available through the world-wide-web at this URL:
|
9 |
-
* http://opensource.org/licenses/osl-3.0.php
|
10 |
-
*
|
11 |
-
* @category Mage
|
12 |
-
*
|
13 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
$installer = $this;
|
17 |
-
$installer->startSetup();
|
18 |
-
|
19 |
-
$res = $installer->run("
|
20 |
-
DROP TABLE IF EXISTS {$this->getTable('autocompleteplus_batches')};
|
21 |
-
CREATE TABLE IF NOT EXISTS {$this->getTable('autocompleteplus_batches')} (
|
22 |
-
`id` int(11) NOT NULL auto_increment,
|
23 |
-
`product_id` INT NULL,
|
24 |
-
`store_id` INT NOT NULL,
|
25 |
-
`update_date` INT DEFAULT NULL,
|
26 |
-
`action` VARCHAR( 255 ) NOT NULL,
|
27 |
-
`sku` VARCHAR( 255 ) NOT NULL,
|
28 |
-
PRIMARY KEY (`id`)
|
29 |
-
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
|
30 |
-
|
31 |
-
Mage::log(__FILE__ . ' triggered', null, 'autocomplete.log', true);
|
32 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* InstantSearchPlus (Autosuggest).
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Mage
|
12 |
+
*
|
13 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
$installer = $this;
|
17 |
+
$installer->startSetup();
|
18 |
+
|
19 |
+
$res = $installer->run("
|
20 |
+
DROP TABLE IF EXISTS {$this->getTable('autocompleteplus_batches')};
|
21 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('autocompleteplus_batches')} (
|
22 |
+
`id` int(11) NOT NULL auto_increment,
|
23 |
+
`product_id` INT NULL,
|
24 |
+
`store_id` INT NOT NULL,
|
25 |
+
`update_date` INT DEFAULT NULL,
|
26 |
+
`action` VARCHAR( 255 ) NOT NULL,
|
27 |
+
`sku` VARCHAR( 255 ) NOT NULL,
|
28 |
+
PRIMARY KEY (`id`)
|
29 |
+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
|
30 |
+
|
31 |
+
Mage::log(__FILE__ . ' triggered', null, 'autocomplete.log', true);
|
32 |
+
$installer->endSetup();
|
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.2.5-2.0.2.6.php
CHANGED
@@ -1,37 +1,37 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* InstantSearchPlus (Autosuggest).
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is available through the world-wide-web at this URL:
|
9 |
-
* http://opensource.org/licenses/osl-3.0.php
|
10 |
-
*
|
11 |
-
* @category Mage
|
12 |
-
*
|
13 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
|
17 |
-
/* @var $installer Mage_Core_Model_Resource_Setup */
|
18 |
-
$installer = $this;
|
19 |
-
|
20 |
-
$installer->startSetup();
|
21 |
-
|
22 |
-
$installer->run("
|
23 |
-
-- DROP TABLE IF EXISTS `{$this->getTable('autocompleteplus_autosuggest/notifications')}`;
|
24 |
-
CREATE TABLE IF NOT EXISTS `{$installer->getTable('autocompleteplus_autosuggest/notifications')}` (
|
25 |
-
`notification_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
26 |
-
`type` varchar(32) default NULL,
|
27 |
-
`subject` varchar(255) default NULL,
|
28 |
-
`message` text,
|
29 |
-
`timestamp` varchar(32) default NULL,
|
30 |
-
`is_active` tinyint(1) NOT NULL default '1',
|
31 |
-
PRIMARY KEY (`notification_id`),
|
32 |
-
KEY `IDX_TYPE` (`type`),
|
33 |
-
KEY `IDX_IS_ACTIVE` (`is_active`)
|
34 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
35 |
-
");
|
36 |
-
Mage::log(__FILE__ . ' triggered', null, 'autocomplete.log', true);
|
37 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* InstantSearchPlus (Autosuggest).
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Mage
|
12 |
+
*
|
13 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
|
17 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
18 |
+
$installer = $this;
|
19 |
+
|
20 |
+
$installer->startSetup();
|
21 |
+
|
22 |
+
$installer->run("
|
23 |
+
-- DROP TABLE IF EXISTS `{$this->getTable('autocompleteplus_autosuggest/notifications')}`;
|
24 |
+
CREATE TABLE IF NOT EXISTS `{$installer->getTable('autocompleteplus_autosuggest/notifications')}` (
|
25 |
+
`notification_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
26 |
+
`type` varchar(32) default NULL,
|
27 |
+
`subject` varchar(255) default NULL,
|
28 |
+
`message` text,
|
29 |
+
`timestamp` varchar(32) default NULL,
|
30 |
+
`is_active` tinyint(1) NOT NULL default '1',
|
31 |
+
PRIMARY KEY (`notification_id`),
|
32 |
+
KEY `IDX_TYPE` (`type`),
|
33 |
+
KEY `IDX_IS_ACTIVE` (`is_active`)
|
34 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
35 |
+
");
|
36 |
+
Mage::log(__FILE__ . ' triggered', null, 'autocomplete.log', true);
|
37 |
+
$installer->endSetup();
|
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.4.6-2.0.4.7.php
CHANGED
@@ -1,41 +1,41 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* InstantSearchPlus (Autosuggest).
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is available through the world-wide-web at this URL:
|
9 |
-
* http://opensource.org/licenses/osl-3.0.php
|
10 |
-
*
|
11 |
-
* @category Mage
|
12 |
-
*
|
13 |
-
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
-
*/
|
16 |
-
$installer = $this;
|
17 |
-
|
18 |
-
$installer->startSetup();
|
19 |
-
|
20 |
-
$res = $installer->run("
|
21 |
-
|
22 |
-
DROP TABLE IF EXISTS {$this->getTable('autocompleteplus_checksum')};
|
23 |
-
|
24 |
-
CREATE TABLE IF NOT EXISTS {$this->getTable('autocompleteplus_checksum')} (
|
25 |
-
|
26 |
-
`identifier` VARCHAR( 255 ) NOT NULL,
|
27 |
-
|
28 |
-
`sku` VARCHAR( 255 ) NOT NULL,
|
29 |
-
|
30 |
-
`store_id` INT NOT NULL,
|
31 |
-
|
32 |
-
`checksum` VARCHAR( 255 ) NOT NULL,
|
33 |
-
|
34 |
-
PRIMARY KEY (`identifier`, `store_id`)
|
35 |
-
|
36 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
37 |
-
|
38 |
-
");
|
39 |
-
|
40 |
-
Mage::log(__FILE__ . ' triggered', null, 'autocomplete.log', true);
|
41 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* InstantSearchPlus (Autosuggest).
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @category Mage
|
12 |
+
*
|
13 |
+
* @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
$installer = $this;
|
17 |
+
|
18 |
+
$installer->startSetup();
|
19 |
+
|
20 |
+
$res = $installer->run("
|
21 |
+
|
22 |
+
DROP TABLE IF EXISTS {$this->getTable('autocompleteplus_checksum')};
|
23 |
+
|
24 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('autocompleteplus_checksum')} (
|
25 |
+
|
26 |
+
`identifier` VARCHAR( 255 ) NOT NULL,
|
27 |
+
|
28 |
+
`sku` VARCHAR( 255 ) NOT NULL,
|
29 |
+
|
30 |
+
`store_id` INT NOT NULL,
|
31 |
+
|
32 |
+
`checksum` VARCHAR( 255 ) NOT NULL,
|
33 |
+
|
34 |
+
PRIMARY KEY (`identifier`, `store_id`)
|
35 |
+
|
36 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
37 |
+
|
38 |
+
");
|
39 |
+
|
40 |
+
Mage::log(__FILE__ . ' triggered', null, 'autocomplete.log', true);
|
41 |
+
$installer->endSetup();
|
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.5.4-2.0.5.5.php
CHANGED
@@ -1,107 +1,107 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
|
5 |
-
$installer->startSetup();
|
6 |
-
$fileIo = new Varien_Io_File();
|
7 |
-
$baseDir = Mage::getBaseDir();
|
8 |
-
$fileIo->open(array('path' => $baseDir));
|
9 |
-
|
10 |
-
// getEdition exist from version 1.12, LICENSE_EE.txt file only exists in EE edition, we need the condition to work on EE version less then 1.11.x.x
|
11 |
-
if (!method_exists('Mage', 'getEdition') && file_exists($baseDir . DS . 'LICENSE_EE.txt') && method_exists('Mage', 'getVersion') && version_compare(Mage::getVersion(), '1.10.0.0.', '<') === true) {
|
12 |
-
|
13 |
-
$res = $installer->run("
|
14 |
-
|
15 |
-
DROP TABLE IF EXISTS {$this->getTable('autocompleteplus_pusher')};
|
16 |
-
|
17 |
-
CREATE TABLE IF NOT EXISTS {$this->getTable('autocompleteplus_pusher')} (
|
18 |
-
|
19 |
-
`id` INT UNSIGNED NOT NULL auto_increment,
|
20 |
-
|
21 |
-
`store_id` INT UNSIGNED NOT NULL,
|
22 |
-
|
23 |
-
`to_send` INT UNSIGNED NOT NULL,
|
24 |
-
|
25 |
-
`offset` INT UNSIGNED NOT NULL,
|
26 |
-
|
27 |
-
`total_batches` INT UNSIGNED NOT NULL,
|
28 |
-
|
29 |
-
`batch_number` INT UNSIGNED NOT NULL,
|
30 |
-
|
31 |
-
`sent` INT UNSIGNED NOT NULL,
|
32 |
-
|
33 |
-
PRIMARY KEY (`id`)
|
34 |
-
|
35 |
-
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
36 |
-
|
37 |
-
");
|
38 |
-
} else {
|
39 |
-
$table = $installer->getConnection()->newTable($installer->getTable('autocompleteplus_autosuggest/pusher'))
|
40 |
-
->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
41 |
-
|
42 |
-
'identity' => true,
|
43 |
-
|
44 |
-
'unsigned' => true,
|
45 |
-
|
46 |
-
'nullable' => false,
|
47 |
-
|
48 |
-
'primary' => true,
|
49 |
-
|
50 |
-
), 'Id')
|
51 |
-
->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
52 |
-
|
53 |
-
'nullable' => false,
|
54 |
-
|
55 |
-
'unsigned' => true,
|
56 |
-
|
57 |
-
))
|
58 |
-
->addColumn('to_send', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
59 |
-
|
60 |
-
'nullable' => false,
|
61 |
-
|
62 |
-
'unsigned' => true,
|
63 |
-
|
64 |
-
), 'Amount left to send')
|
65 |
-
->addColumn('offset', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
66 |
-
|
67 |
-
'nullable' => false,
|
68 |
-
|
69 |
-
'unsigned' => true,
|
70 |
-
|
71 |
-
))
|
72 |
-
->addColumn('total_batches', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
73 |
-
|
74 |
-
'nullable' => false,
|
75 |
-
|
76 |
-
'unsigned' => true,
|
77 |
-
|
78 |
-
))
|
79 |
-
->addColumn('batch_number', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
80 |
-
|
81 |
-
'nullable' => false,
|
82 |
-
|
83 |
-
'unsigned' => true,
|
84 |
-
|
85 |
-
))
|
86 |
-
->addColumn('sent', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
87 |
-
|
88 |
-
'nullable' => false,
|
89 |
-
|
90 |
-
'unsigned' => true,
|
91 |
-
|
92 |
-
));
|
93 |
-
|
94 |
-
if (method_exists($installer->getConnection(), 'isTableExists')) {
|
95 |
-
if ($installer->getConnection()->isTableExists($table->getName())) {
|
96 |
-
$installer->getConnection()->dropTable($table->getName());
|
97 |
-
}
|
98 |
-
} else if (method_exists($installer, 'tableExists')) {
|
99 |
-
if ($installer->tableExists($table->getName())) {
|
100 |
-
$installer->run("DROP TABLE IF EXISTS {$table->getName()};");
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
$installer->getConnection()->createTable($table);
|
105 |
-
}
|
106 |
-
Mage::log(__FILE__ . ' triggered', null, 'autocomplete.log', true);
|
107 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
$fileIo = new Varien_Io_File();
|
7 |
+
$baseDir = Mage::getBaseDir();
|
8 |
+
$fileIo->open(array('path' => $baseDir));
|
9 |
+
|
10 |
+
// getEdition exist from version 1.12, LICENSE_EE.txt file only exists in EE edition, we need the condition to work on EE version less then 1.11.x.x
|
11 |
+
if (!method_exists('Mage', 'getEdition') && file_exists($baseDir . DS . 'LICENSE_EE.txt') && method_exists('Mage', 'getVersion') && version_compare(Mage::getVersion(), '1.10.0.0.', '<') === true) {
|
12 |
+
|
13 |
+
$res = $installer->run("
|
14 |
+
|
15 |
+
DROP TABLE IF EXISTS {$this->getTable('autocompleteplus_pusher')};
|
16 |
+
|
17 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('autocompleteplus_pusher')} (
|
18 |
+
|
19 |
+
`id` INT UNSIGNED NOT NULL auto_increment,
|
20 |
+
|
21 |
+
`store_id` INT UNSIGNED NOT NULL,
|
22 |
+
|
23 |
+
`to_send` INT UNSIGNED NOT NULL,
|
24 |
+
|
25 |
+
`offset` INT UNSIGNED NOT NULL,
|
26 |
+
|
27 |
+
`total_batches` INT UNSIGNED NOT NULL,
|
28 |
+
|
29 |
+
`batch_number` INT UNSIGNED NOT NULL,
|
30 |
+
|
31 |
+
`sent` INT UNSIGNED NOT NULL,
|
32 |
+
|
33 |
+
PRIMARY KEY (`id`)
|
34 |
+
|
35 |
+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
36 |
+
|
37 |
+
");
|
38 |
+
} else {
|
39 |
+
$table = $installer->getConnection()->newTable($installer->getTable('autocompleteplus_autosuggest/pusher'))
|
40 |
+
->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
41 |
+
|
42 |
+
'identity' => true,
|
43 |
+
|
44 |
+
'unsigned' => true,
|
45 |
+
|
46 |
+
'nullable' => false,
|
47 |
+
|
48 |
+
'primary' => true,
|
49 |
+
|
50 |
+
), 'Id')
|
51 |
+
->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
52 |
+
|
53 |
+
'nullable' => false,
|
54 |
+
|
55 |
+
'unsigned' => true,
|
56 |
+
|
57 |
+
))
|
58 |
+
->addColumn('to_send', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
59 |
+
|
60 |
+
'nullable' => false,
|
61 |
+
|
62 |
+
'unsigned' => true,
|
63 |
+
|
64 |
+
), 'Amount left to send')
|
65 |
+
->addColumn('offset', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
66 |
+
|
67 |
+
'nullable' => false,
|
68 |
+
|
69 |
+
'unsigned' => true,
|
70 |
+
|
71 |
+
))
|
72 |
+
->addColumn('total_batches', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
73 |
+
|
74 |
+
'nullable' => false,
|
75 |
+
|
76 |
+
'unsigned' => true,
|
77 |
+
|
78 |
+
))
|
79 |
+
->addColumn('batch_number', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
80 |
+
|
81 |
+
'nullable' => false,
|
82 |
+
|
83 |
+
'unsigned' => true,
|
84 |
+
|
85 |
+
))
|
86 |
+
->addColumn('sent', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
87 |
+
|
88 |
+
'nullable' => false,
|
89 |
+
|
90 |
+
'unsigned' => true,
|
91 |
+
|
92 |
+
));
|
93 |
+
|
94 |
+
if (method_exists($installer->getConnection(), 'isTableExists')) {
|
95 |
+
if ($installer->getConnection()->isTableExists($table->getName())) {
|
96 |
+
$installer->getConnection()->dropTable($table->getName());
|
97 |
+
}
|
98 |
+
} else if (method_exists($installer, 'tableExists')) {
|
99 |
+
if ($installer->tableExists($table->getName())) {
|
100 |
+
$installer->run("DROP TABLE IF EXISTS {$table->getName()};");
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
$installer->getConnection()->createTable($table);
|
105 |
+
}
|
106 |
+
Mage::log(__FILE__ . ' triggered', null, 'autocomplete.log', true);
|
107 |
+
$installer->endSetup();
|
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.7.0-2.0.7.1.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
$installer->startSetup();
|
5 |
-
|
6 |
-
// $installer->run("ALTER TABLE {$this->getTable('sales/quote_item')} ADD `added_from_search` TINYINT(1) NULL DEFAULT NULL COMMENT 'AutocompletePlus Add Flag';");
|
7 |
-
Mage::log(__FILE__ . ' triggered', null, 'autocomplete.log', true);
|
8 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
+
// $installer->run("ALTER TABLE {$this->getTable('sales/quote_item')} ADD `added_from_search` TINYINT(1) NULL DEFAULT NULL COMMENT 'AutocompletePlus Add Flag';");
|
7 |
+
Mage::log(__FILE__ . ' triggered', null, 'autocomplete.log', true);
|
8 |
+
$installer->endSetup();
|
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.7.2-2.0.7.3.php
CHANGED
@@ -1,105 +1,105 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
$tableName = $this->getTable('autocompleteplus_batches');
|
5 |
-
$columnName = 'update_date';
|
6 |
-
$checkColumnType = false;
|
7 |
-
$fileIo = new Varien_Io_File();
|
8 |
-
$baseDir = Mage::getBaseDir();
|
9 |
-
$fileIo->open(array('path' => $baseDir));
|
10 |
-
|
11 |
-
/*
|
12 |
-
* Check if getEdition method does not exist in Mage
|
13 |
-
* Check if Enterprise Edition license exists in Magento root
|
14 |
-
* Check if getVersion method exists in Mage
|
15 |
-
* Compare versions to check if less than 1.10.0.0
|
16 |
-
* Required to use file_exists because Varien_Io_File isValid missing < 1.8CE
|
17 |
-
*/
|
18 |
-
// @codingStandardsIgnoreLine
|
19 |
-
if (!method_exists('Mage', 'getEdition') && file_exists($baseDir . DS . 'LICENSE_EE.txt') && method_exists('Mage', 'getVersion') && version_compare(Mage::getVersion(), '1.10.0.0.', '<') === true) {
|
20 |
-
$tableExists = $installer->getConnection()->showTableStatus($tableName);
|
21 |
-
} else {
|
22 |
-
if (method_exists($installer->getConnection(), 'isTableExists')) {
|
23 |
-
$tableExists = $installer->getConnection()->isTableExists($tableName);
|
24 |
-
} else {
|
25 |
-
$tableExists = $installer->tableExists($tableName);
|
26 |
-
}
|
27 |
-
}
|
28 |
-
|
29 |
-
if ($tableExists) {
|
30 |
-
try {
|
31 |
-
$checkIfExists = $installer->getConnection()->tableColumnExists($tableName, 'update_date');
|
32 |
-
|
33 |
-
/*
|
34 |
-
* Check if table already exists
|
35 |
-
*/
|
36 |
-
if (!$checkIfExists) {
|
37 |
-
|
38 |
-
/*
|
39 |
-
* Check if column 'update_date' is type INT
|
40 |
-
*/
|
41 |
-
$describe = $this->getConnection()->describeTable($tableName);
|
42 |
-
foreach ($describe as $column) {
|
43 |
-
if ($column['COLUMN_NAME'] == $columnName && $column['DATA_TYPE'] == Varien_Db_Ddl_Table::TYPE_INTEGER) {
|
44 |
-
$checkColumnType = true;
|
45 |
-
}
|
46 |
-
}
|
47 |
-
|
48 |
-
if (!$checkColumnType) {
|
49 |
-
$installer->startSetup();
|
50 |
-
|
51 |
-
if (method_exists($installer->getConnection(), 'dropTable')) {
|
52 |
-
$installer->getConnection()->dropTable($tableName);
|
53 |
-
} else {
|
54 |
-
$installer->run("DROP TABLE IF EXISTS {$tableName};");
|
55 |
-
}
|
56 |
-
|
57 |
-
$installer->getConnection()->newTable($tableName)
|
58 |
-
->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
|
59 |
-
'identity' => true,
|
60 |
-
'unsigned' => true,
|
61 |
-
'nullable' => false,
|
62 |
-
'primary' => true,
|
63 |
-
'comment' => 'Batch ID',
|
64 |
-
))
|
65 |
-
->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
66 |
-
'nullable' => false,
|
67 |
-
'comment' => 'Product ID',
|
68 |
-
))
|
69 |
-
->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
70 |
-
'nullable' => false,
|
71 |
-
'comment' => 'Store ID',
|
72 |
-
))
|
73 |
-
->addColumn('update_date', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
74 |
-
'nullable' => true,
|
75 |
-
'comment' => 'Update Time Integer',
|
76 |
-
))
|
77 |
-
->addColumn('action', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
|
78 |
-
'nullable' => false,
|
79 |
-
'comment' => 'Batch Action',
|
80 |
-
))
|
81 |
-
->addColumn('sku', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
|
82 |
-
'nullable' => false,
|
83 |
-
'comment' => 'Product SKU',
|
84 |
-
));
|
85 |
-
$installer->endSetup();
|
86 |
-
}
|
87 |
-
}
|
88 |
-
} catch (Exception $e) {
|
89 |
-
$errMsg = $e->getMessage();
|
90 |
-
Mage::log('Install failed with a message: '.$errMsg, null, 'autocomplete.log', true);
|
91 |
-
|
92 |
-
$command = 'http://magento.instantsearchplus.com/install_error';
|
93 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
94 |
-
//getting site url
|
95 |
-
$url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
|
96 |
-
|
97 |
-
$data = array();
|
98 |
-
$data['site'] = $url;
|
99 |
-
$data['msg'] = $errMsg;
|
100 |
-
$data['f'] = '2.0.7.3';
|
101 |
-
$res = $helper->sendPostCurl($command, $data);
|
102 |
-
}
|
103 |
-
|
104 |
-
Mage::log(__FILE__ . ' triggered', null, 'autocomplete.log', true);
|
105 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$tableName = $this->getTable('autocompleteplus_batches');
|
5 |
+
$columnName = 'update_date';
|
6 |
+
$checkColumnType = false;
|
7 |
+
$fileIo = new Varien_Io_File();
|
8 |
+
$baseDir = Mage::getBaseDir();
|
9 |
+
$fileIo->open(array('path' => $baseDir));
|
10 |
+
|
11 |
+
/*
|
12 |
+
* Check if getEdition method does not exist in Mage
|
13 |
+
* Check if Enterprise Edition license exists in Magento root
|
14 |
+
* Check if getVersion method exists in Mage
|
15 |
+
* Compare versions to check if less than 1.10.0.0
|
16 |
+
* Required to use file_exists because Varien_Io_File isValid missing < 1.8CE
|
17 |
+
*/
|
18 |
+
// @codingStandardsIgnoreLine
|
19 |
+
if (!method_exists('Mage', 'getEdition') && file_exists($baseDir . DS . 'LICENSE_EE.txt') && method_exists('Mage', 'getVersion') && version_compare(Mage::getVersion(), '1.10.0.0.', '<') === true) {
|
20 |
+
$tableExists = $installer->getConnection()->showTableStatus($tableName);
|
21 |
+
} else {
|
22 |
+
if (method_exists($installer->getConnection(), 'isTableExists')) {
|
23 |
+
$tableExists = $installer->getConnection()->isTableExists($tableName);
|
24 |
+
} else {
|
25 |
+
$tableExists = $installer->tableExists($tableName);
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
if ($tableExists) {
|
30 |
+
try {
|
31 |
+
$checkIfExists = $installer->getConnection()->tableColumnExists($tableName, 'update_date');
|
32 |
+
|
33 |
+
/*
|
34 |
+
* Check if table already exists
|
35 |
+
*/
|
36 |
+
if (!$checkIfExists) {
|
37 |
+
|
38 |
+
/*
|
39 |
+
* Check if column 'update_date' is type INT
|
40 |
+
*/
|
41 |
+
$describe = $this->getConnection()->describeTable($tableName);
|
42 |
+
foreach ($describe as $column) {
|
43 |
+
if ($column['COLUMN_NAME'] == $columnName && $column['DATA_TYPE'] == Varien_Db_Ddl_Table::TYPE_INTEGER) {
|
44 |
+
$checkColumnType = true;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
if (!$checkColumnType) {
|
49 |
+
$installer->startSetup();
|
50 |
+
|
51 |
+
if (method_exists($installer->getConnection(), 'dropTable')) {
|
52 |
+
$installer->getConnection()->dropTable($tableName);
|
53 |
+
} else {
|
54 |
+
$installer->run("DROP TABLE IF EXISTS {$tableName};");
|
55 |
+
}
|
56 |
+
|
57 |
+
$installer->getConnection()->newTable($tableName)
|
58 |
+
->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
|
59 |
+
'identity' => true,
|
60 |
+
'unsigned' => true,
|
61 |
+
'nullable' => false,
|
62 |
+
'primary' => true,
|
63 |
+
'comment' => 'Batch ID',
|
64 |
+
))
|
65 |
+
->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
66 |
+
'nullable' => false,
|
67 |
+
'comment' => 'Product ID',
|
68 |
+
))
|
69 |
+
->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
70 |
+
'nullable' => false,
|
71 |
+
'comment' => 'Store ID',
|
72 |
+
))
|
73 |
+
->addColumn('update_date', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
74 |
+
'nullable' => true,
|
75 |
+
'comment' => 'Update Time Integer',
|
76 |
+
))
|
77 |
+
->addColumn('action', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
|
78 |
+
'nullable' => false,
|
79 |
+
'comment' => 'Batch Action',
|
80 |
+
))
|
81 |
+
->addColumn('sku', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
|
82 |
+
'nullable' => false,
|
83 |
+
'comment' => 'Product SKU',
|
84 |
+
));
|
85 |
+
$installer->endSetup();
|
86 |
+
}
|
87 |
+
}
|
88 |
+
} catch (Exception $e) {
|
89 |
+
$errMsg = $e->getMessage();
|
90 |
+
Mage::log('Install failed with a message: '.$errMsg, null, 'autocomplete.log', true);
|
91 |
+
|
92 |
+
$command = 'http://magento.instantsearchplus.com/install_error';
|
93 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
94 |
+
//getting site url
|
95 |
+
$url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
|
96 |
+
|
97 |
+
$data = array();
|
98 |
+
$data['site'] = $url;
|
99 |
+
$data['msg'] = $errMsg;
|
100 |
+
$data['f'] = '2.0.7.3';
|
101 |
+
$res = $helper->sendPostCurl($command, $data);
|
102 |
+
}
|
103 |
+
|
104 |
+
Mage::log(__FILE__ . ' triggered', null, 'autocomplete.log', true);
|
105 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.8.8-3.0.0.0.php
CHANGED
@@ -1,37 +1,37 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
5 |
-
$row = false;
|
6 |
-
$installer->startSetup();
|
7 |
-
|
8 |
-
$tableExists = false;
|
9 |
-
$tableName = $installer->getTable('autocompleteplus_autosuggest/config');
|
10 |
-
|
11 |
-
if (method_exists($installer->getConnection(), 'isTableExists')) {
|
12 |
-
$tableExists = $installer->getConnection()->isTableExists($tableName);
|
13 |
-
} else {
|
14 |
-
$tableExists = $installer->tableExists($tableName);
|
15 |
-
}
|
16 |
-
if ($tableExists) {
|
17 |
-
$select = $installer->getConnection()->select()
|
18 |
-
->from(array('config' => $tableName));
|
19 |
-
$row = $installer->getConnection()->fetchAll($select);
|
20 |
-
|
21 |
-
if (method_exists($installer->getConnection(), 'dropTable')) {
|
22 |
-
$installer->getConnection()->dropTable($tableName);
|
23 |
-
} else {
|
24 |
-
$installer->run("DROP TABLE IF EXISTS {$tableName};");
|
25 |
-
}
|
26 |
-
}
|
27 |
-
|
28 |
-
if ($row && isset($row[0]['licensekey']) && isset($row[0]['authkey'])) {
|
29 |
-
$config->generateConfig($row[0]['licensekey'], $row[0]['authkey']);
|
30 |
-
} else {
|
31 |
-
$config->generateConfig();
|
32 |
-
}
|
33 |
-
|
34 |
-
Mage::app()->getCacheInstance()->cleanType('config');
|
35 |
-
|
36 |
-
Mage::log(__FILE__ . ' triggered', null, 'autocomplete.log', true);
|
37 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
5 |
+
$row = false;
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
$tableExists = false;
|
9 |
+
$tableName = $installer->getTable('autocompleteplus_autosuggest/config');
|
10 |
+
|
11 |
+
if (method_exists($installer->getConnection(), 'isTableExists')) {
|
12 |
+
$tableExists = $installer->getConnection()->isTableExists($tableName);
|
13 |
+
} else {
|
14 |
+
$tableExists = $installer->tableExists($tableName);
|
15 |
+
}
|
16 |
+
if ($tableExists) {
|
17 |
+
$select = $installer->getConnection()->select()
|
18 |
+
->from(array('config' => $tableName));
|
19 |
+
$row = $installer->getConnection()->fetchAll($select);
|
20 |
+
|
21 |
+
if (method_exists($installer->getConnection(), 'dropTable')) {
|
22 |
+
$installer->getConnection()->dropTable($tableName);
|
23 |
+
} else {
|
24 |
+
$installer->run("DROP TABLE IF EXISTS {$tableName};");
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
if ($row && isset($row[0]['licensekey']) && isset($row[0]['authkey'])) {
|
29 |
+
$config->generateConfig($row[0]['licensekey'], $row[0]['authkey']);
|
30 |
+
} else {
|
31 |
+
$config->generateConfig();
|
32 |
+
}
|
33 |
+
|
34 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
35 |
+
|
36 |
+
Mage::log(__FILE__ . ' triggered', null, 'autocomplete.log', true);
|
37 |
+
$installer->endSetup();
|
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-3.0.0.4-3.0.0.5.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
$installer->startSetup();
|
5 |
-
|
6 |
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/autocompleteplus.xml
CHANGED
@@ -1,38 +1,38 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<layout>
|
3 |
-
<default>
|
4 |
-
<reference name="notifications">
|
5 |
-
<block type="autocompleteplus_autosuggest/notifications" name="autocompleteplus_notifications" template="autocompleteplus/notifications.phtml"></block>
|
6 |
-
</reference>
|
7 |
-
<reference name="before_body_end">
|
8 |
-
<block type="core/text" name="instantsearch.adminLinks">
|
9 |
-
<action method="setText">
|
10 |
-
<text>
|
11 |
-
<![CDATA[
|
12 |
-
<script type="text/javascript">
|
13 |
-
document.observe('dom:loaded', function() {$('nav').select('li.level0').each(function(l, ind) {
|
14 |
-
if (l.innerHTML.indexOf('InstantSearch+') >= 0) {
|
15 |
-
l.select('a').first().writeAttribute('target', '_blank');
|
16 |
-
}});
|
17 |
-
});
|
18 |
-
</script>
|
19 |
-
]]>
|
20 |
-
</text>
|
21 |
-
</action>
|
22 |
-
</block>
|
23 |
-
</reference>
|
24 |
-
</default>
|
25 |
-
<adminhtml_autocompleteplus_push_startpush>
|
26 |
-
<remove name="root"/>
|
27 |
-
<block type="adminhtml/page" name="convert_root" output="toHtml" template="page.phtml">
|
28 |
-
<block type="adminhtml/page_head" name="convert_root_head" as="head" template="page/head.phtml">
|
29 |
-
<action method="addJs"><script>prototype/prototype.js</script></action>
|
30 |
-
<action method="addJs"><script>prototype/validation.js</script></action>
|
31 |
-
<action method="addJs"><script>varien/js.js</script></action>
|
32 |
-
<action method="addJs"><script>mage/translate.js</script></action>
|
33 |
-
<action method="addJs"><script>mage/adminhtml/tools.js</script></action>
|
34 |
-
</block>
|
35 |
-
<block type="autocompleteplus_autosuggest/adminhtml_process" name="autocompleteplus_autosuggest_adminhtml_process" template="autocompleteplus/process.phtml" output="toHtml"/>
|
36 |
-
</block>
|
37 |
-
</adminhtml_autocompleteplus_push_startpush>
|
38 |
</layout>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
<default>
|
4 |
+
<reference name="notifications">
|
5 |
+
<block type="autocompleteplus_autosuggest/notifications" name="autocompleteplus_notifications" template="autocompleteplus/notifications.phtml"></block>
|
6 |
+
</reference>
|
7 |
+
<reference name="before_body_end">
|
8 |
+
<block type="core/text" name="instantsearch.adminLinks">
|
9 |
+
<action method="setText">
|
10 |
+
<text>
|
11 |
+
<![CDATA[
|
12 |
+
<script type="text/javascript">
|
13 |
+
document.observe('dom:loaded', function() {$('nav').select('li.level0').each(function(l, ind) {
|
14 |
+
if (l.innerHTML.indexOf('InstantSearch+') >= 0) {
|
15 |
+
l.select('a').first().writeAttribute('target', '_blank');
|
16 |
+
}});
|
17 |
+
});
|
18 |
+
</script>
|
19 |
+
]]>
|
20 |
+
</text>
|
21 |
+
</action>
|
22 |
+
</block>
|
23 |
+
</reference>
|
24 |
+
</default>
|
25 |
+
<adminhtml_autocompleteplus_push_startpush>
|
26 |
+
<remove name="root"/>
|
27 |
+
<block type="adminhtml/page" name="convert_root" output="toHtml" template="page.phtml">
|
28 |
+
<block type="adminhtml/page_head" name="convert_root_head" as="head" template="page/head.phtml">
|
29 |
+
<action method="addJs"><script>prototype/prototype.js</script></action>
|
30 |
+
<action method="addJs"><script>prototype/validation.js</script></action>
|
31 |
+
<action method="addJs"><script>varien/js.js</script></action>
|
32 |
+
<action method="addJs"><script>mage/translate.js</script></action>
|
33 |
+
<action method="addJs"><script>mage/adminhtml/tools.js</script></action>
|
34 |
+
</block>
|
35 |
+
<block type="autocompleteplus_autosuggest/adminhtml_process" name="autocompleteplus_autosuggest_adminhtml_process" template="autocompleteplus/process.phtml" output="toHtml"/>
|
36 |
+
</block>
|
37 |
+
</adminhtml_autocompleteplus_push_startpush>
|
38 |
</layout>
|
app/design/adminhtml/default/default/template/autocompleteplus/notifications.phtml
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
<?php
|
2 |
-
$shouldSync=$this->localhostSynced();
|
3 |
-
|
4 |
-
if($shouldSync){
|
5 |
-
?>
|
6 |
-
<div id="autosuggest-notification" class="notification-global">
|
7 |
-
<a target="_blank" href="<?php echo Mage::helper('adminhtml')->getUrl('adminhtml/autocompleteplus_push/startpush');?>">
|
8 |
-
<b><?php echo $this->__('Sync now'); ?></b>
|
9 |
-
</a>
|
10 |
-
<?php echo $this->__(' to complete the initial <strong>InstantSearch+</strong> product synchronization with our cloud service') ?>.
|
11 |
-
</div>
|
12 |
-
<?php
|
13 |
-
}
|
14 |
?>
|
1 |
+
<?php
|
2 |
+
$shouldSync=$this->localhostSynced();
|
3 |
+
|
4 |
+
if($shouldSync){
|
5 |
+
?>
|
6 |
+
<div id="autosuggest-notification" class="notification-global">
|
7 |
+
<a target="_blank" href="<?php echo Mage::helper('adminhtml')->getUrl('adminhtml/autocompleteplus_push/startpush');?>">
|
8 |
+
<b><?php echo $this->__('Sync now'); ?></b>
|
9 |
+
</a>
|
10 |
+
<?php echo $this->__(' to complete the initial <strong>InstantSearch+</strong> product synchronization with our cloud service') ?>.
|
11 |
+
</div>
|
12 |
+
<?php
|
13 |
+
}
|
14 |
?>
|
app/design/adminhtml/default/default/template/autocompleteplus/process.phtml
CHANGED
@@ -1,137 +1,137 @@
|
|
1 |
-
<?php
|
2 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
3 |
-
$pushId = $helper->getPushId();
|
4 |
-
$totalPushes = Mage::getModel('autocompleteplus_autosuggest/pusher')->getCollection()->getSize();
|
5 |
-
$pushUrl = '';
|
6 |
-
$updateUrl = '';
|
7 |
-
|
8 |
-
if ($pushId != '') {
|
9 |
-
$pushUrl = $helper->getPushUrl($pushId);
|
10 |
-
}
|
11 |
-
?>
|
12 |
-
<style type="text/css">
|
13 |
-
ul { list-style-type:none; padding:0; margin:0; }
|
14 |
-
li { margin-left:0; border:1px solid #ccc; margin:2px; padding:2px 2px 2px 2px; font:normal 12px sans-serif; }
|
15 |
-
img { margin-right:5px; }
|
16 |
-
</style>
|
17 |
-
<ul>
|
18 |
-
<li>
|
19 |
-
<img src="<?php echo $this->getSkinUrl('images/note_msg_icon.gif');?>" class="v-middle" style="margin-right:5px"/>
|
20 |
-
<?php echo $this->__('Starting initial store product sync with InstantSearch+'); ?>
|
21 |
-
</li>
|
22 |
-
|
23 |
-
<li style="background-color:#FFD;">
|
24 |
-
<img src="<?php echo $this->getSkinUrl('images/fam_bullet_error.gif'); ?>" class="v-middle" style="margin-right:5px"/>
|
25 |
-
<?php echo $this->__('Warning: Please do not close this tab until sync is complete'); ?>
|
26 |
-
</li>
|
27 |
-
|
28 |
-
<li id="liFinished" style="display:none;">
|
29 |
-
<img src="<?php echo $this->getSkinUrl('images/note_msg_icon.gif'); ?>" class="v-middle" style="margin-right:5px"/>
|
30 |
-
<?php echo $this->__(' Initial Product Sync is finished. '); ?>
|
31 |
-
<span id="liFinished_count">0</span> <?php echo $this->__('products were synced'); ?>
|
32 |
-
</li>
|
33 |
-
</ul>
|
34 |
-
|
35 |
-
<script type="text/javascript">
|
36 |
-
var config = <?php echo Mage::helper('core')->jsonEncode($this->_pushConfig); ?>;
|
37 |
-
config.tpl = new Template(config.template);
|
38 |
-
config.tplTxt = new Template(config.text);
|
39 |
-
config.tplSccTxt = new Template(config.successText);
|
40 |
-
|
41 |
-
var url= "<?php echo $pushUrl; ?>";
|
42 |
-
var updateUrl = "<?php echo $updateUrl; ?>";
|
43 |
-
|
44 |
-
var count=0;
|
45 |
-
|
46 |
-
if(url!=""){
|
47 |
-
sendImportData(url);
|
48 |
-
}else{
|
49 |
-
$("liFinished").show();
|
50 |
-
$("liFinished_count").update(count);
|
51 |
-
$("synced-rows").hide()
|
52 |
-
}
|
53 |
-
|
54 |
-
function sendImportData(url) {
|
55 |
-
|
56 |
-
if (!$("updatedRows")) {
|
57 |
-
Element.insert($("liFinished"), {
|
58 |
-
before: config.tpl.evaluate({
|
59 |
-
style: "background-color: #FFD;",
|
60 |
-
image: config.styles.loader,
|
61 |
-
text: "<?php echo $this->__('Syncing: push %s/%s', $pushId, $totalPushes); ?>",
|
62 |
-
id: "updatedRows"
|
63 |
-
})
|
64 |
-
});
|
65 |
-
}
|
66 |
-
|
67 |
-
new Ajax.Request(url, {
|
68 |
-
method: "get",
|
69 |
-
onSuccess: function(transport) {
|
70 |
-
|
71 |
-
if (transport.responseText.isJSON()) {
|
72 |
-
var res=transport.responseText.evalJSON();
|
73 |
-
|
74 |
-
if(!res){
|
75 |
-
Element.insert($("updatedRows"), {
|
76 |
-
before: config.tpl.evaluate({
|
77 |
-
style: "background-color:"+config.styles.error.bg,
|
78 |
-
image: config.styles.error.icon,
|
79 |
-
text: res.message,
|
80 |
-
id: "error-"+makeid()
|
81 |
-
})
|
82 |
-
});
|
83 |
-
|
84 |
-
} else {
|
85 |
-
|
86 |
-
if (!$("synced-rows")){
|
87 |
-
Element.insert($("updatedRows"), {
|
88 |
-
before: config.tpl.evaluate({
|
89 |
-
style: "background-color:"+config.styles.message.bg,
|
90 |
-
image: config.styles.message.icon,
|
91 |
-
text: res.updatedSuccessStatus,
|
92 |
-
id: "synced-rows"
|
93 |
-
})});
|
94 |
-
}else{
|
95 |
-
$("synced-rows_status").update(res.updatedSuccessStatus);
|
96 |
-
}
|
97 |
-
|
98 |
-
url=res.nextPushUrl;
|
99 |
-
|
100 |
-
count+=res.count;
|
101 |
-
|
102 |
-
if(url!=""){
|
103 |
-
$("updatedRows_status").update(res.updatedStatus);
|
104 |
-
sendImportData(url);
|
105 |
-
}else{
|
106 |
-
$("liFinished").show();
|
107 |
-
$("liFinished_count").update(count);
|
108 |
-
$("updatedRows").hide()
|
109 |
-
$("synced-rows").hide()
|
110 |
-
}
|
111 |
-
|
112 |
-
}
|
113 |
-
} else {
|
114 |
-
Element.insert($("updatedRows"), {
|
115 |
-
before: config.tpl.evaluate({
|
116 |
-
style: "background-color:"+config.styles.error.bg,
|
117 |
-
image: config.styles.error.icon,
|
118 |
-
text: transport.responseText.escapeHTML(),
|
119 |
-
id: "error-"+makeid()
|
120 |
-
})
|
121 |
-
});
|
122 |
-
}
|
123 |
-
}
|
124 |
-
});
|
125 |
-
}
|
126 |
-
|
127 |
-
function makeid()
|
128 |
-
{
|
129 |
-
var text = "";
|
130 |
-
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
131 |
-
|
132 |
-
for( var i=0; i < 5; i++ )
|
133 |
-
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
134 |
-
|
135 |
-
return text;
|
136 |
-
}
|
137 |
</script>
|
1 |
+
<?php
|
2 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
3 |
+
$pushId = $helper->getPushId();
|
4 |
+
$totalPushes = Mage::getModel('autocompleteplus_autosuggest/pusher')->getCollection()->getSize();
|
5 |
+
$pushUrl = '';
|
6 |
+
$updateUrl = '';
|
7 |
+
|
8 |
+
if ($pushId != '') {
|
9 |
+
$pushUrl = $helper->getPushUrl($pushId);
|
10 |
+
}
|
11 |
+
?>
|
12 |
+
<style type="text/css">
|
13 |
+
ul { list-style-type:none; padding:0; margin:0; }
|
14 |
+
li { margin-left:0; border:1px solid #ccc; margin:2px; padding:2px 2px 2px 2px; font:normal 12px sans-serif; }
|
15 |
+
img { margin-right:5px; }
|
16 |
+
</style>
|
17 |
+
<ul>
|
18 |
+
<li>
|
19 |
+
<img src="<?php echo $this->getSkinUrl('images/note_msg_icon.gif');?>" class="v-middle" style="margin-right:5px"/>
|
20 |
+
<?php echo $this->__('Starting initial store product sync with InstantSearch+'); ?>
|
21 |
+
</li>
|
22 |
+
|
23 |
+
<li style="background-color:#FFD;">
|
24 |
+
<img src="<?php echo $this->getSkinUrl('images/fam_bullet_error.gif'); ?>" class="v-middle" style="margin-right:5px"/>
|
25 |
+
<?php echo $this->__('Warning: Please do not close this tab until sync is complete'); ?>
|
26 |
+
</li>
|
27 |
+
|
28 |
+
<li id="liFinished" style="display:none;">
|
29 |
+
<img src="<?php echo $this->getSkinUrl('images/note_msg_icon.gif'); ?>" class="v-middle" style="margin-right:5px"/>
|
30 |
+
<?php echo $this->__(' Initial Product Sync is finished. '); ?>
|
31 |
+
<span id="liFinished_count">0</span> <?php echo $this->__('products were synced'); ?>
|
32 |
+
</li>
|
33 |
+
</ul>
|
34 |
+
|
35 |
+
<script type="text/javascript">
|
36 |
+
var config = <?php echo Mage::helper('core')->jsonEncode($this->_pushConfig); ?>;
|
37 |
+
config.tpl = new Template(config.template);
|
38 |
+
config.tplTxt = new Template(config.text);
|
39 |
+
config.tplSccTxt = new Template(config.successText);
|
40 |
+
|
41 |
+
var url= "<?php echo $pushUrl; ?>";
|
42 |
+
var updateUrl = "<?php echo $updateUrl; ?>";
|
43 |
+
|
44 |
+
var count=0;
|
45 |
+
|
46 |
+
if(url!=""){
|
47 |
+
sendImportData(url);
|
48 |
+
}else{
|
49 |
+
$("liFinished").show();
|
50 |
+
$("liFinished_count").update(count);
|
51 |
+
$("synced-rows").hide()
|
52 |
+
}
|
53 |
+
|
54 |
+
function sendImportData(url) {
|
55 |
+
|
56 |
+
if (!$("updatedRows")) {
|
57 |
+
Element.insert($("liFinished"), {
|
58 |
+
before: config.tpl.evaluate({
|
59 |
+
style: "background-color: #FFD;",
|
60 |
+
image: config.styles.loader,
|
61 |
+
text: "<?php echo $this->__('Syncing: push %s/%s', $pushId, $totalPushes); ?>",
|
62 |
+
id: "updatedRows"
|
63 |
+
})
|
64 |
+
});
|
65 |
+
}
|
66 |
+
|
67 |
+
new Ajax.Request(url, {
|
68 |
+
method: "get",
|
69 |
+
onSuccess: function(transport) {
|
70 |
+
|
71 |
+
if (transport.responseText.isJSON()) {
|
72 |
+
var res=transport.responseText.evalJSON();
|
73 |
+
|
74 |
+
if(!res){
|
75 |
+
Element.insert($("updatedRows"), {
|
76 |
+
before: config.tpl.evaluate({
|
77 |
+
style: "background-color:"+config.styles.error.bg,
|
78 |
+
image: config.styles.error.icon,
|
79 |
+
text: res.message,
|
80 |
+
id: "error-"+makeid()
|
81 |
+
})
|
82 |
+
});
|
83 |
+
|
84 |
+
} else {
|
85 |
+
|
86 |
+
if (!$("synced-rows")){
|
87 |
+
Element.insert($("updatedRows"), {
|
88 |
+
before: config.tpl.evaluate({
|
89 |
+
style: "background-color:"+config.styles.message.bg,
|
90 |
+
image: config.styles.message.icon,
|
91 |
+
text: res.updatedSuccessStatus,
|
92 |
+
id: "synced-rows"
|
93 |
+
})});
|
94 |
+
}else{
|
95 |
+
$("synced-rows_status").update(res.updatedSuccessStatus);
|
96 |
+
}
|
97 |
+
|
98 |
+
url=res.nextPushUrl;
|
99 |
+
|
100 |
+
count+=res.count;
|
101 |
+
|
102 |
+
if(url!=""){
|
103 |
+
$("updatedRows_status").update(res.updatedStatus);
|
104 |
+
sendImportData(url);
|
105 |
+
}else{
|
106 |
+
$("liFinished").show();
|
107 |
+
$("liFinished_count").update(count);
|
108 |
+
$("updatedRows").hide()
|
109 |
+
$("synced-rows").hide()
|
110 |
+
}
|
111 |
+
|
112 |
+
}
|
113 |
+
} else {
|
114 |
+
Element.insert($("updatedRows"), {
|
115 |
+
before: config.tpl.evaluate({
|
116 |
+
style: "background-color:"+config.styles.error.bg,
|
117 |
+
image: config.styles.error.icon,
|
118 |
+
text: transport.responseText.escapeHTML(),
|
119 |
+
id: "error-"+makeid()
|
120 |
+
})
|
121 |
+
});
|
122 |
+
}
|
123 |
+
}
|
124 |
+
});
|
125 |
+
}
|
126 |
+
|
127 |
+
function makeid()
|
128 |
+
{
|
129 |
+
var text = "";
|
130 |
+
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
131 |
+
|
132 |
+
for( var i=0; i < 5; i++ )
|
133 |
+
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
134 |
+
|
135 |
+
return text;
|
136 |
+
}
|
137 |
</script>
|
app/design/adminhtml/default/default/template/autocompleteplus/system/config/button.phtml
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
-
<script type="text/javascript">
|
2 |
-
//<![CDATA[
|
3 |
-
function updateautocomplete() {
|
4 |
-
var email = $('autocompleteplus_config_store_email').value || ='no@email.com';
|
5 |
-
|
6 |
-
new Ajax.Request('<?php echo $this->getAjaxCheckUrl() ?>', {
|
7 |
-
method: 'post',
|
8 |
-
parameters: { email: email },
|
9 |
-
onSuccess: function( transport ) {
|
10 |
-
if (transport.responseText){
|
11 |
-
alert(transport.responseText);
|
12 |
-
configForm.submit();
|
13 |
-
}
|
14 |
-
}
|
15 |
-
});
|
16 |
-
}
|
17 |
-
//]]>
|
18 |
-
</script>
|
19 |
-
|
20 |
<?php echo $this->getButtonHtml() ?>
|
1 |
+
<script type="text/javascript">
|
2 |
+
//<![CDATA[
|
3 |
+
function updateautocomplete() {
|
4 |
+
var email = $('autocompleteplus_config_store_email').value || ='no@email.com';
|
5 |
+
|
6 |
+
new Ajax.Request('<?php echo $this->getAjaxCheckUrl() ?>', {
|
7 |
+
method: 'post',
|
8 |
+
parameters: { email: email },
|
9 |
+
onSuccess: function( transport ) {
|
10 |
+
if (transport.responseText){
|
11 |
+
alert(transport.responseText);
|
12 |
+
configForm.submit();
|
13 |
+
}
|
14 |
+
}
|
15 |
+
});
|
16 |
+
}
|
17 |
+
//]]>
|
18 |
+
</script>
|
19 |
+
|
20 |
<?php echo $this->getButtonHtml() ?>
|
app/design/adminhtml/default/default/template/autocompleteplus/system/config/sync.phtml
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
-
<script type="text/javascript">
|
2 |
-
//<![CDATA[
|
3 |
-
function syncautocomplete() {
|
4 |
-
|
5 |
-
var url='<?php echo $this->getSyncUrl(); ?>';
|
6 |
-
|
7 |
-
window.open(url);
|
8 |
-
}
|
9 |
-
//]]>
|
10 |
-
</script>
|
11 |
-
<?php
|
12 |
-
|
13 |
-
if($this->getIsReachable()==0){
|
14 |
-
echo $this->getButtonHtml();
|
15 |
-
}else{
|
16 |
-
echo
|
17 |
-
'<style>
|
18 |
-
#row_autocompleteplus_config_sync{display: none}
|
19 |
-
</style>';
|
20 |
-
}
|
21 |
?>
|
1 |
+
<script type="text/javascript">
|
2 |
+
//<![CDATA[
|
3 |
+
function syncautocomplete() {
|
4 |
+
|
5 |
+
var url='<?php echo $this->getSyncUrl(); ?>';
|
6 |
+
|
7 |
+
window.open(url);
|
8 |
+
}
|
9 |
+
//]]>
|
10 |
+
</script>
|
11 |
+
<?php
|
12 |
+
|
13 |
+
if($this->getIsReachable()==0){
|
14 |
+
echo $this->getButtonHtml();
|
15 |
+
}else{
|
16 |
+
echo
|
17 |
+
'<style>
|
18 |
+
#row_autocompleteplus_config_sync{display: none}
|
19 |
+
</style>';
|
20 |
+
}
|
21 |
?>
|
app/design/frontend/base/default/layout/autocompleteplus.xml
CHANGED
@@ -1,40 +1,40 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<layout version="0.1.0">
|
3 |
-
<default>
|
4 |
-
<reference name="head">
|
5 |
-
<block name="inject" template="autocompleteplus/inject.phtml" type="autocompleteplus_autosuggest/inject"/>
|
6 |
-
<block type="autocompleteplus_autosuggest/autocomplete" />
|
7 |
-
</reference>
|
8 |
-
</default>
|
9 |
-
<autocompleteplus>
|
10 |
-
<reference name="catalogsearch.leftnav">
|
11 |
-
<action method="setTemplate" ifconfig="autocompleteplus/config/layered">
|
12 |
-
<value>autocompleteplus/catalog/layer/view.phtml</value>
|
13 |
-
</action>
|
14 |
-
</reference>
|
15 |
-
<reference name="search_result_list">
|
16 |
-
<action method="setTemplate" ifconfig="autocompleteplus/config/layered">
|
17 |
-
<value>autocompleteplus/catalog/product/list.phtml</value>
|
18 |
-
</action>
|
19 |
-
</reference>
|
20 |
-
</autocompleteplus>
|
21 |
-
<catalogsearch_result_index>
|
22 |
-
<update handle="autocompleteplus"/>
|
23 |
-
</catalogsearch_result_index>
|
24 |
-
<autocompleteplus_result_index>
|
25 |
-
<update handle="autocompleteplus"/>
|
26 |
-
<remove name="search.result"/>
|
27 |
-
<remove name="left"/>
|
28 |
-
<reference name="content">
|
29 |
-
<block type="core/template" name="search_result_list" template="autocompleteplus/catalog/product/list.phtml"/>
|
30 |
-
</reference>
|
31 |
-
</autocompleteplus_result_index>
|
32 |
-
<instantsearchplus_result_index>
|
33 |
-
<update handle="autocompleteplus"/>
|
34 |
-
<remove name="search.result"/>
|
35 |
-
<remove name="left"/>
|
36 |
-
<reference name="content">
|
37 |
-
<block type="core/template" name="search_result_list" template="autocompleteplus/catalog/product/list.phtml"/>
|
38 |
-
</reference>
|
39 |
-
</instantsearchplus_result_index>
|
40 |
</layout>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
<reference name="head">
|
5 |
+
<block name="inject" template="autocompleteplus/inject.phtml" type="autocompleteplus_autosuggest/inject"/>
|
6 |
+
<block type="autocompleteplus_autosuggest/autocomplete" />
|
7 |
+
</reference>
|
8 |
+
</default>
|
9 |
+
<autocompleteplus>
|
10 |
+
<reference name="catalogsearch.leftnav">
|
11 |
+
<action method="setTemplate" ifconfig="autocompleteplus/config/layered">
|
12 |
+
<value>autocompleteplus/catalog/layer/view.phtml</value>
|
13 |
+
</action>
|
14 |
+
</reference>
|
15 |
+
<reference name="search_result_list">
|
16 |
+
<action method="setTemplate" ifconfig="autocompleteplus/config/layered">
|
17 |
+
<value>autocompleteplus/catalog/product/list.phtml</value>
|
18 |
+
</action>
|
19 |
+
</reference>
|
20 |
+
</autocompleteplus>
|
21 |
+
<catalogsearch_result_index>
|
22 |
+
<update handle="autocompleteplus"/>
|
23 |
+
</catalogsearch_result_index>
|
24 |
+
<autocompleteplus_result_index>
|
25 |
+
<update handle="autocompleteplus"/>
|
26 |
+
<remove name="search.result"/>
|
27 |
+
<remove name="left"/>
|
28 |
+
<reference name="content">
|
29 |
+
<block type="core/template" name="search_result_list" template="autocompleteplus/catalog/product/list.phtml"/>
|
30 |
+
</reference>
|
31 |
+
</autocompleteplus_result_index>
|
32 |
+
<instantsearchplus_result_index>
|
33 |
+
<update handle="autocompleteplus"/>
|
34 |
+
<remove name="search.result"/>
|
35 |
+
<remove name="left"/>
|
36 |
+
<reference name="content">
|
37 |
+
<block type="core/template" name="search_result_list" template="autocompleteplus/catalog/product/list.phtml"/>
|
38 |
+
</reference>
|
39 |
+
</instantsearchplus_result_index>
|
40 |
</layout>
|
app/design/frontend/base/default/template/autocompleteplus/catalog/layer/view.phtml
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
|
2 |
-
<div id="isp_search_result_layered_navigation"></div>
|
3 |
-
|
1 |
+
|
2 |
+
<div id="isp_search_result_layered_navigation"></div>
|
3 |
+
|
app/design/frontend/base/default/template/autocompleteplus/catalog/product/list.phtml
CHANGED
@@ -1,48 +1,48 @@
|
|
1 |
-
<?php
|
2 |
-
$store_id = Mage::app()->getStore()->getStoreId();
|
3 |
-
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
4 |
-
$uuid = $config->getUUID();
|
5 |
-
$query = htmlentities(Mage::app()->getRequest()->getParam('q'), ENT_QUOTES);
|
6 |
-
$match_value = '';
|
7 |
-
|
8 |
-
try{
|
9 |
-
$formkey_html = $this->getBlockHtml('formkey'); // '<input name="form_key" type="hidden" value="E3rpphc1BL6zyTB3" />'
|
10 |
-
$pattern = '/.*form_key.*value=\"([^\"]+)\"/s';
|
11 |
-
if (preg_match($pattern, $formkey_html, $match)){
|
12 |
-
if ($match){
|
13 |
-
$match_value = $match[1];
|
14 |
-
}
|
15 |
-
}
|
16 |
-
} catch (Exception $e){
|
17 |
-
Mage::logException($e);
|
18 |
-
}
|
19 |
-
|
20 |
-
?>
|
21 |
-
<!-- <div id="isp_search_result_page"></div> -->
|
22 |
-
|
23 |
-
<script>
|
24 |
-
var __isp_fulltext_search_obj = {
|
25 |
-
uuid: "<?php echo $this->escapeHtml($config->getUUID()); ?>",
|
26 |
-
store_id: <?php echo $this->escapeHtml($store_id); ?>,
|
27 |
-
query: "<?php echo $this->escapeHtml($query); ?>",
|
28 |
-
formkey: "<?php echo $this->escapeHtml($match_value); ?>"
|
29 |
-
};
|
30 |
-
</script>
|
31 |
-
<?php
|
32 |
-
$helper = Mage::helper('autocompleteplus_autosuggest');
|
33 |
-
|
34 |
-
$html=Mage::app()->getCacheInstance()->load('autocomplete_template_serp');
|
35 |
-
|
36 |
-
if(!$html) {
|
37 |
-
$server_url = $helper->getServerUrl();
|
38 |
-
$url = $server_url . '/ma_load_search_page?isp_platform=magento&r=002';
|
39 |
-
$resp = $helper->sendCurl($url);
|
40 |
-
$response_json = json_decode($resp);
|
41 |
-
$html = $response_json->html;
|
42 |
-
|
43 |
-
Mage::app()->getCacheInstance()->save($html, 'autocomplete_template_serp', array("autocomplete_cache"), 60);
|
44 |
-
|
45 |
-
}
|
46 |
-
|
47 |
-
echo $html;
|
48 |
?>
|
1 |
+
<?php
|
2 |
+
$store_id = Mage::app()->getStore()->getStoreId();
|
3 |
+
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
4 |
+
$uuid = $config->getUUID();
|
5 |
+
$query = htmlentities(Mage::app()->getRequest()->getParam('q'), ENT_QUOTES);
|
6 |
+
$match_value = '';
|
7 |
+
|
8 |
+
try{
|
9 |
+
$formkey_html = $this->getBlockHtml('formkey'); // '<input name="form_key" type="hidden" value="E3rpphc1BL6zyTB3" />'
|
10 |
+
$pattern = '/.*form_key.*value=\"([^\"]+)\"/s';
|
11 |
+
if (preg_match($pattern, $formkey_html, $match)){
|
12 |
+
if ($match){
|
13 |
+
$match_value = $match[1];
|
14 |
+
}
|
15 |
+
}
|
16 |
+
} catch (Exception $e){
|
17 |
+
Mage::logException($e);
|
18 |
+
}
|
19 |
+
|
20 |
+
?>
|
21 |
+
<!-- <div id="isp_search_result_page"></div> -->
|
22 |
+
|
23 |
+
<script>
|
24 |
+
var __isp_fulltext_search_obj = {
|
25 |
+
uuid: "<?php echo $this->escapeHtml($config->getUUID()); ?>",
|
26 |
+
store_id: <?php echo $this->escapeHtml($store_id); ?>,
|
27 |
+
query: "<?php echo $this->escapeHtml($query); ?>",
|
28 |
+
formkey: "<?php echo $this->escapeHtml($match_value); ?>"
|
29 |
+
};
|
30 |
+
</script>
|
31 |
+
<?php
|
32 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
33 |
+
|
34 |
+
$html=Mage::app()->getCacheInstance()->load('autocomplete_template_serp');
|
35 |
+
|
36 |
+
if(!$html) {
|
37 |
+
$server_url = $helper->getServerUrl();
|
38 |
+
$url = $server_url . '/ma_load_search_page?isp_platform=magento&r=002&uuid=' . $config->getUUID() . '&store_id=' . $store_id;
|
39 |
+
$resp = $helper->sendCurl($url);
|
40 |
+
$response_json = json_decode($resp);
|
41 |
+
$html = $response_json->html;
|
42 |
+
|
43 |
+
Mage::app()->getCacheInstance()->save($html, 'autocomplete_template_serp', array("autocomplete_cache"), 60);
|
44 |
+
|
45 |
+
}
|
46 |
+
|
47 |
+
echo $html;
|
48 |
?>
|
app/design/frontend/base/default/template/autocompleteplus/inject.phtml
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
<?php if (Mage::getStoreConfigFlag('autocompleteplus/config/enabled')): ?>
|
2 |
-
<script data-cfasync="false" async type="text/javascript" src="<?php echo $this->getSrc()?>"></script>
|
3 |
<?php endif; ?>
|
1 |
+
<?php if (Mage::getStoreConfigFlag('autocompleteplus/config/enabled')): ?>
|
2 |
+
<script data-cfasync="false" async type="text/javascript" src="<?php echo $this->getSrc()?>"></script>
|
3 |
<?php endif; ?>
|
app/etc/modules/Autocompleteplus_Autosuggest.xml
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<config>
|
3 |
-
<modules>
|
4 |
-
<Autocompleteplus_Autosuggest>
|
5 |
-
<active>true</active>
|
6 |
-
<codePool>local</codePool>
|
7 |
-
</Autocompleteplus_Autosuggest>
|
8 |
-
</modules>
|
9 |
</config>
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Autocompleteplus_Autosuggest>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Autocompleteplus_Autosuggest>
|
8 |
+
</modules>
|
9 |
</config>
|
lib/Autocompleteplus/Autosuggest/Xml/Generator.php
CHANGED
@@ -1,87 +1,87 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Autocompleteplus_Autosuggest_Xml_Generator implements Autocompleteplus_Autosuggest_Xml_GeneratorInterface
|
4 |
-
{
|
5 |
-
protected $_xml;
|
6 |
-
|
7 |
-
protected $_rootElementName;
|
8 |
-
|
9 |
-
protected $_rootAttributes;
|
10 |
-
|
11 |
-
public function getRootElementName() {
|
12 |
-
return $this->_rootElementName;
|
13 |
-
}
|
14 |
-
|
15 |
-
public function setRootElementName($name) {
|
16 |
-
$this->_rootElementName = $name;
|
17 |
-
return $this;
|
18 |
-
}
|
19 |
-
|
20 |
-
public function setRootAttributes($attributes)
|
21 |
-
{
|
22 |
-
$this->_rootAttributes = $attributes;
|
23 |
-
return $this;
|
24 |
-
}
|
25 |
-
|
26 |
-
public function getRootAttributes()
|
27 |
-
{
|
28 |
-
return $this->_rootAttributes;
|
29 |
-
}
|
30 |
-
|
31 |
-
public function getSimpleXml()
|
32 |
-
{
|
33 |
-
if (!$this->_xml) {
|
34 |
-
$rootElement = sprintf('<%s/>', $this->getRootElementName());
|
35 |
-
$this->_xml = new \SimpleXMLElement($rootElement);
|
36 |
-
|
37 |
-
$rootAttributes = $this->getRootAttributes();
|
38 |
-
|
39 |
-
if ($rootAttributes) {
|
40 |
-
foreach ($rootAttributes as $attrKey => $attrValue) {
|
41 |
-
$this->_xml->addAttribute($attrKey, $attrValue);
|
42 |
-
}
|
43 |
-
}
|
44 |
-
}
|
45 |
-
return $this->_xml;
|
46 |
-
}
|
47 |
-
|
48 |
-
public function generateXml() {
|
49 |
-
$domDocument = new \DOMDocument('1.0');
|
50 |
-
$domDocument->formatOutput = true;
|
51 |
-
$simpleXmlToDom = dom_import_simplexml($this->getSimpleXml());
|
52 |
-
|
53 |
-
$simpleXmlToDom = $domDocument->importNode($simpleXmlToDom, true);
|
54 |
-
$domDocument->appendChild($simpleXmlToDom);
|
55 |
-
|
56 |
-
$output = $domDocument->saveXML($domDocument, LIBXML_NOEMPTYTAG);
|
57 |
-
|
58 |
-
return $output;
|
59 |
-
}
|
60 |
-
|
61 |
-
public function createChild($childName, $childAttributes, $childValue = false, $parent = false) {
|
62 |
-
$xml = $this->getSimpleXml();
|
63 |
-
|
64 |
-
if ($parent !== false) {
|
65 |
-
$xml = $parent;
|
66 |
-
}
|
67 |
-
|
68 |
-
if ($childValue !== false) {
|
69 |
-
$child = $xml->addChild($childName);
|
70 |
-
if ($child !== NULL) {
|
71 |
-
$node = dom_import_simplexml($child);
|
72 |
-
$doc = $node->ownerDocument;
|
73 |
-
$node->appendChild($doc->createCDATASection($childValue));
|
74 |
-
}
|
75 |
-
} else {
|
76 |
-
$child = $xml->addChild($childName);
|
77 |
-
}
|
78 |
-
|
79 |
-
if (is_array($childAttributes)) {
|
80 |
-
foreach ($childAttributes as $key => $val) {
|
81 |
-
$child->addAttribute($key, $val);
|
82 |
-
}
|
83 |
-
}
|
84 |
-
|
85 |
-
return $child;
|
86 |
-
}
|
87 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Autocompleteplus_Autosuggest_Xml_Generator implements Autocompleteplus_Autosuggest_Xml_GeneratorInterface
|
4 |
+
{
|
5 |
+
protected $_xml;
|
6 |
+
|
7 |
+
protected $_rootElementName;
|
8 |
+
|
9 |
+
protected $_rootAttributes;
|
10 |
+
|
11 |
+
public function getRootElementName() {
|
12 |
+
return $this->_rootElementName;
|
13 |
+
}
|
14 |
+
|
15 |
+
public function setRootElementName($name) {
|
16 |
+
$this->_rootElementName = $name;
|
17 |
+
return $this;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function setRootAttributes($attributes)
|
21 |
+
{
|
22 |
+
$this->_rootAttributes = $attributes;
|
23 |
+
return $this;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getRootAttributes()
|
27 |
+
{
|
28 |
+
return $this->_rootAttributes;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getSimpleXml()
|
32 |
+
{
|
33 |
+
if (!$this->_xml) {
|
34 |
+
$rootElement = sprintf('<%s/>', $this->getRootElementName());
|
35 |
+
$this->_xml = new \SimpleXMLElement($rootElement);
|
36 |
+
|
37 |
+
$rootAttributes = $this->getRootAttributes();
|
38 |
+
|
39 |
+
if ($rootAttributes) {
|
40 |
+
foreach ($rootAttributes as $attrKey => $attrValue) {
|
41 |
+
$this->_xml->addAttribute($attrKey, $attrValue);
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}
|
45 |
+
return $this->_xml;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function generateXml() {
|
49 |
+
$domDocument = new \DOMDocument('1.0');
|
50 |
+
$domDocument->formatOutput = true;
|
51 |
+
$simpleXmlToDom = dom_import_simplexml($this->getSimpleXml());
|
52 |
+
|
53 |
+
$simpleXmlToDom = $domDocument->importNode($simpleXmlToDom, true);
|
54 |
+
$domDocument->appendChild($simpleXmlToDom);
|
55 |
+
|
56 |
+
$output = $domDocument->saveXML($domDocument, LIBXML_NOEMPTYTAG);
|
57 |
+
|
58 |
+
return $output;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function createChild($childName, $childAttributes, $childValue = false, $parent = false) {
|
62 |
+
$xml = $this->getSimpleXml();
|
63 |
+
|
64 |
+
if ($parent !== false) {
|
65 |
+
$xml = $parent;
|
66 |
+
}
|
67 |
+
|
68 |
+
if ($childValue !== false) {
|
69 |
+
$child = $xml->addChild($childName);
|
70 |
+
if ($child !== NULL) {
|
71 |
+
$node = dom_import_simplexml($child);
|
72 |
+
$doc = $node->ownerDocument;
|
73 |
+
$node->appendChild($doc->createCDATASection($childValue));
|
74 |
+
}
|
75 |
+
} else {
|
76 |
+
$child = $xml->addChild($childName);
|
77 |
+
}
|
78 |
+
|
79 |
+
if (is_array($childAttributes)) {
|
80 |
+
foreach ($childAttributes as $key => $val) {
|
81 |
+
$child->addAttribute($key, $val);
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
return $child;
|
86 |
+
}
|
87 |
}
|
lib/Autocompleteplus/Autosuggest/Xml/GeneratorInterface.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
interface Autocompleteplus_Autosuggest_Xml_GeneratorInterface
|
4 |
-
{
|
5 |
-
public function getSimpleXml();
|
6 |
-
|
7 |
-
public function getRootElementName();
|
8 |
-
|
9 |
-
public function setRootElementName($name);
|
10 |
-
|
11 |
-
public function generateXml();
|
12 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
interface Autocompleteplus_Autosuggest_Xml_GeneratorInterface
|
4 |
+
{
|
5 |
+
public function getSimpleXml();
|
6 |
+
|
7 |
+
public function getRootElementName();
|
8 |
+
|
9 |
+
public function setRootElementName($name);
|
10 |
+
|
11 |
+
public function generateXml();
|
12 |
}
|
package.xml
CHANGED
@@ -1,21 +1,19 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>autocompleteplus_autosuggest</name>
|
4 |
-
<version>3.0.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.autocompleteplus.com/privacy">AC+</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>AutoComplete+ InstantSearch</summary>
|
10 |
<description>AutoComplete+ InstantSearch triples visitor conversion, optimizes search, and offers promotions through state-of-the-art contextual suggestions dropdown. Since suggestions are lightning fast, accurate, and contextual - visitors find exactly what they want - faster.</description>
|
11 |
-
<notes>*
|
12 |
-
*
|
13 |
-
* missing search sku bug fix
|
14 |
-
* few more minor bugs fix</notes>
|
15 |
<authors><author><name>Adar</name><user>Adar</user><email>magento@autocompleteplus.com</email></author></authors>
|
16 |
-
<date>2016-
|
17 |
-
<time>
|
18 |
-
<contents><target name="magelocal"><dir name="Autocompleteplus"><dir name="Autosuggest"><dir name="Adminhtml"><dir name="Model"><file name="Attributes.php" hash="
|
19 |
<compatible/>
|
20 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
21 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>autocompleteplus_autosuggest</name>
|
4 |
+
<version>3.0.0.11</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.autocompleteplus.com/privacy">AC+</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>AutoComplete+ InstantSearch</summary>
|
10 |
<description>AutoComplete+ InstantSearch triples visitor conversion, optimizes search, and offers promotions through state-of-the-art contextual suggestions dropdown. Since suggestions are lightning fast, accurate, and contextual - visitors find exactly what they want - faster.</description>
|
11 |
+
<notes>* localhost missing ssl fix
|
12 |
+
* performance optimizations</notes>
|
|
|
|
|
13 |
<authors><author><name>Adar</name><user>Adar</user><email>magento@autocompleteplus.com</email></author></authors>
|
14 |
+
<date>2016-10-06</date>
|
15 |
+
<time>08:55:55</time>
|
16 |
+
<contents><target name="magelocal"><dir name="Autocompleteplus"><dir name="Autosuggest"><dir name="Adminhtml"><dir name="Model"><file name="Attributes.php" hash="97a5e1f05936c1f264e87879e233106e"/><file name="Button.php" hash="dcc2bb8d5c4d1956b92d76b6238f9645"/></dir></dir><dir name="Block"><dir name="Adminhtml"><file name="Button.php" hash="e9ffbadef9836d0a462dd6fb38a77ea2"/><file name="Process.php" hash="bfb4c87b561672df12247e0b78946bb1"/><file name="Sync.php" hash="eb15efd072207f569bc6f643b4bf3d16"/></dir><file name="Autocomplete.php" hash="76e9a77fe461ab4b224a3b3b4beaaf73"/><file name="Autocorrection.php" hash="0c493ca68ebab9f6d1503c669974af0a"/><file name="Inject.php" hash="83a165f87eac85fac3f48dce348ecc57"/><file name="Notifications.php" hash="6f41ba9d91b9b3e77350bc8ed09cfc8e"/></dir><dir name="Controller"><file name="Abstract.php" hash="0840025b76db4151681c120a44157cc9"/></dir><dir name="Helper"><file name="Data.php" hash="abf383c755efe023fabc32235ea86c26"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Attributes.php" hash="985eca64f07681afb331da05459b858c"/></dir><dir name="Api"><file name="V2.php" hash="25678058e22f86e4df900cd1b6248d08"/></dir><file name="Api.php" hash="d56bf879fd921a21c902da69eefcc1e0"/><file name="Batches.php" hash="cbcb39300e92a6fcf0137455b1abadc4"/><file name="Catalog.php" hash="d88858cd2db5e66ce557f5fb440d5611"/><file name="Catalogreport.php" hash="a3587900c62e9a7103153905add264a3"/><file name="Checksum.php" hash="574e3fa7632d99d664f85bf330a00a2a"/><file name="Config.php" hash="19f9828a5320e64b38e14e9e10827feb"/><file name="Layer.php" hash="b9071f27d04ae4dfeac1beb6c4d0a677"/><dir name="Mysql4"><dir name="Batches"><file name="Collection.php" hash="3cad224b07f2a8a34bb9cb60abc95a41"/></dir><file name="Batches.php" hash="8d1a43f2fd4369e8cf9f5a6a6197d563"/><dir name="Checksum"><file name="Collection.php" hash="b887944f0ab03653f000e00c4d21ad16"/></dir><file name="Checksum.php" hash="760ab40bbafd31b6944ce9c14b7b15e8"/><dir name="Fulltext"><file name="Collection.php" hash="af0852806988d0f96d6c1c7cfa2b9492"/></dir><dir name="Notifications"><file name="Collection.php" hash="f8abe40d33bc60f726cb327225df410b"/></dir><file name="Notifications.php" hash="a081dccecde1fc34ad898dde64e2f299"/><dir name="Pusher"><file name="Collection.php" hash="adb20bd9d870514af3e93e9bb963dc6d"/></dir><file name="Pusher.php" hash="ba5837cd7d2eca891e7bd7eea8711206"/></dir><file name="Notifications.php" hash="b06b24bfcadf86781316db136cb0beba"/><file name="Observer.php" hash="9e11248ed588a0da26049d3dd8c91e8f"/><file name="Pusher.php" hash="958e6fcede116b927734c7f26175d3fe"/><dir name="Renderer"><file name="Abstract.php" hash="e2b34472be5af56ea7169798ee726104"/><file name="Batches.php" hash="94b07816fbc25066656cea78dd9a618c"/><dir name="Catalog"><file name="Product.php" hash="b76de972fdb6b2b6741ea5a56db09442"/></dir></dir><dir name="Resource"><dir name="Batches"><file name="Collection.php" hash="566d6ca03a592fc6af839f64015864f9"/></dir><file name="Batches.php" hash="486601099e6c3d5acafedb2a494fdf53"/><dir name="Checksum"><file name="Collection.php" hash="532d0a67affac342520702dbe1bfcf2b"/></dir><file name="Checksum.php" hash="e7209f000caecadf49bfe76cfd1523f2"/><dir name="Fulltext"><file name="Collection.php" hash="952d3599ddc3c40279fc52d9bdb24f61"/></dir><dir name="Notifications"><file name="Collection.php" hash="c2f2b04a7aef986307187ad3f58b014f"/></dir><file name="Notifications.php" hash="e77b5b4651b37dcca8261a07142e1e2c"/><dir name="Pusher"><file name="Collection.php" hash="6abec498173b76b494e5b414f03895ea"/></dir><file name="Pusher.php" hash="95841d08cba60e33b0311dfb563eed64"/></dir><file name="Service.php" hash="d9a45335115b655524fce38d239859af"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Autocompleteplus"><file name="PushController.php" hash="158eb274edb766ff2d262754589f705d"/><file name="RedirectController.php" hash="6caaf09e28a7ab52037f6a970fe8a4e1"/></dir></dir><dir name="CatalogSearch"><file name="ResultController.php" hash="b3b6f8a2eda4834bb08af5452aae57a6"/></dir><file name="CatalogsearchController.php" hash="69cd8445623de0e6f8f04eadce83c0e5"/><file name="CategoriesController.php" hash="ec414ba576d1ead451037f00ad260f0c"/><file name="LayeredController.php" hash="1fe4e9095685c9b769f099a7e2896172"/><file name="ProductsController.php" hash="e6631406719f9bee6064b065b1882e1f"/><file name="ProductsbyidController.php" hash="2368b229d443698d38e1e96d284e5e84"/><file name="ResultController.php" hash="dc7e2f0d3364fa421e9a5c672ade14d7"/><file name="SearchesController.php" hash="9e7be782449944695f56ec08497eff20"/></dir><dir name="data"><dir name="autosuggest_setup"><file name="data-install-3.0.0.5.php" hash="b00a07c07028f18da59718cd5d55f06f"/><file name="data-upgrade-3.0.0.9-3.0.0.10.php" hash="89b44b0e9239b6bb21f7910fec6561cf"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="697b17c6d9e377ef754675680cf6e7a8"/><file name="cache.xml" hash="37e44e63ee5608af5f980028437b9329"/><file name="config.xml" hash="b4afd1d1b8bc04adaafbe761f18e60d3"/><file name="system.xml" hash="300a4b648a61473b23cc3e5e7fc0c778"/></dir><dir name="sql"><dir name="autosuggest_setup"><file name="mysql4-install-2.0.1.1.php" hash="530b30128aae6971b122a25af7c6f906"/><file name="mysql4-upgrade-2.0.1.3-2.0.2.2.php" hash="18de68b46af2480df60c0b1d57b1ba46"/><file name="mysql4-upgrade-2.0.2.5-2.0.2.6.php" hash="fcc1d07d36b4114b6aa086315b6e2b10"/><file name="mysql4-upgrade-2.0.4.6-2.0.4.7.php" hash="23a6072916f76804aed4078d1cd2dcb7"/><file name="mysql4-upgrade-2.0.5.4-2.0.5.5.php" hash="2d87f9ebd05eb785e496bd5a67802046"/><file name="mysql4-upgrade-2.0.7.0-2.0.7.1.php" hash="463879358bf857bf0df971b1f5228bea"/><file name="mysql4-upgrade-2.0.7.2-2.0.7.3.php" hash="1e9909aff39f321b4eca270ff59b677f"/><file name="mysql4-upgrade-2.0.8.8-3.0.0.0.php" hash="3eb103d10ced459ce605374d6cdc4a1d"/><file name="mysql4-upgrade-3.0.0.3-3.0.0.4.php" hash="9574b75e9a733be858a14588978cd21a"/><file name="mysql4-upgrade-3.0.0.4-3.0.0.5.php" hash="fe9b5ecaaa7b0c92c8ca71933bf3dcb1"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Autocompleteplus_Autosuggest.xml" hash="60e242b6c2c36e56c265e57f3ac0bcb1"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="autocompleteplus.xml" hash="87d15d88a45079525ed7ba5c62761bd7"/></dir><dir name="template"><dir name="autocompleteplus"><dir name="catalog"><dir name="layer"><file name="view.phtml" hash="2e2860a5896722172cbbf8887aa7834a"/></dir><dir name="product"><file name="list.phtml" hash="5ce70827e54082cc4d8ffd393234baf4"/></dir></dir><file name="inject.phtml" hash="ac1746e5b9a34837029c2983735f6e0c"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="autocompleteplus"><file name="notifications.phtml" hash="c0f5bb1f78421ffc0064c8f928899701"/><file name="process.phtml" hash="e8c92df106d56f6c2733b1b9cf371c5b"/><dir name="system"><dir name="config"><file name="button.phtml" hash="d167de08a4b5c2514cfbfd56821f6abc"/><file name="sync.phtml" hash="c8dff813daec5afed63914181831e96d"/></dir></dir></dir></dir><dir name="layout"><file name="autocompleteplus.xml" hash="15b04fb5fb38092ec5d8d16815ba20ff"/></dir></dir></dir></dir></target><target name="magelib"><dir name="Autocompleteplus"><dir name="Autosuggest"><dir name="Xml"><file name="Generator.php" hash="7aefaa8e6b247bdcc62497ab5700872c"/><file name="GeneratorInterface.php" hash="14c8d2a5348be50f8cef6d794339f2ed"/></dir></dir></dir></target></contents>
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
</package>
|