Version Notes
* purchase popularity fix;
* fancy url for instantsearchplus;
* additional params for vers request.
Download this release
Release Info
| Developer | Adar |
| Extension | autocompleteplus_autosuggest |
| Version | 3.0.0.12 |
| Comparing to | |
| See all releases | |
Code changes from version 3.0.0.11 to 3.0.0.12
- app/code/local/Autocompleteplus/Autosuggest/Adminhtml/Model/Attributes.php +24 -13
- app/code/local/Autocompleteplus/Autosuggest/Adminhtml/Model/Button.php +29 -18
- app/code/local/Autocompleteplus/Autosuggest/Block/Adminhtml/Button.php +21 -13
- app/code/local/Autocompleteplus/Autosuggest/Block/Adminhtml/Process.php +30 -4
- app/code/local/Autocompleteplus/Autosuggest/Block/Adminhtml/Sync.php +24 -6
- app/code/local/Autocompleteplus/Autosuggest/Block/Autocomplete.php +41 -8
- app/code/local/Autocompleteplus/Autosuggest/Block/Autocorrection.php +38 -8
- app/code/local/Autocompleteplus/Autosuggest/Block/Inject.php +57 -12
- app/code/local/Autocompleteplus/Autosuggest/Block/Notifications.php +17 -5
- app/code/local/Autocompleteplus/Autosuggest/Controller/Abstract.php +38 -1
- app/code/local/Autocompleteplus/Autosuggest/Helper/Data.php +545 -122
- app/code/local/Autocompleteplus/Autosuggest/Model/Catalog.php +125 -80
- app/code/local/Autocompleteplus/Autosuggest/Model/Config.php +25 -22
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Batches.php +2 -3
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Batches/Collection.php +2 -3
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Checksum.php +2 -3
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Checksum/Collection.php +2 -3
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Fulltext/Collection.php +2 -3
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Notifications.php +2 -3
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Notifications/Collection.php +2 -3
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Pusher.php +2 -3
- app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Pusher/Collection.php +2 -3
- app/code/local/Autocompleteplus/Autosuggest/Model/Observer.php +4 -7
- app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Abstract.php +9 -1
- app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Batches.php +8 -6
- app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Catalog/Product.php +372 -122
- app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Batches/Collection.php +4 -2
- app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Notifications/Collection.php +1 -2
- app/code/local/Autocompleteplus/Autosuggest/Model/Service.php +3 -3
- app/code/local/Autocompleteplus/Autosuggest/controllers/CategoriesController.php +14 -15
- app/code/local/Autocompleteplus/Autosuggest/controllers/LayeredController.php +70 -8
- app/code/local/Autocompleteplus/Autosuggest/controllers/ProductsController.php +313 -89
- app/code/local/Autocompleteplus/Autosuggest/controllers/ProductsbyidController.php +41 -6
- app/code/local/Autocompleteplus/Autosuggest/controllers/SearchesController.php +74 -23
- app/code/local/Autocompleteplus/Autosuggest/data/autosuggest_setup/data-install-3.0.0.5.php +3 -2
- app/code/local/Autocompleteplus/Autosuggest/data/autosuggest_setup/data-upgrade-3.0.0.9-3.0.0.10.php +1 -1
- app/code/local/Autocompleteplus/Autosuggest/etc/config.xml +8 -1
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-install-2.0.1.1.php +1 -1
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.1.3-2.0.2.2.php +1 -1
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.2.5-2.0.2.6.php +1 -1
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.4.6-2.0.4.7.php +1 -1
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.5.4-2.0.5.5.php +95 -64
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.7.0-2.0.7.1.php +1 -1
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.7.2-2.0.7.3.php +2 -2
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.8.8-3.0.0.0.php +1 -1
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-3.0.0.3-3.0.0.4.php +3 -3
- app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-3.0.0.4-3.0.0.5.php +1 -1
- app/design/frontend/base/default/template/autocompleteplus/catalog/product/list.phtml +39 -31
- package.xml +7 -6
app/code/local/Autocompleteplus/Autosuggest/Adminhtml/Model/Attributes.php
CHANGED
|
@@ -1,21 +1,22 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
*
|
| 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 |
-
*
|
| 12 |
*
|
| 13 |
-
* @
|
| 14 |
-
*
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
*
|
|
|
|
| 19 |
*/
|
| 20 |
class Autocompleteplus_Autosuggest_Adminhtml_Model_Attributes
|
| 21 |
{
|
|
@@ -34,7 +35,9 @@ class Autocompleteplus_Autosuggest_Adminhtml_Model_Attributes
|
|
| 34 |
|
| 35 |
public function getOptions()
|
| 36 |
{
|
| 37 |
-
$entityType = Mage::getModel('catalog/product')
|
|
|
|
|
|
|
| 38 |
$entityTypeId = $entityType->getId();
|
| 39 |
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
|
| 40 |
->setEntityTypeFilter($entityTypeId)
|
|
@@ -43,10 +46,18 @@ class Autocompleteplus_Autosuggest_Adminhtml_Model_Attributes
|
|
| 43 |
$result = array();
|
| 44 |
$result[] = array('value' => '', 'label' => 'Choose an attribute');
|
| 45 |
foreach ($attributeInfo as $_key => $_value) {
|
| 46 |
-
if (isset($_value['frontend_label'])
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
} else {
|
| 49 |
-
$result[] = array(
|
|
|
|
|
|
|
|
|
|
| 50 |
}
|
| 51 |
}
|
| 52 |
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* Autocompleteplus_Autosuggest_Adminhtml_Model_Attributes
|
| 4 |
+
* Used in creating options for Yes|No config value selection.
|
| 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 |
+
* PHP version 5
|
| 12 |
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
*/
|
| 21 |
class Autocompleteplus_Autosuggest_Adminhtml_Model_Attributes
|
| 22 |
{
|
| 35 |
|
| 36 |
public function getOptions()
|
| 37 |
{
|
| 38 |
+
$entityType = Mage::getModel('catalog/product')
|
| 39 |
+
->getResource()
|
| 40 |
+
->getEntityType();
|
| 41 |
$entityTypeId = $entityType->getId();
|
| 42 |
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
|
| 43 |
->setEntityTypeFilter($entityTypeId)
|
| 46 |
$result = array();
|
| 47 |
$result[] = array('value' => '', 'label' => 'Choose an attribute');
|
| 48 |
foreach ($attributeInfo as $_key => $_value) {
|
| 49 |
+
if (isset($_value['frontend_label'])
|
| 50 |
+
&& ($_value['frontend_label'] != '')
|
| 51 |
+
) {
|
| 52 |
+
$result[] = array(
|
| 53 |
+
'value' => $_value['attribute_code'],
|
| 54 |
+
'label' => $_value['frontend_label']
|
| 55 |
+
);
|
| 56 |
} else {
|
| 57 |
+
$result[] = array(
|
| 58 |
+
'value' => $_value['attribute_code'],
|
| 59 |
+
'label' => $_value['attribute_code']
|
| 60 |
+
);
|
| 61 |
}
|
| 62 |
}
|
| 63 |
|
app/code/local/Autocompleteplus/Autosuggest/Adminhtml/Model/Button.php
CHANGED
|
@@ -1,26 +1,29 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
*
|
| 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 |
-
*
|
| 12 |
*
|
| 13 |
-
* @
|
| 14 |
-
*
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
*
|
|
|
|
| 19 |
*/
|
| 20 |
-
class Autocompleteplus_Autosuggest_Adminhtml_Model_Button
|
| 21 |
{
|
| 22 |
-
|
| 23 |
* Set template
|
|
|
|
|
|
|
| 24 |
*/
|
| 25 |
protected function _construct()
|
| 26 |
{
|
|
@@ -31,7 +34,7 @@ class Autocompleteplus_Autosuggest_Adminhtml_Model_Button extends Mage_Adminhtm
|
|
| 31 |
/**
|
| 32 |
* Return element html.
|
| 33 |
*
|
| 34 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
| 35 |
*
|
| 36 |
* @return string
|
| 37 |
*/
|
|
@@ -42,6 +45,11 @@ class Autocompleteplus_Autosuggest_Adminhtml_Model_Button extends Mage_Adminhtm
|
|
| 42 |
return $this->_toHtml();
|
| 43 |
}
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
public function getUUID()
|
| 46 |
{
|
| 47 |
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
|
@@ -56,7 +64,8 @@ class Autocompleteplus_Autosuggest_Adminhtml_Model_Button extends Mage_Adminhtm
|
|
| 56 |
*/
|
| 57 |
public function getAjaxCheckUrl()
|
| 58 |
{
|
| 59 |
-
return Mage::helper('adminhtml')
|
|
|
|
| 60 |
}
|
| 61 |
|
| 62 |
/**
|
|
@@ -67,11 +76,13 @@ class Autocompleteplus_Autosuggest_Adminhtml_Model_Button extends Mage_Adminhtm
|
|
| 67 |
public function getButtonHtml()
|
| 68 |
{
|
| 69 |
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
| 70 |
-
->setData(
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
| 75 |
|
| 76 |
return $button->toHtml();
|
| 77 |
}
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* Autocompleteplus_Autosuggest_Adminhtml_Model_Button
|
| 4 |
+
* Used in creating options for Yes|No config value selection.
|
| 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 |
+
* PHP version 5
|
| 12 |
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
*/
|
| 21 |
+
class Autocompleteplus_Autosuggest_Adminhtml_Model_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 22 |
{
|
| 23 |
+
/**
|
| 24 |
* Set template
|
| 25 |
+
*
|
| 26 |
+
* @return void
|
| 27 |
*/
|
| 28 |
protected function _construct()
|
| 29 |
{
|
| 34 |
/**
|
| 35 |
* Return element html.
|
| 36 |
*
|
| 37 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 38 |
*
|
| 39 |
* @return string
|
| 40 |
*/
|
| 45 |
return $this->_toHtml();
|
| 46 |
}
|
| 47 |
|
| 48 |
+
/**
|
| 49 |
+
* Return uuid
|
| 50 |
+
*
|
| 51 |
+
* @return mixed
|
| 52 |
+
*/
|
| 53 |
public function getUUID()
|
| 54 |
{
|
| 55 |
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
| 64 |
*/
|
| 65 |
public function getAjaxCheckUrl()
|
| 66 |
{
|
| 67 |
+
return Mage::helper('adminhtml')
|
| 68 |
+
->getUrl('autocompleteplus/products/updateemail');
|
| 69 |
}
|
| 70 |
|
| 71 |
/**
|
| 76 |
public function getButtonHtml()
|
| 77 |
{
|
| 78 |
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
| 79 |
+
->setData(
|
| 80 |
+
array(
|
| 81 |
+
'id' => 'autocompleteplus_button',
|
| 82 |
+
'label' => $this->helper('adminhtml')->__('Update'),
|
| 83 |
+
'onclick' => 'javascript:updateautocomplete(); return false;',
|
| 84 |
+
)
|
| 85 |
+
);
|
| 86 |
|
| 87 |
return $button->toHtml();
|
| 88 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Block/Adminhtml/Button.php
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
<?php
|
| 2 |
-
|
| 3 |
/**
|
| 4 |
-
*
|
| 5 |
*
|
| 6 |
* NOTICE OF LICENSE
|
| 7 |
*
|
|
@@ -9,14 +8,15 @@
|
|
| 9 |
* that is available through the world-wide-web at this URL:
|
| 10 |
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
*
|
| 12 |
-
*
|
| 13 |
*
|
| 14 |
-
* @
|
| 15 |
-
*
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
*
|
|
|
|
| 20 |
*/
|
| 21 |
class Autocompleteplus_Autosuggest_Block_Adminhtml_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 22 |
{
|
|
@@ -32,7 +32,7 @@ class Autocompleteplus_Autosuggest_Block_Adminhtml_Button extends Mage_Adminhtml
|
|
| 32 |
/**
|
| 33 |
* Return element html.
|
| 34 |
*
|
| 35 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
| 36 |
*
|
| 37 |
* @return string
|
| 38 |
*/
|
|
@@ -43,6 +43,11 @@ class Autocompleteplus_Autosuggest_Block_Adminhtml_Button extends Mage_Adminhtml
|
|
| 43 |
return $this->_toHtml();
|
| 44 |
}
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
public function getUUID()
|
| 47 |
{
|
| 48 |
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
|
@@ -57,7 +62,8 @@ class Autocompleteplus_Autosuggest_Block_Adminhtml_Button extends Mage_Adminhtml
|
|
| 57 |
*/
|
| 58 |
public function getAjaxCheckUrl()
|
| 59 |
{
|
| 60 |
-
return Mage::helper('adminhtml')
|
|
|
|
| 61 |
}
|
| 62 |
|
| 63 |
/**
|
|
@@ -69,11 +75,13 @@ class Autocompleteplus_Autosuggest_Block_Adminhtml_Button extends Mage_Adminhtml
|
|
| 69 |
{
|
| 70 |
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
| 71 |
|
| 72 |
-
->setData(
|
|
|
|
| 73 |
'id' => 'autocompleteplus_button',
|
| 74 |
'label' => $this->helper('adminhtml')->__('Update'),
|
| 75 |
'onclick' => 'javascript:updateautocomplete(); return false;',
|
| 76 |
-
|
|
|
|
| 77 |
|
| 78 |
return $button->toHtml();
|
| 79 |
}
|
| 1 |
<?php
|
|
|
|
| 2 |
/**
|
| 3 |
+
* Autocompleteplus_Autosuggest_Block_Adminhtml_Button
|
| 4 |
*
|
| 5 |
* NOTICE OF LICENSE
|
| 6 |
*
|
| 8 |
* that is available through the world-wide-web at this URL:
|
| 9 |
* http://opensource.org/licenses/osl-3.0.php
|
| 10 |
*
|
| 11 |
+
* PHP version 5
|
| 12 |
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
*/
|
| 21 |
class Autocompleteplus_Autosuggest_Block_Adminhtml_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 22 |
{
|
| 32 |
/**
|
| 33 |
* Return element html.
|
| 34 |
*
|
| 35 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 36 |
*
|
| 37 |
* @return string
|
| 38 |
*/
|
| 43 |
return $this->_toHtml();
|
| 44 |
}
|
| 45 |
|
| 46 |
+
/**
|
| 47 |
+
* Returns uuid
|
| 48 |
+
*
|
| 49 |
+
* @return mixed
|
| 50 |
+
*/
|
| 51 |
public function getUUID()
|
| 52 |
{
|
| 53 |
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
| 62 |
*/
|
| 63 |
public function getAjaxCheckUrl()
|
| 64 |
{
|
| 65 |
+
return Mage::helper('adminhtml')
|
| 66 |
+
->getUrl('autocompleteplus/products/updateemail');
|
| 67 |
}
|
| 68 |
|
| 69 |
/**
|
| 75 |
{
|
| 76 |
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
| 77 |
|
| 78 |
+
->setData(
|
| 79 |
+
array(
|
| 80 |
'id' => 'autocompleteplus_button',
|
| 81 |
'label' => $this->helper('adminhtml')->__('Update'),
|
| 82 |
'onclick' => 'javascript:updateautocomplete(); return false;',
|
| 83 |
+
)
|
| 84 |
+
);
|
| 85 |
|
| 86 |
return $button->toHtml();
|
| 87 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Block/Adminhtml/Process.php
CHANGED
|
@@ -1,10 +1,28 @@
|
|
| 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>
|
|
@@ -24,8 +42,16 @@ TMPL;
|
|
| 24 |
),
|
| 25 |
'loader' => $this->getSkinUrl('images/ajax-loader.gif'),
|
| 26 |
'template' => $configTemplate,
|
| 27 |
-
'text' => $this->__(
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
);
|
| 30 |
}
|
| 31 |
}
|
| 1 |
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Autocompleteplus_Autosuggest_Block_Adminhtml_Process
|
| 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 |
+
* PHP version 5
|
| 12 |
+
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
+
*/
|
| 21 |
class Autocompleteplus_Autosuggest_Block_Adminhtml_Process extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 22 |
{
|
| 23 |
protected function _construct()
|
| 24 |
{
|
| 25 |
+
$configTemplate = <<<'TMPL'
|
| 26 |
<li style="#{style}" id="#{id}">
|
| 27 |
<img id="#{id}_img" src="#{image}" class="v-middle" style="margin-right:5px"/>
|
| 28 |
<span id="#{id}_status" class="text">#{text}</span>
|
| 42 |
),
|
| 43 |
'loader' => $this->getSkinUrl('images/ajax-loader.gif'),
|
| 44 |
'template' => $configTemplate,
|
| 45 |
+
'text' => $this->__(
|
| 46 |
+
'Processed <strong>%s%% %s/%d</strong> records',
|
| 47 |
+
'#{percent}',
|
| 48 |
+
'#{updated}',
|
| 49 |
+
$this->getBatchItemsCount()
|
| 50 |
+
),
|
| 51 |
+
'successText' => $this->__(
|
| 52 |
+
'Imported <strong>%s</strong> records',
|
| 53 |
+
'#{updated}'
|
| 54 |
+
),
|
| 55 |
);
|
| 56 |
}
|
| 57 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Block/Adminhtml/Sync.php
CHANGED
|
@@ -1,7 +1,22 @@
|
|
| 1 |
<?php
|
| 2 |
-
|
| 3 |
/**
|
| 4 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
*/
|
| 6 |
class Autocompleteplus_Autosuggest_Block_Adminhtml_Sync extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 7 |
{
|
|
@@ -14,7 +29,7 @@ class Autocompleteplus_Autosuggest_Block_Adminhtml_Sync extends Mage_Adminhtml_B
|
|
| 14 |
/**
|
| 15 |
* Return element html.
|
| 16 |
*
|
| 17 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
| 18 |
*
|
| 19 |
* @return string
|
| 20 |
*/
|
|
@@ -56,7 +71,8 @@ class Autocompleteplus_Autosuggest_Block_Adminhtml_Sync extends Mage_Adminhtml_B
|
|
| 56 |
*/
|
| 57 |
public function getSyncUrl()
|
| 58 |
{
|
| 59 |
-
return Mage::helper('adminhtml')
|
|
|
|
| 60 |
}
|
| 61 |
|
| 62 |
/**
|
|
@@ -67,11 +83,13 @@ class Autocompleteplus_Autosuggest_Block_Adminhtml_Sync extends Mage_Adminhtml_B
|
|
| 67 |
public function getButtonHtml()
|
| 68 |
{
|
| 69 |
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
| 70 |
-
->setData(
|
|
|
|
| 71 |
'id' => 'autocompleteplus_sync',
|
| 72 |
'label' => $this->helper('adminhtml')->__('Sync'),
|
| 73 |
'onclick' => 'javascript:syncautocomplete(); return false;',
|
| 74 |
-
|
|
|
|
| 75 |
|
| 76 |
return $button->toHtml();
|
| 77 |
}
|
| 1 |
<?php
|
|
|
|
| 2 |
/**
|
| 3 |
+
* Autocompleteplus_Autosuggest_Block_Adminhtml_Sync
|
| 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 |
+
* PHP version 5
|
| 12 |
+
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
*/
|
| 21 |
class Autocompleteplus_Autosuggest_Block_Adminhtml_Sync extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 22 |
{
|
| 29 |
/**
|
| 30 |
* Return element html.
|
| 31 |
*
|
| 32 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 33 |
*
|
| 34 |
* @return string
|
| 35 |
*/
|
| 71 |
*/
|
| 72 |
public function getSyncUrl()
|
| 73 |
{
|
| 74 |
+
return Mage::helper('adminhtml')
|
| 75 |
+
->getUrl('adminhtml/autocompleteplus_push/startpush');
|
| 76 |
}
|
| 77 |
|
| 78 |
/**
|
| 83 |
public function getButtonHtml()
|
| 84 |
{
|
| 85 |
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
| 86 |
+
->setData(
|
| 87 |
+
array(
|
| 88 |
'id' => 'autocompleteplus_sync',
|
| 89 |
'label' => $this->helper('adminhtml')->__('Sync'),
|
| 90 |
'onclick' => 'javascript:syncautocomplete(); return false;',
|
| 91 |
+
)
|
| 92 |
+
);
|
| 93 |
|
| 94 |
return $button->toHtml();
|
| 95 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Block/Autocomplete.php
CHANGED
|
@@ -1,18 +1,41 @@
|
|
| 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')
|
|
|
|
| 10 |
if (!$fulltext_enable) {
|
| 11 |
return '';
|
| 12 |
}
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
$current_search_term = urlencode(self::getRequest()->getParam('q'));
|
| 15 |
-
$searched_term = Mage::getSingleton('core/session')
|
|
|
|
| 16 |
if ($current_search_term != $searched_term) {
|
| 17 |
$is_full_text_wrong_flow = true;
|
| 18 |
}
|
|
@@ -25,10 +48,16 @@ class Autocompleteplus_Autosuggest_Block_Autocomplete extends Mage_Core_Block_Ab
|
|
| 25 |
$params = array();
|
| 26 |
if (!$is_full_text_wrong_flow) {
|
| 27 |
try {
|
| 28 |
-
$alternatives = Mage::getSingleton('core/session')
|
| 29 |
-
|
|
|
|
|
|
|
| 30 |
} catch (Exception $e) {
|
| 31 |
-
Mage::log(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
return '';
|
| 34 |
}
|
|
@@ -44,7 +73,11 @@ class Autocompleteplus_Autosuggest_Block_Autocomplete extends Mage_Core_Block_Ab
|
|
| 44 |
}
|
| 45 |
|
| 46 |
$magento_version = Mage::getVersion();
|
| 47 |
-
$extension_version = (string) Mage::getConfig()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
$versions = ($params == '') ? 'mage_v='.$magento_version.'&ext_v='.$extension_version
|
| 49 |
: '&mage_v='.$magento_version.'&ext_v='.$extension_version;
|
| 50 |
|
| 1 |
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Autocompleteplus_Autosuggest_Block_Autocomplete
|
| 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 |
+
* PHP version 5
|
| 12 |
+
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
+
*/
|
| 21 |
class Autocompleteplus_Autosuggest_Block_Autocomplete extends Mage_Core_Block_Abstract
|
| 22 |
{
|
| 23 |
protected function _toHtml()
|
| 24 |
{
|
| 25 |
$is_full_text_wrong_flow = false;
|
| 26 |
try {
|
| 27 |
+
$fulltext_enable = Mage::getSingleton('core/session')
|
| 28 |
+
->getIsFullTextEnable();
|
| 29 |
if (!$fulltext_enable) {
|
| 30 |
return '';
|
| 31 |
}
|
| 32 |
+
/**
|
| 33 |
+
* Checking if the searched query from addSearchFilter()
|
| 34 |
+
* is the same to the current query
|
| 35 |
+
*/
|
| 36 |
$current_search_term = urlencode(self::getRequest()->getParam('q'));
|
| 37 |
+
$searched_term = Mage::getSingleton('core/session')
|
| 38 |
+
->getIspUrlEncodeQuery();
|
| 39 |
if ($current_search_term != $searched_term) {
|
| 40 |
$is_full_text_wrong_flow = true;
|
| 41 |
}
|
| 48 |
$params = array();
|
| 49 |
if (!$is_full_text_wrong_flow) {
|
| 50 |
try {
|
| 51 |
+
$alternatives = Mage::getSingleton('core/session')
|
| 52 |
+
->getIspSearchAlternatives();
|
| 53 |
+
$results_for = Mage::getSingleton('core/session')
|
| 54 |
+
->getIspSearchResultsFor();
|
| 55 |
} catch (Exception $e) {
|
| 56 |
+
Mage::log(
|
| 57 |
+
'autocomplete.php _toHtml() Exception => results_for and did you mean calculations'.$e->getMessage(),
|
| 58 |
+
null,
|
| 59 |
+
'autocompleteplus.log'
|
| 60 |
+
);
|
| 61 |
|
| 62 |
return '';
|
| 63 |
}
|
| 73 |
}
|
| 74 |
|
| 75 |
$magento_version = Mage::getVersion();
|
| 76 |
+
$extension_version = (string) Mage::getConfig()
|
| 77 |
+
->getNode()
|
| 78 |
+
->modules
|
| 79 |
+
->Autocompleteplus_Autosuggest
|
| 80 |
+
->version;
|
| 81 |
$versions = ($params == '') ? 'mage_v='.$magento_version.'&ext_v='.$extension_version
|
| 82 |
: '&mage_v='.$magento_version.'&ext_v='.$extension_version;
|
| 83 |
|
app/code/local/Autocompleteplus/Autosuggest/Block/Autocorrection.php
CHANGED
|
@@ -1,28 +1,58 @@
|
|
| 1 |
<?php
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
class Autocompleteplus_Autosuggest_Block_Autocorrection extends Mage_Core_Block_Template
|
| 5 |
{
|
| 6 |
protected function _prepareLayout()
|
| 7 |
{
|
| 8 |
-
$header = $this->__(
|
|
|
|
|
|
|
|
|
|
| 9 |
if (Mage::registry('search_results_for')) {
|
| 10 |
-
$header = $this->__(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
}
|
| 12 |
$alternatives = '';
|
| 13 |
if (Mage::registry('search_alternatives')) {
|
| 14 |
$links = array();
|
| 15 |
foreach (Mage::registry('search_alternatives') as $alternative) {
|
| 16 |
-
$links[] = '<a href="'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
}
|
| 18 |
|
| 19 |
-
$alternatives = '</h1><strong>'
|
|
|
|
|
|
|
| 20 |
}
|
| 21 |
|
| 22 |
if (Mage::registry('search_results_for') || Mage::registry('search_alternatives')) {
|
| 23 |
$this->getLayout()
|
| 24 |
-
|
| 25 |
-
|
| 26 |
}
|
| 27 |
}
|
| 28 |
}
|
| 1 |
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Autocompleteplus_Autosuggest_Block_Autocorrection
|
| 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 |
+
* PHP version 5
|
| 12 |
+
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
+
*/
|
| 21 |
class Autocompleteplus_Autosuggest_Block_Autocorrection extends Mage_Core_Block_Template
|
| 22 |
{
|
| 23 |
protected function _prepareLayout()
|
| 24 |
{
|
| 25 |
+
$header = $this->__(
|
| 26 |
+
"Search results for '%s'",
|
| 27 |
+
$this->helper('catalogsearch')->getEscapedQueryText()
|
| 28 |
+
);
|
| 29 |
if (Mage::registry('search_results_for')) {
|
| 30 |
+
$header = $this->__(
|
| 31 |
+
"No results for '%s', showing results for '%s'",
|
| 32 |
+
$this->helper('catalogsearch')->getQueryText(),
|
| 33 |
+
Mage::registry('search_results_for')
|
| 34 |
+
);
|
| 35 |
}
|
| 36 |
$alternatives = '';
|
| 37 |
if (Mage::registry('search_alternatives')) {
|
| 38 |
$links = array();
|
| 39 |
foreach (Mage::registry('search_alternatives') as $alternative) {
|
| 40 |
+
$links[] = '<a href="'.
|
| 41 |
+
$this->getUrl(
|
| 42 |
+
'catalogsearch/result',
|
| 43 |
+
array('q' => $alternative)
|
| 44 |
+
).'">'.$alternative.'</a>';
|
| 45 |
}
|
| 46 |
|
| 47 |
+
$alternatives = '</h1><strong>'.
|
| 48 |
+
$this->__('Did you mean:').
|
| 49 |
+
'</strong><p>'.implode(', ', $links).'</p>';
|
| 50 |
}
|
| 51 |
|
| 52 |
if (Mage::registry('search_results_for') || Mage::registry('search_alternatives')) {
|
| 53 |
$this->getLayout()
|
| 54 |
+
->getBlock('search.result')
|
| 55 |
+
->setHeaderText($header.$alternatives);
|
| 56 |
}
|
| 57 |
}
|
| 58 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Block/Inject.php
CHANGED
|
@@ -1,5 +1,23 @@
|
|
| 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';
|
|
@@ -7,6 +25,11 @@ class Autocompleteplus_Autosuggest_Block_Inject extends Mage_Checkout_Block_Cart
|
|
| 7 |
public $_onCatalog = false;
|
| 8 |
protected $_helper;
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
protected function _construct()
|
| 11 |
{
|
| 12 |
$this->_helper = Mage::helper('autocompleteplus_autosuggest');
|
|
@@ -18,7 +41,7 @@ class Autocompleteplus_Autosuggest_Block_Inject extends Mage_Checkout_Block_Cart
|
|
| 18 |
}
|
| 19 |
|
| 20 |
/**
|
| 21 |
-
* Test to see if admin is logged in
|
| 22 |
* by swapping session identifier.
|
| 23 |
*
|
| 24 |
* @return bool
|
|
@@ -31,19 +54,23 @@ class Autocompleteplus_Autosuggest_Block_Inject extends Mage_Checkout_Block_Cart
|
|
| 31 |
$path = $io->getCleanPath(Mage::getBaseDir('session'));
|
| 32 |
$sessionFilePath = $path.DS.'sess_'.$sessionCookie;
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
| 35 |
if ($sessionCookie) {
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
| 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 |
|
|
@@ -104,7 +131,9 @@ class Autocompleteplus_Autosuggest_Block_Inject extends Mage_Checkout_Block_Cart
|
|
| 104 |
*/
|
| 105 |
public function getProductUrl()
|
| 106 |
{
|
| 107 |
-
|
|
|
|
|
|
|
| 108 |
return urlencode($product->getProductUrl());
|
| 109 |
}
|
| 110 |
}
|
|
@@ -116,7 +145,9 @@ class Autocompleteplus_Autosuggest_Block_Inject extends Mage_Checkout_Block_Cart
|
|
| 116 |
*/
|
| 117 |
public function getProductSku()
|
| 118 |
{
|
| 119 |
-
|
|
|
|
|
|
|
| 120 |
return $product->getSku();
|
| 121 |
}
|
| 122 |
}
|
|
@@ -128,18 +159,32 @@ class Autocompleteplus_Autosuggest_Block_Inject extends Mage_Checkout_Block_Cart
|
|
| 128 |
*/
|
| 129 |
public function getProductIdentifier()
|
| 130 |
{
|
| 131 |
-
|
|
|
|
|
|
|
| 132 |
return $product->getId();
|
| 133 |
}
|
| 134 |
}
|
| 135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
public function getQuoteId()
|
| 137 |
{
|
| 138 |
return Mage::getSingleton('checkout/session')->getQuoteId();
|
| 139 |
}
|
| 140 |
-
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
$session_customer = Mage::getSingleton('customer/session');
|
|
|
|
| 143 |
return $session_customer->isLoggedIn();
|
| 144 |
}
|
| 145 |
|
|
@@ -161,7 +206,7 @@ class Autocompleteplus_Autosuggest_Block_Inject extends Mage_Checkout_Block_Cart
|
|
| 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, '', '&');
|
| 1 |
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Autocompleteplus_Autosuggest_Block_Inject
|
| 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 |
+
* PHP version 5
|
| 12 |
+
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
+
*/
|
| 21 |
class Autocompleteplus_Autosuggest_Block_Inject extends Mage_Checkout_Block_Cart_Sidebar
|
| 22 |
{
|
| 23 |
const AUTOCOMPLETE_JS_URL = 'https://acp-magento.appspot.com/js/acp-magento.js';
|
| 25 |
public $_onCatalog = false;
|
| 26 |
protected $_helper;
|
| 27 |
|
| 28 |
+
/**
|
| 29 |
+
* Construct
|
| 30 |
+
*
|
| 31 |
+
* @return void
|
| 32 |
+
*/
|
| 33 |
protected function _construct()
|
| 34 |
{
|
| 35 |
$this->_helper = Mage::helper('autocompleteplus_autosuggest');
|
| 41 |
}
|
| 42 |
|
| 43 |
/**
|
| 44 |
+
* Test to see if admin is logged in
|
| 45 |
* by swapping session identifier.
|
| 46 |
*
|
| 47 |
* @return bool
|
| 54 |
$path = $io->getCleanPath(Mage::getBaseDir('session'));
|
| 55 |
$sessionFilePath = $path.DS.'sess_'.$sessionCookie;
|
| 56 |
|
| 57 |
+
/**
|
| 58 |
+
* Check if adminhtml cookie is set
|
| 59 |
+
*/
|
| 60 |
if ($sessionCookie) {
|
| 61 |
+
/**
|
| 62 |
+
* Get session path and add dir seperator
|
| 63 |
+
* and content field of cookie as data name with magento "sess_" prefix
|
| 64 |
+
*/
|
| 65 |
if (!$io->fileExists($sessionFilePath)) {
|
| 66 |
return false;
|
| 67 |
}
|
| 68 |
//write content of file in var
|
| 69 |
$io->open(array('path' => $path));
|
| 70 |
$sessionFile = $io->read($sessionFilePath);
|
| 71 |
+
if (stripos($sessionFile, 'Mage_Admin_Model_User') !== false) {
|
| 72 |
return true;
|
| 73 |
}
|
|
|
|
| 74 |
}
|
| 75 |
}
|
| 76 |
|
| 131 |
*/
|
| 132 |
public function getProductUrl()
|
| 133 |
{
|
| 134 |
+
$product = $this->getProduct();
|
| 135 |
+
|
| 136 |
+
if ($product != null) {
|
| 137 |
return urlencode($product->getProductUrl());
|
| 138 |
}
|
| 139 |
}
|
| 145 |
*/
|
| 146 |
public function getProductSku()
|
| 147 |
{
|
| 148 |
+
$product = $this->getProduct();
|
| 149 |
+
|
| 150 |
+
if ($product != null) {
|
| 151 |
return $product->getSku();
|
| 152 |
}
|
| 153 |
}
|
| 159 |
*/
|
| 160 |
public function getProductIdentifier()
|
| 161 |
{
|
| 162 |
+
$product = $this->getProduct();
|
| 163 |
+
|
| 164 |
+
if ($product != null) {
|
| 165 |
return $product->getId();
|
| 166 |
}
|
| 167 |
}
|
| 168 |
|
| 169 |
+
/**
|
| 170 |
+
* Returns quota Id
|
| 171 |
+
*
|
| 172 |
+
* @return mixed
|
| 173 |
+
*/
|
| 174 |
public function getQuoteId()
|
| 175 |
{
|
| 176 |
return Mage::getSingleton('checkout/session')->getQuoteId();
|
| 177 |
}
|
| 178 |
+
|
| 179 |
+
/**
|
| 180 |
+
* Checks if user is logged in as admin
|
| 181 |
+
*
|
| 182 |
+
* @return mixed
|
| 183 |
+
*/
|
| 184 |
+
public function isLoggedInUser()
|
| 185 |
+
{
|
| 186 |
$session_customer = Mage::getSingleton('customer/session');
|
| 187 |
+
|
| 188 |
return $session_customer->isLoggedIn();
|
| 189 |
}
|
| 190 |
|
| 206 |
'is_admin_user' => $this->_isAdminLoggedIn(),
|
| 207 |
'sessionID' => $this->_helper->getSessionId(),
|
| 208 |
'QuoteID' => $this->getQuoteId(),
|
| 209 |
+
'is_user_logged_in' => $this->isLoggedInUser(),
|
| 210 |
);
|
| 211 |
|
| 212 |
return self::AUTOCOMPLETE_JS_URL.'?'.http_build_query($parameters, '', '&');
|
app/code/local/Autocompleteplus/Autosuggest/Block/Notifications.php
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
*
|
| 4 |
*
|
| 5 |
* NOTICE OF LICENSE
|
| 6 |
*
|
|
@@ -8,10 +8,15 @@
|
|
| 8 |
* that is available through the world-wide-web at this URL:
|
| 9 |
* http://opensource.org/licenses/osl-3.0.php
|
| 10 |
*
|
| 11 |
-
*
|
| 12 |
*
|
| 13 |
-
* @
|
| 14 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
*/
|
| 16 |
class Autocompleteplus_Autosuggest_Block_Notifications extends Mage_Core_Block_Template
|
| 17 |
{
|
|
@@ -20,13 +25,20 @@ class Autocompleteplus_Autosuggest_Block_Notifications extends Mage_Core_Block_T
|
|
| 20 |
*/
|
| 21 |
public function getNotifications()
|
| 22 |
{
|
| 23 |
-
/**
|
|
|
|
|
|
|
| 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');
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* Autocompleteplus_Autosuggest_Block_Notifications
|
| 4 |
*
|
| 5 |
* NOTICE OF LICENSE
|
| 6 |
*
|
| 8 |
* that is available through the world-wide-web at this URL:
|
| 9 |
* http://opensource.org/licenses/osl-3.0.php
|
| 10 |
*
|
| 11 |
+
* PHP version 5
|
| 12 |
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
*/
|
| 21 |
class Autocompleteplus_Autosuggest_Block_Notifications extends Mage_Core_Block_Template
|
| 22 |
{
|
| 25 |
*/
|
| 26 |
public function getNotifications()
|
| 27 |
{
|
| 28 |
+
/**
|
| 29 |
+
* @var Autocompleteplus_Autosuggest_Model_Mysql4_Notifications_Collection $collection
|
| 30 |
+
*/
|
| 31 |
$collection = Mage::getModel('autocompleteplus_autosuggest/notifications')
|
| 32 |
->getCollection();
|
| 33 |
|
| 34 |
return $collection->addTypeFilter('alert')->addActiveFilter();
|
| 35 |
}
|
| 36 |
|
| 37 |
+
/**
|
| 38 |
+
* Checks if localhost synced
|
| 39 |
+
*
|
| 40 |
+
* @return bool
|
| 41 |
+
*/
|
| 42 |
public function localhostSynced()
|
| 43 |
{
|
| 44 |
$helper = Mage::helper('autocompleteplus_autosuggest');
|
app/code/local/Autocompleteplus/Autosuggest/Controller/Abstract.php
CHANGED
|
@@ -1,5 +1,43 @@
|
|
| 1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
abstract class Autocompleteplus_Autosuggest_Controller_Abstract extends Mage_Core_Controller_Front_Action
|
| 4 |
{
|
| 5 |
const PHP_SCRIPT_TIMEOUT = 1800;
|
|
@@ -10,6 +48,5 @@ abstract class Autocompleteplus_Autosuggest_Controller_Abstract extends Mage_Cor
|
|
| 10 |
public function preDispatch()
|
| 11 |
{
|
| 12 |
parent::preDispatch();
|
| 13 |
-
set_time_limit(self::PHP_SCRIPT_TIMEOUT);
|
| 14 |
}
|
| 15 |
}
|
| 1 |
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Abstract File
|
| 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 |
+
* PHP version 5
|
| 12 |
+
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
+
*/
|
| 21 |
|
| 22 |
+
/**
|
| 23 |
+
* Autocompleteplus_Autosuggest_Controller_Abstract
|
| 24 |
+
* Used in creating options for Yes|No config value selection.
|
| 25 |
+
* NOTICE OF LICENSE
|
| 26 |
+
*
|
| 27 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 28 |
+
* that is available through the world-wide-web at this URL:
|
| 29 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 30 |
+
*
|
| 31 |
+
* PHP version 5
|
| 32 |
+
*
|
| 33 |
+
* @category Mage
|
| 34 |
+
*
|
| 35 |
+
* @package Instantsearchplus
|
| 36 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 37 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 38 |
+
* @license Open Software License (OSL 3.0)*
|
| 39 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 40 |
+
*/
|
| 41 |
abstract class Autocompleteplus_Autosuggest_Controller_Abstract extends Mage_Core_Controller_Front_Action
|
| 42 |
{
|
| 43 |
const PHP_SCRIPT_TIMEOUT = 1800;
|
| 48 |
public function preDispatch()
|
| 49 |
{
|
| 50 |
parent::preDispatch();
|
|
|
|
| 51 |
}
|
| 52 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Helper/Data.php
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
*
|
| 4 |
*
|
| 5 |
* NOTICE OF LICENSE
|
| 6 |
*
|
|
@@ -8,33 +8,65 @@
|
|
| 8 |
* that is available through the world-wide-web at this URL:
|
| 9 |
* http://opensource.org/licenses/osl-3.0.php
|
| 10 |
*
|
| 11 |
-
*
|
| 12 |
*
|
| 13 |
-
* @
|
| 14 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 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
|
|
@@ -46,21 +78,45 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 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()
|
|
|
|
|
|
|
| 62 |
}
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
public function getConfigDataByFullPath($path)
|
| 65 |
{
|
| 66 |
$valsArr = $this->getConfigMultiDataByFullPath($path);
|
|
@@ -74,15 +130,28 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 74 |
return $value;
|
| 75 |
}
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
public function getConfigMultiDataByFullPath($path)
|
| 78 |
{
|
| 79 |
$values = array();
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
$values[] = array_shift($conf);
|
| 84 |
-
} else {
|
| 85 |
|
|
|
|
| 86 |
foreach ($rows as $row) {
|
| 87 |
$scopeId = $row->getScopeId();
|
| 88 |
|
|
@@ -97,11 +166,21 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 97 |
return $values;
|
| 98 |
}
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
public function getConfigMultiScopesDataByFullPath($path)
|
| 101 |
{
|
| 102 |
$values = array();
|
| 103 |
|
| 104 |
-
$rows = Mage::getSingleton('core/config_data')
|
|
|
|
|
|
|
| 105 |
|
| 106 |
foreach ($rows as $row) {
|
| 107 |
$scope = $row->getScope();
|
|
@@ -111,8 +190,7 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 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 |
|
|
@@ -120,10 +198,16 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 120 |
}
|
| 121 |
}
|
| 122 |
|
| 123 |
-
|
| 124 |
return $values;
|
| 125 |
}
|
| 126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
public function sendCurl($command)
|
| 128 |
{
|
| 129 |
if (isset($ch)) {
|
|
@@ -144,8 +228,20 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 144 |
return $str;
|
| 145 |
}
|
| 146 |
|
| 147 |
-
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
if (isset($ch)) {
|
| 150 |
unset($ch);
|
| 151 |
}
|
|
@@ -158,18 +254,29 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 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(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
//curl_setopt($ch,CURLOPT_POST,0);
|
| 163 |
if (!empty($data)) {
|
| 164 |
-
curl_setopt_array(
|
|
|
|
|
|
|
| 165 |
CURLOPT_POSTFIELDS => $data,
|
| 166 |
-
|
|
|
|
| 167 |
}
|
| 168 |
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
|
| 174 |
$str = curl_exec($ch);
|
| 175 |
} else {
|
|
@@ -179,9 +286,18 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 179 |
return $str;
|
| 180 |
}
|
| 181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
public function prepareGroupedProductPrice($groupedProduct)
|
| 183 |
{
|
| 184 |
-
$aProductIds = $groupedProduct
|
|
|
|
|
|
|
| 185 |
|
| 186 |
$prices = array();
|
| 187 |
foreach ($aProductIds as $ids) {
|
|
@@ -206,9 +322,18 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 206 |
$groupedProduct->setPrice(0);
|
| 207 |
}
|
| 208 |
|
| 209 |
-
|
|
|
|
|
|
|
| 210 |
}
|
| 211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
public function getBundlePrice($product)
|
| 213 |
{
|
| 214 |
$optionCol = $product->getTypeInstance(true)
|
|
@@ -245,6 +370,11 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 245 |
return $price;
|
| 246 |
}
|
| 247 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
public function getMultiStoreDataJson()
|
| 249 |
{
|
| 250 |
$websites = Mage::getModel('core/website')->getCollection();
|
|
@@ -252,14 +382,22 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 252 |
$ext = Mage::helper('autocompleteplus_autosuggest')->getVersion();
|
| 253 |
$version = array('mage' => $mage, 'ext' => $ext);
|
| 254 |
|
| 255 |
-
|
|
|
|
|
|
|
| 256 |
$url = $this->getConfigDataByFullPath('web/unsecure/base_url');
|
| 257 |
|
| 258 |
-
|
| 259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
|
| 261 |
if (!$storeMail) {
|
| 262 |
-
$storeMail = $this->getConfigDataByFullPath(
|
|
|
|
|
|
|
| 263 |
}
|
| 264 |
|
| 265 |
$storesArr = array();
|
|
@@ -307,17 +445,27 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 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 |
-
|
|
|
|
|
|
|
| 317 |
if ($module->codePool == 'core' || $module->active != 'true') {
|
| 318 |
continue;
|
| 319 |
}
|
| 320 |
-
$config_file_path = Mage::getConfig()
|
|
|
|
| 321 |
$config = new Varien_Simplexml_Config();
|
| 322 |
$config->loadString('<config/>');
|
| 323 |
$config->loadFile($config_file_path);
|
|
@@ -329,13 +477,22 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 329 |
}
|
| 330 |
foreach ($nodes->children() as $node_name => $config) {
|
| 331 |
if ($config->rewrite) { // there is rewrite for current config
|
| 332 |
-
|
| 333 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
|
| 335 |
$lead_derived_class = '';
|
| 336 |
-
$conf = Mage::getConfig()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
if (isset($conf->rewrite->$class_tag)) {
|
| 338 |
-
$lead_derived_class = (string) $conf
|
|
|
|
| 339 |
}
|
| 340 |
if ($derived_class == '') {
|
| 341 |
$derived_class = $lead_derived_class;
|
|
@@ -349,8 +506,14 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 349 |
'name' => array((string) $name),
|
| 350 |
);
|
| 351 |
} else {
|
| 352 |
-
array_push(
|
| 353 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 354 |
}
|
| 355 |
}
|
| 356 |
}
|
|
@@ -364,8 +527,14 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 364 |
$isp_rewrite_classes = array();
|
| 365 |
$isp_module_name = 'Autocompleteplus_Autosuggest';
|
| 366 |
foreach ($all_rewrite_classes as $base => $conflict_info) {
|
| 367 |
-
|
| 368 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
$isp_rewrite_classes[$base] = $conflict_info;
|
| 370 |
}
|
| 371 |
}
|
|
@@ -374,6 +543,15 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 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;
|
|
@@ -393,6 +571,8 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 393 |
|
| 394 |
/**
|
| 395 |
* Checksum functionality.
|
|
|
|
|
|
|
| 396 |
*/
|
| 397 |
public function isChecksumTableExists()
|
| 398 |
{
|
|
@@ -405,42 +585,71 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
//
|
| 425 |
-
|
| 426 |
-
|
| 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
|
| 434 |
-
$
|
|
|
|
|
|
|
| 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.
|
|
|
|
| 444 |
$updates = $read->fetchAll($sql_fetch, array($product_id, $store_id));
|
| 445 |
if ($updates && (count($updates) != 0)) {
|
| 446 |
return $updates[0]['checksum'];
|
|
@@ -449,8 +658,22 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 449 |
}
|
| 450 |
}
|
| 451 |
|
| 452 |
-
|
| 453 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 454 |
return;
|
| 455 |
if ($product_id == null || $sku == null) {
|
| 456 |
return;
|
|
@@ -475,6 +698,18 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 475 |
}
|
| 476 |
}
|
| 477 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 478 |
public function updateDeletedProductChecksum($table_prefix, $read, $write, $product_id, $sku, $store_id)
|
| 479 |
{
|
| 480 |
return;
|
|
@@ -482,7 +717,8 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 482 |
return;
|
| 483 |
}
|
| 484 |
|
| 485 |
-
$checksums = Mage::getModel('autocompleteplus_autosuggest/checksum')
|
|
|
|
| 486 |
->addFieldToFilter('identifier', $product_id)
|
| 487 |
->addFieldToFilter('store_id', $store_id);
|
| 488 |
|
|
@@ -493,8 +729,24 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 493 |
}
|
| 494 |
}
|
| 495 |
|
| 496 |
-
|
| 497 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 498 |
if ($product_id == null) {
|
| 499 |
return;
|
| 500 |
}
|
|
@@ -503,27 +755,63 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 503 |
}
|
| 504 |
try {
|
| 505 |
$table_prefix = (string) Mage::getConfig()->getTablePrefix();
|
| 506 |
-
$is_table_exist = $write
|
| 507 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 508 |
return;
|
| 509 |
}
|
| 510 |
|
| 511 |
-
$sql_fetch = 'SELECT * FROM '
|
|
|
|
|
|
|
| 512 |
$updates = $read->fetchAll($sql_fetch, array($product_id, $store_id));
|
| 513 |
|
| 514 |
if ($updates && (count($updates) != 0)) {
|
| 515 |
-
$sql = 'UPDATE '.$table_prefix.
|
| 516 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 517 |
} else {
|
| 518 |
-
$sql = 'INSERT INTO '
|
| 519 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 520 |
}
|
| 521 |
} catch (Exception $e) {
|
| 522 |
-
Mage::log(
|
| 523 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 524 |
}
|
| 525 |
}
|
| 526 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 527 |
public function compareProductsChecksum($from, $count, $store_id = null)
|
| 528 |
{
|
| 529 |
$num_of_updates = 0;
|
|
@@ -549,25 +837,61 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 549 |
->setStore($store_id)->setStoreId($store_id)
|
| 550 |
->load($product_collection_data['entity_id']);
|
| 551 |
|
| 552 |
-
$current_checksum = $this->getSavedChecksum(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 553 |
$new_checksum = $this->calculateChecksum($product_model);
|
| 554 |
} catch (Exception $e) {
|
| 555 |
-
Mage::log(
|
| 556 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 557 |
|
| 558 |
return 0;
|
| 559 |
}
|
| 560 |
if ($current_checksum == '' || $current_checksum != $new_checksum) {
|
| 561 |
++$num_of_updates;
|
| 562 |
-
$this->updateSavedProductChecksum(
|
| 563 |
-
$
|
| 564 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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');
|
|
@@ -586,11 +910,25 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 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();
|
|
@@ -598,47 +936,76 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 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='
|
|
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
| 634 |
$_tableprefix = (string) Mage::getConfig()->getTablePrefix();
|
| 635 |
-
$tblExist = $write->showTableStatus(
|
|
|
|
|
|
|
| 636 |
|
| 637 |
if (!$tblExist) {
|
| 638 |
return '';
|
| 639 |
}
|
| 640 |
|
| 641 |
-
$sql = 'SELECT * FROM `'
|
|
|
|
| 642 |
$licenseData = $read->fetchAll($sql);
|
| 643 |
if (array_key_exists('server_type', $licenseData[0])) {
|
| 644 |
$key = $licenseData[0]['server_type'];
|
|
@@ -652,23 +1019,37 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 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 |
-
|
| 661 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 662 |
|
| 663 |
if (!$tblExist) {
|
| 664 |
return;
|
| 665 |
}
|
| 666 |
|
| 667 |
-
$sqlFetch = 'SELECT * FROM '.$_tableprefix.
|
|
|
|
| 668 |
$updates = $write->fetchAll($sqlFetch);
|
| 669 |
|
| 670 |
if ($updates && count($updates) != 0) {
|
| 671 |
-
$sql = 'UPDATE '.$_tableprefix.
|
|
|
|
| 672 |
$write->query($sql, array($end_point));
|
| 673 |
} else {
|
| 674 |
Mage::log('cant update server_type', null, 'autocompleteplus.log');
|
|
@@ -678,6 +1059,11 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 678 |
}
|
| 679 |
}
|
| 680 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 681 |
public function getErrormessage()
|
| 682 |
{
|
| 683 |
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
|
@@ -692,7 +1078,8 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 692 |
return '';
|
| 693 |
}
|
| 694 |
|
| 695 |
-
$sql = 'SELECT * FROM `'
|
|
|
|
| 696 |
|
| 697 |
$licenseData = $read->fetchAll($sql);
|
| 698 |
|
|
@@ -701,6 +1088,11 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 701 |
return $errormessage;
|
| 702 |
}
|
| 703 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 704 |
public function getIfSyncWasInitiated()
|
| 705 |
{
|
| 706 |
$collection = Mage::getModel('autocompleteplus_autosuggest/pusher')->getCollection();
|
|
@@ -708,6 +1100,11 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 708 |
return $collection->getSize() > 0;
|
| 709 |
}
|
| 710 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 711 |
public function getPushId()
|
| 712 |
{
|
| 713 |
$collection = Mage::getModel('autocompleteplus_autosuggest/pusher')
|
|
@@ -720,6 +1117,13 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 720 |
return $collection->getLastItem()->getId();
|
| 721 |
}
|
| 722 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 723 |
public function getPushUrl($id = null)
|
| 724 |
{
|
| 725 |
if ($id == null) {
|
|
@@ -729,9 +1133,8 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 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;
|
|
@@ -744,13 +1147,15 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 744 |
|
| 745 |
public function escapeXml($xml)
|
| 746 |
{
|
| 747 |
-
|
| 748 |
-
|
| 749 |
-
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
|
| 753 |
-
|
|
|
|
|
|
|
| 754 |
|
| 755 |
$xml = preg_replace('/[\x00-\x1f]/', '', $xml);
|
| 756 |
|
|
@@ -765,7 +1170,9 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 765 |
*/
|
| 766 |
public function getSessionId()
|
| 767 |
{
|
| 768 |
-
return md5(
|
|
|
|
|
|
|
| 769 |
}
|
| 770 |
|
| 771 |
/**
|
|
@@ -781,8 +1188,10 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 781 |
}
|
| 782 |
|
| 783 |
/**
|
| 784 |
-
*
|
| 785 |
-
*
|
|
|
|
|
|
|
| 786 |
* @return array
|
| 787 |
*/
|
| 788 |
protected function _createMultiStoreByScopeJson($storesArr)
|
|
@@ -790,7 +1199,9 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 790 |
$multistoreData = array();
|
| 791 |
$storeComplete = array();
|
| 792 |
|
| 793 |
-
$storeUrls = $this->getConfigMultiScopesDataByFullPath(
|
|
|
|
|
|
|
| 794 |
$locales = $this->getConfigMultiScopesDataByFullPath('general/locale/code');
|
| 795 |
$useStoreCode = $this->getConfigDataByFullPath('web/url/use_store');
|
| 796 |
|
|
@@ -801,47 +1212,58 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 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 |
-
|
| 810 |
-
|
| 811 |
-
|
| 812 |
-
|
| 813 |
-
|
| 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 |
-
|
| 826 |
-
|
| 827 |
-
|
| 828 |
-
|
| 829 |
-
|
| 830 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 831 |
$storeComplete['url'] = $storeUrls[self::DEFAULT_SCOPE][0];
|
| 832 |
}
|
| 833 |
} else {
|
| 834 |
-
$storeComplete['url'] = $storeUrls[0]
|
| 835 |
}
|
| 836 |
|
| 837 |
$multistoreData[] = $storeComplete;
|
| 838 |
}
|
|
|
|
| 839 |
return $multistoreData;
|
| 840 |
}
|
| 841 |
|
| 842 |
/**
|
| 843 |
-
*
|
| 844 |
-
*
|
|
|
|
|
|
|
| 845 |
* @return array
|
| 846 |
*/
|
| 847 |
protected function _createMultiStoreJson($storesArr)
|
|
@@ -872,11 +1294,12 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 872 |
}
|
| 873 |
|
| 874 |
if ($useStoreCode) {
|
| 875 |
-
$storeComplete['url'] = $storeUrls[0]
|
| 876 |
}
|
| 877 |
|
| 878 |
$multistoreData[] = $storeComplete;
|
| 879 |
}
|
|
|
|
| 880 |
return $multistoreData;
|
| 881 |
}
|
| 882 |
}
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* Data File
|
| 4 |
*
|
| 5 |
* NOTICE OF LICENSE
|
| 6 |
*
|
| 8 |
* that is available through the world-wide-web at this URL:
|
| 9 |
* http://opensource.org/licenses/osl-3.0.php
|
| 10 |
*
|
| 11 |
+
* PHP version 5
|
| 12 |
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Autocompleteplus_Autosuggest_Helper_Data
|
| 24 |
+
*
|
| 25 |
+
* NOTICE OF LICENSE
|
| 26 |
+
*
|
| 27 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 28 |
+
* that is available through the world-wide-web at this URL:
|
| 29 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 30 |
+
*
|
| 31 |
+
* PHP version 5
|
| 32 |
+
*
|
| 33 |
+
* @category Mage
|
| 34 |
+
*
|
| 35 |
+
* @package Instantsearchplus
|
| 36 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 37 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 38 |
+
* @license Open Software License (OSL 3.0)*
|
| 39 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 40 |
*/
|
| 41 |
class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
|
| 42 |
{
|
|
|
|
| 43 |
const WEBSITES_SCOPE = 'websites';
|
| 44 |
|
| 45 |
const STORES_SCOPE = 'stores';
|
| 46 |
|
| 47 |
const DEFAULT_SCOPE = 'default';
|
| 48 |
|
|
|
|
| 49 |
const WEBSITE_ID = 'website_id';
|
| 50 |
|
| 51 |
+
protected $server_url = 'http://magento.instantsearchplus.com';
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
+
/**
|
| 54 |
+
* Return server url
|
| 55 |
+
*
|
| 56 |
+
* @return string
|
| 57 |
+
*/
|
| 58 |
public function getServerUrl()
|
| 59 |
{
|
| 60 |
return $this->server_url;
|
| 61 |
}
|
| 62 |
|
| 63 |
+
/**
|
| 64 |
+
* Validate uuid
|
| 65 |
+
*
|
| 66 |
+
* @param string $uuid comment
|
| 67 |
+
*
|
| 68 |
+
* @return bool
|
| 69 |
+
*/
|
| 70 |
public function validateUuid($uuid)
|
| 71 |
{
|
| 72 |
if (strlen($uuid) == 36
|
| 78 |
return false;
|
| 79 |
}
|
| 80 |
|
| 81 |
+
/**
|
| 82 |
+
* Return extension config model
|
| 83 |
+
*
|
| 84 |
+
* @return false|Mage_Core_Model_Abstract
|
| 85 |
+
*/
|
| 86 |
public function getConfig()
|
| 87 |
{
|
| 88 |
return Mage::getModel('autocompleteplus_autosuggest/config');
|
| 89 |
}
|
| 90 |
|
| 91 |
+
/**
|
| 92 |
+
* Return Magento version
|
| 93 |
+
*
|
| 94 |
+
* @return string
|
| 95 |
+
*/
|
| 96 |
public function getMageVersion()
|
| 97 |
{
|
| 98 |
return Mage::getVersion();
|
| 99 |
}
|
| 100 |
|
| 101 |
+
/**
|
| 102 |
+
* Return Extension version
|
| 103 |
+
*
|
| 104 |
+
* @return string
|
| 105 |
+
*/
|
| 106 |
public function getVersion()
|
| 107 |
{
|
| 108 |
+
return (string) Mage::getConfig()
|
| 109 |
+
->getModuleConfig('Autocompleteplus_Autosuggest')
|
| 110 |
+
->version;
|
| 111 |
}
|
| 112 |
|
| 113 |
+
/**
|
| 114 |
+
* Get data from magento config by path
|
| 115 |
+
*
|
| 116 |
+
* @param string $path comment
|
| 117 |
+
*
|
| 118 |
+
* @return mixed|string
|
| 119 |
+
*/
|
| 120 |
public function getConfigDataByFullPath($path)
|
| 121 |
{
|
| 122 |
$valsArr = $this->getConfigMultiDataByFullPath($path);
|
| 130 |
return $value;
|
| 131 |
}
|
| 132 |
|
| 133 |
+
/**
|
| 134 |
+
* Get multi line data from magento config by path
|
| 135 |
+
*
|
| 136 |
+
* @param string $path comment
|
| 137 |
+
*
|
| 138 |
+
* @return mixed|string
|
| 139 |
+
*/
|
| 140 |
public function getConfigMultiDataByFullPath($path)
|
| 141 |
{
|
| 142 |
$values = array();
|
| 143 |
|
| 144 |
+
$rows = Mage::getSingleton('core/config_data')
|
| 145 |
+
->getCollection()
|
| 146 |
+
->getItemsByColumnValue('path', $path);
|
| 147 |
+
|
| 148 |
+
if (!$rows) {
|
| 149 |
+
$conf = Mage::getSingleton('core/config')
|
| 150 |
+
->init()
|
| 151 |
+
->getXpath('/config/default/'.$path);
|
| 152 |
$values[] = array_shift($conf);
|
|
|
|
| 153 |
|
| 154 |
+
} else {
|
| 155 |
foreach ($rows as $row) {
|
| 156 |
$scopeId = $row->getScopeId();
|
| 157 |
|
| 166 |
return $values;
|
| 167 |
}
|
| 168 |
|
| 169 |
+
/**
|
| 170 |
+
* Get multi line data by scopes
|
| 171 |
+
* from magento config by path
|
| 172 |
+
*
|
| 173 |
+
* @param string $path comment
|
| 174 |
+
*
|
| 175 |
+
* @return mixed|string
|
| 176 |
+
*/
|
| 177 |
public function getConfigMultiScopesDataByFullPath($path)
|
| 178 |
{
|
| 179 |
$values = array();
|
| 180 |
|
| 181 |
+
$rows = Mage::getSingleton('core/config_data')
|
| 182 |
+
->getCollection()
|
| 183 |
+
->getItemsByColumnValue('path', $path);
|
| 184 |
|
| 185 |
foreach ($rows as $row) {
|
| 186 |
$scope = $row->getScope();
|
| 190 |
$rowValue = $row->getValue();
|
| 191 |
|
| 192 |
if ($scope != null && $scopeId != null && $rowValue != null) {
|
| 193 |
+
if (!array_key_exists($scope, $values)) {
|
|
|
|
| 194 |
$values[$scope] = array();
|
| 195 |
}
|
| 196 |
|
| 198 |
}
|
| 199 |
}
|
| 200 |
|
|
|
|
| 201 |
return $values;
|
| 202 |
}
|
| 203 |
|
| 204 |
+
/**
|
| 205 |
+
* Send curl request
|
| 206 |
+
*
|
| 207 |
+
* @param string $command comment
|
| 208 |
+
*
|
| 209 |
+
* @return mixed|string
|
| 210 |
+
*/
|
| 211 |
public function sendCurl($command)
|
| 212 |
{
|
| 213 |
if (isset($ch)) {
|
| 228 |
return $str;
|
| 229 |
}
|
| 230 |
|
| 231 |
+
/**
|
| 232 |
+
* Send curl POST request
|
| 233 |
+
*
|
| 234 |
+
* @param string $command comment
|
| 235 |
+
* @param array $data comment
|
| 236 |
+
* @param string $cookie_file comment
|
| 237 |
+
*
|
| 238 |
+
* @return mixed|string
|
| 239 |
+
*/
|
| 240 |
+
public static function sendPostCurl(
|
| 241 |
+
$command,
|
| 242 |
+
$data = array(),
|
| 243 |
+
$cookie_file = 'genCookie.txt'
|
| 244 |
+
) {
|
| 245 |
if (isset($ch)) {
|
| 246 |
unset($ch);
|
| 247 |
}
|
| 254 |
curl_setopt($ch, CURLOPT_HEADER, 0);
|
| 255 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
| 256 |
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
|
| 257 |
+
curl_setopt(
|
| 258 |
+
$ch,
|
| 259 |
+
CURLOPT_USERAGENT,
|
| 260 |
+
'Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20100101 Firefox/21.0'
|
| 261 |
+
);
|
| 262 |
//curl_setopt($ch,CURLOPT_POST,0);
|
| 263 |
if (!empty($data)) {
|
| 264 |
+
curl_setopt_array(
|
| 265 |
+
$ch,
|
| 266 |
+
array(
|
| 267 |
CURLOPT_POSTFIELDS => $data,
|
| 268 |
+
)
|
| 269 |
+
);
|
| 270 |
}
|
| 271 |
|
| 272 |
+
/**
|
| 273 |
+
* Setting Http Header
|
| 274 |
+
* curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
| 275 |
+
* 'Connection: Keep-Alive',
|
| 276 |
+
* 'Keep-Alive: 800'
|
| 277 |
+
* ));
|
| 278 |
+
*/
|
| 279 |
+
|
| 280 |
|
| 281 |
$str = curl_exec($ch);
|
| 282 |
} else {
|
| 286 |
return $str;
|
| 287 |
}
|
| 288 |
|
| 289 |
+
/**
|
| 290 |
+
* Prepare grouped product price
|
| 291 |
+
*
|
| 292 |
+
* @param mixed $groupedProduct comment
|
| 293 |
+
*
|
| 294 |
+
* @return void
|
| 295 |
+
*/
|
| 296 |
public function prepareGroupedProductPrice($groupedProduct)
|
| 297 |
{
|
| 298 |
+
$aProductIds = $groupedProduct
|
| 299 |
+
->getTypeInstance()
|
| 300 |
+
->getChildrenIds($groupedProduct->getId());
|
| 301 |
|
| 302 |
$prices = array();
|
| 303 |
foreach ($aProductIds as $ids) {
|
| 322 |
$groupedProduct->setPrice(0);
|
| 323 |
}
|
| 324 |
|
| 325 |
+
/**
|
| 326 |
+
* Or you can return price
|
| 327 |
+
*/
|
| 328 |
}
|
| 329 |
|
| 330 |
+
/**
|
| 331 |
+
* Get bundled product price
|
| 332 |
+
*
|
| 333 |
+
* @param mixed $product comment
|
| 334 |
+
*
|
| 335 |
+
* @return float
|
| 336 |
+
*/
|
| 337 |
public function getBundlePrice($product)
|
| 338 |
{
|
| 339 |
$optionCol = $product->getTypeInstance(true)
|
| 370 |
return $price;
|
| 371 |
}
|
| 372 |
|
| 373 |
+
/**
|
| 374 |
+
* Get multi stores json
|
| 375 |
+
*
|
| 376 |
+
* @return string
|
| 377 |
+
*/
|
| 378 |
public function getMultiStoreDataJson()
|
| 379 |
{
|
| 380 |
$websites = Mage::getModel('core/website')->getCollection();
|
| 382 |
$ext = Mage::helper('autocompleteplus_autosuggest')->getVersion();
|
| 383 |
$version = array('mage' => $mage, 'ext' => $ext);
|
| 384 |
|
| 385 |
+
/**
|
| 386 |
+
* Getting site url
|
| 387 |
+
*/
|
| 388 |
$url = $this->getConfigDataByFullPath('web/unsecure/base_url');
|
| 389 |
|
| 390 |
+
/**
|
| 391 |
+
* Getting site owner email
|
| 392 |
+
*/
|
| 393 |
+
$storeMail = $this->getConfigDataByFullPath(
|
| 394 |
+
'autocompleteplus/config/store_email'
|
| 395 |
+
);
|
| 396 |
|
| 397 |
if (!$storeMail) {
|
| 398 |
+
$storeMail = $this->getConfigDataByFullPath(
|
| 399 |
+
'trans_email/ident_general/email'
|
| 400 |
+
);
|
| 401 |
}
|
| 402 |
|
| 403 |
$storesArr = array();
|
| 445 |
return $multistoreJson;
|
| 446 |
}
|
| 447 |
|
| 448 |
+
/**
|
| 449 |
+
* Get extension conflicts
|
| 450 |
+
*
|
| 451 |
+
* @param bool $all_conflicts comment
|
| 452 |
+
*
|
| 453 |
+
* @return array
|
| 454 |
+
*/
|
| 455 |
public function getExtensionConflict($all_conflicts = false)
|
| 456 |
{
|
| 457 |
$all_rewrite_classes = array();
|
| 458 |
$node_type_list = array('model', 'helper', 'block');
|
| 459 |
|
| 460 |
foreach ($node_type_list as $node_type) {
|
| 461 |
+
$children = Mage::getConfig()->getNode('modules')->children();
|
| 462 |
+
|
| 463 |
+
foreach ($children as $name => $module) {
|
| 464 |
if ($module->codePool == 'core' || $module->active != 'true') {
|
| 465 |
continue;
|
| 466 |
}
|
| 467 |
+
$config_file_path = Mage::getConfig()
|
| 468 |
+
->getModuleDir('etc', $name).DS.'config.xml';
|
| 469 |
$config = new Varien_Simplexml_Config();
|
| 470 |
$config->loadString('<config/>');
|
| 471 |
$config->loadFile($config_file_path);
|
| 477 |
}
|
| 478 |
foreach ($nodes->children() as $node_name => $config) {
|
| 479 |
if ($config->rewrite) { // there is rewrite for current config
|
| 480 |
+
$reWriteChildren = $config->rewrite->children();
|
| 481 |
+
|
| 482 |
+
foreach ($reWriteChildren as $class_tag => $derived_class) {
|
| 483 |
+
$base_class_name = $this->_getMageBaseClass(
|
| 484 |
+
$node_type, $node_name, $class_tag
|
| 485 |
+
);
|
| 486 |
|
| 487 |
$lead_derived_class = '';
|
| 488 |
+
$conf = Mage::getConfig()
|
| 489 |
+
->getNode()
|
| 490 |
+
->global
|
| 491 |
+
->{$node_type.'s'}->{$node_name};
|
| 492 |
+
|
| 493 |
if (isset($conf->rewrite->$class_tag)) {
|
| 494 |
+
$lead_derived_class = (string) $conf
|
| 495 |
+
->rewrite->$class_tag;
|
| 496 |
}
|
| 497 |
if ($derived_class == '') {
|
| 498 |
$derived_class = $lead_derived_class;
|
| 506 |
'name' => array((string) $name),
|
| 507 |
);
|
| 508 |
} else {
|
| 509 |
+
array_push(
|
| 510 |
+
$all_rewrite_classes[$base_class_name]['derived'],
|
| 511 |
+
(string) $derived_class
|
| 512 |
+
);
|
| 513 |
+
array_push(
|
| 514 |
+
$all_rewrite_classes[$base_class_name]['name'],
|
| 515 |
+
(string) $name
|
| 516 |
+
);
|
| 517 |
}
|
| 518 |
}
|
| 519 |
}
|
| 527 |
$isp_rewrite_classes = array();
|
| 528 |
$isp_module_name = 'Autocompleteplus_Autosuggest';
|
| 529 |
foreach ($all_rewrite_classes as $base => $conflict_info) {
|
| 530 |
+
/**
|
| 531 |
+
* If isp extension rewrite this base class
|
| 532 |
+
*/
|
| 533 |
+
if (in_array($isp_module_name, $conflict_info['name'])) {
|
| 534 |
+
/**
|
| 535 |
+
* More then 1 class rewrite this base class => there is a conflict
|
| 536 |
+
*/
|
| 537 |
+
if (count($conflict_info['derived']) > 1) {
|
| 538 |
$isp_rewrite_classes[$base] = $conflict_info;
|
| 539 |
}
|
| 540 |
}
|
| 543 |
return $isp_rewrite_classes;
|
| 544 |
}
|
| 545 |
|
| 546 |
+
/**
|
| 547 |
+
* Get Mage base class
|
| 548 |
+
*
|
| 549 |
+
* @param string $node_type param
|
| 550 |
+
* @param string $node_name param
|
| 551 |
+
* @param string $class_tag param
|
| 552 |
+
*
|
| 553 |
+
* @return string
|
| 554 |
+
*/
|
| 555 |
protected function _getMageBaseClass($node_type, $node_name, $class_tag)
|
| 556 |
{
|
| 557 |
$config = Mage::getConfig()->getNode()->global->{$node_type.'s'}->$node_name;
|
| 571 |
|
| 572 |
/**
|
| 573 |
* Checksum functionality.
|
| 574 |
+
*
|
| 575 |
+
* @return bool
|
| 576 |
*/
|
| 577 |
public function isChecksumTableExists()
|
| 578 |
{
|
| 585 |
}
|
| 586 |
}
|
| 587 |
|
| 588 |
+
/**
|
| 589 |
+
* Calculate checksum
|
| 590 |
+
*
|
| 591 |
+
* @param mixed $product param
|
| 592 |
+
*
|
| 593 |
+
* @return string
|
| 594 |
+
*/
|
| 595 |
public function calculateChecksum($product)
|
| 596 |
{
|
| 597 |
$product_id = $product->getId();
|
| 598 |
$product_title = $product->getName();
|
| 599 |
$product_description = $product->getDescription();
|
| 600 |
$product_short_desc = $product->getShortDescription();
|
| 601 |
+
/**
|
| 602 |
+
* Mage::helper('catalog/product')->getProductUrl($product_id);
|
| 603 |
+
* $product->getProductUrl()
|
| 604 |
+
*/
|
| 605 |
+
$product_url = $product->getUrlPath();
|
| 606 |
$product_visibility = $product->getVisibility();
|
| 607 |
$product_in_stock = $product->isInStock();
|
| 608 |
$product_price = (float) $product->getPrice();
|
| 609 |
try {
|
| 610 |
$product_thumb_url = '/'.$product->getImage();
|
| 611 |
|
| 612 |
+
/**
|
| 613 |
+
* Gets thumbs code
|
| 614 |
+
* $product_thumb_url = $product->getThumbnailUrl();
|
| 615 |
+
* //Mage::helper('catalog/image')->init($product, 'thumbnail');
|
| 616 |
+
* $thumb_pattern = '/\/[^\/]+(?![^\/]*\/)/';
|
| 617 |
+
* if (preg_match($thumb_pattern, $product_thumb_url, $matches)
|
| 618 |
+
* && count($matches) > 0){
|
| 619 |
+
* $product_thumb_url = $matches[0];
|
| 620 |
+
* } else {
|
| 621 |
+
* $product_thumb_url = '';
|
| 622 |
+
* }
|
| 623 |
+
*/
|
| 624 |
} catch (Exception $e) {
|
| 625 |
$product_thumb_url = '';
|
| 626 |
}
|
| 627 |
$product_type = $product->getTypeID();
|
| 628 |
|
| 629 |
+
$checksum_string = $product_id.$product_title.$product_description.
|
| 630 |
+
$product_short_desc.$product_url.
|
| 631 |
+
$product_visibility.$product_in_stock.$product_price.
|
| 632 |
+
$product_thumb_url.$product_type;
|
| 633 |
|
| 634 |
$checksum_md5 = md5($checksum_string);
|
| 635 |
|
| 636 |
return $checksum_md5;
|
| 637 |
}
|
| 638 |
|
| 639 |
+
/**
|
| 640 |
+
* Get saved checksum
|
| 641 |
+
*
|
| 642 |
+
* @param string $table_prefix param
|
| 643 |
+
* @param mixed $read param
|
| 644 |
+
* @param int $product_id param
|
| 645 |
+
* @param int $store_id param
|
| 646 |
+
*
|
| 647 |
+
* @return string
|
| 648 |
+
*/
|
| 649 |
public function getSavedChecksum($table_prefix, $read, $product_id, $store_id)
|
| 650 |
{
|
| 651 |
+
$sql_fetch = 'SELECT checksum FROM '.$table_prefix.
|
| 652 |
+
'autocompleteplus_checksum WHERE identifier=? AND store_id=?';
|
| 653 |
$updates = $read->fetchAll($sql_fetch, array($product_id, $store_id));
|
| 654 |
if ($updates && (count($updates) != 0)) {
|
| 655 |
return $updates[0]['checksum'];
|
| 658 |
}
|
| 659 |
}
|
| 660 |
|
| 661 |
+
/**
|
| 662 |
+
* Update checksum
|
| 663 |
+
*
|
| 664 |
+
* @param mixed $product_id param
|
| 665 |
+
* @param string $sku param
|
| 666 |
+
* @param mixed $store_id param
|
| 667 |
+
* @param mixed $checksum param
|
| 668 |
+
*
|
| 669 |
+
* @return void
|
| 670 |
+
*/
|
| 671 |
+
public function updateSavedProductChecksum(
|
| 672 |
+
$product_id,
|
| 673 |
+
$sku,
|
| 674 |
+
$store_id,
|
| 675 |
+
$checksum
|
| 676 |
+
) {
|
| 677 |
return;
|
| 678 |
if ($product_id == null || $sku == null) {
|
| 679 |
return;
|
| 698 |
}
|
| 699 |
}
|
| 700 |
|
| 701 |
+
/**
|
| 702 |
+
* Update Deleted Product Checksum
|
| 703 |
+
*
|
| 704 |
+
* @param mixed $table_prefix param
|
| 705 |
+
* @param mixed $read param
|
| 706 |
+
* @param mixed $write param
|
| 707 |
+
* @param mixed $product_id param
|
| 708 |
+
* @param mixed $sku param
|
| 709 |
+
* @param mixed $store_id param
|
| 710 |
+
*
|
| 711 |
+
* @return void
|
| 712 |
+
*/
|
| 713 |
public function updateDeletedProductChecksum($table_prefix, $read, $write, $product_id, $sku, $store_id)
|
| 714 |
{
|
| 715 |
return;
|
| 717 |
return;
|
| 718 |
}
|
| 719 |
|
| 720 |
+
$checksums = Mage::getModel('autocompleteplus_autosuggest/checksum')
|
| 721 |
+
->getCollection()
|
| 722 |
->addFieldToFilter('identifier', $product_id)
|
| 723 |
->addFieldToFilter('store_id', $store_id);
|
| 724 |
|
| 729 |
}
|
| 730 |
}
|
| 731 |
|
| 732 |
+
/**
|
| 733 |
+
* Set Update Needed For Product
|
| 734 |
+
*
|
| 735 |
+
* @param mixed $read param
|
| 736 |
+
* @param mixed $write param
|
| 737 |
+
* @param mixed $product_id param
|
| 738 |
+
* @param mixed $product_sku param
|
| 739 |
+
* @param mixed $store_id param
|
| 740 |
+
*
|
| 741 |
+
* @return void
|
| 742 |
+
*/
|
| 743 |
+
private function setUpdateNeededForProduct(
|
| 744 |
+
$read,
|
| 745 |
+
$write,
|
| 746 |
+
$product_id,
|
| 747 |
+
$product_sku,
|
| 748 |
+
$store_id
|
| 749 |
+
) {
|
| 750 |
if ($product_id == null) {
|
| 751 |
return;
|
| 752 |
}
|
| 755 |
}
|
| 756 |
try {
|
| 757 |
$table_prefix = (string) Mage::getConfig()->getTablePrefix();
|
| 758 |
+
$is_table_exist = $write
|
| 759 |
+
->showTableStatus($table_prefix.'autocompleteplus_batches');
|
| 760 |
+
|
| 761 |
+
/**
|
| 762 |
+
* Table not exists
|
| 763 |
+
*/
|
| 764 |
+
if (!$is_table_exist) {
|
| 765 |
return;
|
| 766 |
}
|
| 767 |
|
| 768 |
+
$sql_fetch = 'SELECT * FROM '.
|
| 769 |
+
$table_prefix.
|
| 770 |
+
'autocompleteplus_batches WHERE product_id=? AND store_id=?';
|
| 771 |
$updates = $read->fetchAll($sql_fetch, array($product_id, $store_id));
|
| 772 |
|
| 773 |
if ($updates && (count($updates) != 0)) {
|
| 774 |
+
$sql = 'UPDATE '.$table_prefix.
|
| 775 |
+
'autocompleteplus_batches SET update_date=?,action=? WHERE product_id=? AND store_id=?';
|
| 776 |
+
$write->query(
|
| 777 |
+
$sql,
|
| 778 |
+
array(strtotime('now'), 'update', $product_id, $store_id)
|
| 779 |
+
);
|
| 780 |
} else {
|
| 781 |
+
$sql = 'INSERT INTO '.
|
| 782 |
+
$table_prefix.
|
| 783 |
+
'autocompleteplus_batches (product_id,store_id,update_date,action,sku) VALUES (?,?,?,?,?)';
|
| 784 |
+
$write->query(
|
| 785 |
+
$sql,
|
| 786 |
+
array($product_id,
|
| 787 |
+
$store_id,
|
| 788 |
+
strtotime('now'),
|
| 789 |
+
'update',
|
| 790 |
+
$product_sku
|
| 791 |
+
)
|
| 792 |
+
);
|
| 793 |
}
|
| 794 |
} catch (Exception $e) {
|
| 795 |
+
Mage::log(
|
| 796 |
+
'Exception raised in setUpdateNeededForProduct()- '.$e->getMessage(),
|
| 797 |
+
null,
|
| 798 |
+
'autocompleteplus.log'
|
| 799 |
+
);
|
| 800 |
+
$this->ispErrorLog(
|
| 801 |
+
'Exception raised in setUpdateNeededForProduct() - '.$e->getMessage()
|
| 802 |
+
);
|
| 803 |
}
|
| 804 |
}
|
| 805 |
|
| 806 |
+
/**
|
| 807 |
+
* Compare product check sum
|
| 808 |
+
*
|
| 809 |
+
* @param int $from param
|
| 810 |
+
* @param int $count param
|
| 811 |
+
* @param null $store_id param
|
| 812 |
+
*
|
| 813 |
+
* @return int|void
|
| 814 |
+
*/
|
| 815 |
public function compareProductsChecksum($from, $count, $store_id = null)
|
| 816 |
{
|
| 817 |
$num_of_updates = 0;
|
| 837 |
->setStore($store_id)->setStoreId($store_id)
|
| 838 |
->load($product_collection_data['entity_id']);
|
| 839 |
|
| 840 |
+
$current_checksum = $this->getSavedChecksum(
|
| 841 |
+
$table_prefix,
|
| 842 |
+
$read,
|
| 843 |
+
$product_model->getId(),
|
| 844 |
+
$store_id
|
| 845 |
+
);
|
| 846 |
$new_checksum = $this->calculateChecksum($product_model);
|
| 847 |
} catch (Exception $e) {
|
| 848 |
+
Mage::log(
|
| 849 |
+
'Exception raised in compareProductsChecksum() on id: '.
|
| 850 |
+
$product->getId().' -> '.$e->getMessage(),
|
| 851 |
+
null,
|
| 852 |
+
'autocompleteplus.log'
|
| 853 |
+
);
|
| 854 |
+
$this->ispErrorLog(
|
| 855 |
+
'Exception raised in compareProductsChecksum() on id: '.
|
| 856 |
+
$product->getId().' -> '.$e->getMessage()
|
| 857 |
+
);
|
| 858 |
|
| 859 |
return 0;
|
| 860 |
}
|
| 861 |
if ($current_checksum == '' || $current_checksum != $new_checksum) {
|
| 862 |
++$num_of_updates;
|
| 863 |
+
$this->updateSavedProductChecksum(
|
| 864 |
+
$table_prefix,
|
| 865 |
+
$read,
|
| 866 |
+
$write,
|
| 867 |
+
$product_model->getId(),
|
| 868 |
+
$product_model->getSku(),
|
| 869 |
+
$store_id, $new_checksum
|
| 870 |
+
);
|
| 871 |
+
$this->setUpdateNeededForProduct(
|
| 872 |
+
$read,
|
| 873 |
+
$write,
|
| 874 |
+
$product_model->getId(),
|
| 875 |
+
$product_model->getSku(),
|
| 876 |
+
$store_id
|
| 877 |
+
);
|
| 878 |
}
|
| 879 |
}
|
| 880 |
|
| 881 |
return $num_of_updates;
|
| 882 |
}
|
| 883 |
|
| 884 |
+
/**
|
| 885 |
+
* Delete product from table
|
| 886 |
+
*
|
| 887 |
+
* @param mixed $read param
|
| 888 |
+
* @param mixed $write param
|
| 889 |
+
* @param mixed $table_prefix param
|
| 890 |
+
* @param int $product_id param
|
| 891 |
+
* @param int $store_id param
|
| 892 |
+
*
|
| 893 |
+
* @return void
|
| 894 |
+
*/
|
| 895 |
public function deleteProductFromTables($read, $write, $table_prefix, $product_id, $store_id)
|
| 896 |
{
|
| 897 |
$dt = strtotime('now');
|
| 910 |
$this->updateDeletedProductChecksum($table_prefix, $read, $write, $product_id, $sku, $store_id);
|
| 911 |
}
|
| 912 |
|
| 913 |
+
/**
|
| 914 |
+
* IspLog
|
| 915 |
+
*
|
| 916 |
+
* @param string $log comment
|
| 917 |
+
*
|
| 918 |
+
* @return void
|
| 919 |
+
*/
|
| 920 |
public function ispLog($log)
|
| 921 |
{
|
| 922 |
Mage::log($log, null, 'autocompleteplus.log');
|
| 923 |
}
|
| 924 |
|
| 925 |
+
/**
|
| 926 |
+
* IspErrorLog
|
| 927 |
+
*
|
| 928 |
+
* @param string $log comment
|
| 929 |
+
*
|
| 930 |
+
* @return void
|
| 931 |
+
*/
|
| 932 |
public function ispErrorLog($log)
|
| 933 |
{
|
| 934 |
$uuid = $this->getUUID();
|
| 936 |
$store_id = Mage::app()->getStore()->getStoreId();
|
| 937 |
|
| 938 |
$server_url = $this->server_url.'/magento_logging_error';
|
| 939 |
+
$request = $server_url.'?uuid='.$uuid.'&site_url='.
|
| 940 |
+
$site_url.'&store_id='.$store_id.'&msg='.urlencode($log);
|
| 941 |
|
| 942 |
$resp = $this->sendCurl($request);
|
| 943 |
}
|
| 944 |
|
| 945 |
+
/**
|
| 946 |
+
* GetUUID
|
| 947 |
+
*
|
| 948 |
+
* @return mixed
|
| 949 |
+
*/
|
| 950 |
public function getUUID()
|
| 951 |
{
|
| 952 |
return $this->getConfig()->getUUID();
|
| 953 |
}
|
| 954 |
|
| 955 |
/**
|
| 956 |
+
* Deprecated, use getAuthorizationKey().
|
| 957 |
+
*
|
| 958 |
+
* @return string | null
|
| 959 |
*/
|
| 960 |
public function getKey()
|
| 961 |
{
|
| 962 |
return $this->getAuthorizationKey();
|
| 963 |
}
|
| 964 |
|
| 965 |
+
/**
|
| 966 |
+
* GetAuthorizationKey
|
| 967 |
+
*
|
| 968 |
+
* @return string | null
|
| 969 |
+
*/
|
| 970 |
public function getAuthorizationKey()
|
| 971 |
{
|
| 972 |
return $this->getConfig()->getAuthorizationKey();
|
| 973 |
}
|
| 974 |
|
| 975 |
+
/**
|
| 976 |
+
* GetIsReachable
|
| 977 |
+
*
|
| 978 |
+
* @return string | null
|
| 979 |
+
*/
|
| 980 |
public function getIsReachable()
|
| 981 |
{
|
| 982 |
return $this->getConfig()->isReachable();
|
| 983 |
}
|
| 984 |
|
| 985 |
+
/**
|
| 986 |
+
* GetServerEndPoint
|
| 987 |
+
*
|
| 988 |
+
* @return string
|
| 989 |
+
*/
|
| 990 |
public function getServerEndPoint()
|
| 991 |
{
|
| 992 |
try {
|
| 993 |
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 994 |
+
|
| 995 |
+
$write = Mage::getSingleton('core/resource')
|
| 996 |
+
->getConnection('core_write');
|
| 997 |
+
|
| 998 |
$_tableprefix = (string) Mage::getConfig()->getTablePrefix();
|
| 999 |
+
$tblExist = $write->showTableStatus(
|
| 1000 |
+
$_tableprefix.'autocompleteplus_config'
|
| 1001 |
+
);
|
| 1002 |
|
| 1003 |
if (!$tblExist) {
|
| 1004 |
return '';
|
| 1005 |
}
|
| 1006 |
|
| 1007 |
+
$sql = 'SELECT * FROM `'.
|
| 1008 |
+
$_tableprefix.'autocompleteplus_config` WHERE `id` =1';
|
| 1009 |
$licenseData = $read->fetchAll($sql);
|
| 1010 |
if (array_key_exists('server_type', $licenseData[0])) {
|
| 1011 |
$key = $licenseData[0]['server_type'];
|
| 1019 |
return $key;
|
| 1020 |
}
|
| 1021 |
|
| 1022 |
+
/**
|
| 1023 |
+
* SetServerEndPoint
|
| 1024 |
+
*
|
| 1025 |
+
* @param string $end_point comment
|
| 1026 |
+
*
|
| 1027 |
+
* @return void
|
| 1028 |
+
*/
|
| 1029 |
public function setServerEndPoint($end_point)
|
| 1030 |
{
|
| 1031 |
try {
|
| 1032 |
$_tableprefix = (string) Mage::getConfig()->getTablePrefix();
|
| 1033 |
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 1034 |
+
|
| 1035 |
+
$write = Mage::getSingleton('core/resource')
|
| 1036 |
+
->getConnection('core_write');
|
| 1037 |
+
|
| 1038 |
+
$tblExist = $write->showTableStatus(
|
| 1039 |
+
$_tableprefix.'autocompleteplus_config'
|
| 1040 |
+
);
|
| 1041 |
|
| 1042 |
if (!$tblExist) {
|
| 1043 |
return;
|
| 1044 |
}
|
| 1045 |
|
| 1046 |
+
$sqlFetch = 'SELECT * FROM '.$_tableprefix.
|
| 1047 |
+
'autocompleteplus_config WHERE id = 1';
|
| 1048 |
$updates = $write->fetchAll($sqlFetch);
|
| 1049 |
|
| 1050 |
if ($updates && count($updates) != 0) {
|
| 1051 |
+
$sql = 'UPDATE '.$_tableprefix.
|
| 1052 |
+
'autocompleteplus_config SET server_type=? WHERE id = 1';
|
| 1053 |
$write->query($sql, array($end_point));
|
| 1054 |
} else {
|
| 1055 |
Mage::log('cant update server_type', null, 'autocompleteplus.log');
|
| 1059 |
}
|
| 1060 |
}
|
| 1061 |
|
| 1062 |
+
/**
|
| 1063 |
+
* GetErrormessage
|
| 1064 |
+
*
|
| 1065 |
+
* @return string
|
| 1066 |
+
*/
|
| 1067 |
public function getErrormessage()
|
| 1068 |
{
|
| 1069 |
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 1078 |
return '';
|
| 1079 |
}
|
| 1080 |
|
| 1081 |
+
$sql = 'SELECT * FROM `'.
|
| 1082 |
+
$_tableprefix.'autocompleteplus_config` WHERE `id` =1';
|
| 1083 |
|
| 1084 |
$licenseData = $read->fetchAll($sql);
|
| 1085 |
|
| 1088 |
return $errormessage;
|
| 1089 |
}
|
| 1090 |
|
| 1091 |
+
/**
|
| 1092 |
+
* GetIfSyncWasInitiated
|
| 1093 |
+
*
|
| 1094 |
+
* @return bool
|
| 1095 |
+
*/
|
| 1096 |
public function getIfSyncWasInitiated()
|
| 1097 |
{
|
| 1098 |
$collection = Mage::getModel('autocompleteplus_autosuggest/pusher')->getCollection();
|
| 1100 |
return $collection->getSize() > 0;
|
| 1101 |
}
|
| 1102 |
|
| 1103 |
+
/**
|
| 1104 |
+
* GetPushId
|
| 1105 |
+
*
|
| 1106 |
+
* @return mixed
|
| 1107 |
+
*/
|
| 1108 |
public function getPushId()
|
| 1109 |
{
|
| 1110 |
$collection = Mage::getModel('autocompleteplus_autosuggest/pusher')
|
| 1117 |
return $collection->getLastItem()->getId();
|
| 1118 |
}
|
| 1119 |
|
| 1120 |
+
/**
|
| 1121 |
+
* GetPushUrl
|
| 1122 |
+
*
|
| 1123 |
+
* @param null $id comment
|
| 1124 |
+
*
|
| 1125 |
+
* @return string
|
| 1126 |
+
*/
|
| 1127 |
public function getPushUrl($id = null)
|
| 1128 |
{
|
| 1129 |
if ($id == null) {
|
| 1133 |
$url = Mage::getUrl();
|
| 1134 |
|
| 1135 |
if (strpos($url, 'index.php') !== false) {
|
|
|
|
| 1136 |
if (substr($url, -1) != '/') {
|
| 1137 |
+
$url .= '/';
|
| 1138 |
}
|
| 1139 |
|
| 1140 |
$url = $url.'autocompleteplus/products/pushbulk/pushid/'.$id;
|
| 1147 |
|
| 1148 |
public function escapeXml($xml)
|
| 1149 |
{
|
| 1150 |
+
/**
|
| 1151 |
+
* $pairs = array(
|
| 1152 |
+
* "\x03" => "",
|
| 1153 |
+
* "\x05" => "",
|
| 1154 |
+
* "\x0E" => "",
|
| 1155 |
+
* "\x16" => "",
|
| 1156 |
+
* );
|
| 1157 |
+
* $xml = strtr($xml, $pairs);
|
| 1158 |
+
*/
|
| 1159 |
|
| 1160 |
$xml = preg_replace('/[\x00-\x1f]/', '', $xml);
|
| 1161 |
|
| 1170 |
*/
|
| 1171 |
public function getSessionId()
|
| 1172 |
{
|
| 1173 |
+
return md5(
|
| 1174 |
+
Mage::app()->getCookie()->get('frontend').$this->_getEncryptionKey()
|
| 1175 |
+
);
|
| 1176 |
}
|
| 1177 |
|
| 1178 |
/**
|
| 1188 |
}
|
| 1189 |
|
| 1190 |
/**
|
| 1191 |
+
* CreateMultiStoreByScopeJson
|
| 1192 |
+
*
|
| 1193 |
+
* @param array $storesArr comment
|
| 1194 |
+
*
|
| 1195 |
* @return array
|
| 1196 |
*/
|
| 1197 |
protected function _createMultiStoreByScopeJson($storesArr)
|
| 1199 |
$multistoreData = array();
|
| 1200 |
$storeComplete = array();
|
| 1201 |
|
| 1202 |
+
$storeUrls = $this->getConfigMultiScopesDataByFullPath(
|
| 1203 |
+
'web/unsecure/base_url'
|
| 1204 |
+
);
|
| 1205 |
$locales = $this->getConfigMultiScopesDataByFullPath('general/locale/code');
|
| 1206 |
$useStoreCode = $this->getConfigDataByFullPath('web/url/use_store');
|
| 1207 |
|
| 1212 |
|
| 1213 |
$storeComplete = $value;
|
| 1214 |
|
| 1215 |
+
if (array_key_exists(self::STORES_SCOPE, $locales)
|
| 1216 |
+
&& array_key_exists($storeId, $locales[self::STORES_SCOPE])
|
| 1217 |
+
) {
|
| 1218 |
$storeComplete['lang'] = $locales[self::STORES_SCOPE][$storeId];
|
| 1219 |
+
} elseif (array_key_exists(self::WEBSITES_SCOPE, $locales)
|
| 1220 |
+
&& array_key_exists(
|
| 1221 |
+
$storeComplete[self::WEBSITE_ID], $locales[self::WEBSITES_SCOPE]
|
| 1222 |
+
)
|
| 1223 |
+
) {
|
| 1224 |
+
$storeComplete['lang'] = $locales[self::WEBSITES_SCOPE]
|
| 1225 |
+
[$storeComplete[self::WEBSITE_ID]];
|
| 1226 |
+
|
| 1227 |
+
} elseif (array_key_exists(self::DEFAULT_SCOPE, $locales)
|
| 1228 |
+
&& array_key_exists(0, $locales[self::DEFAULT_SCOPE])
|
| 1229 |
+
) {
|
| 1230 |
$storeComplete['lang'] = $locales[self::DEFAULT_SCOPE][0];
|
| 1231 |
}
|
| 1232 |
|
|
|
|
| 1233 |
if (!$useStoreCode) {
|
| 1234 |
+
if (array_key_exists(self::STORES_SCOPE, $storeUrls)
|
| 1235 |
+
&& array_key_exists($storeId, $storeUrls[self::STORES_SCOPE])
|
| 1236 |
+
) {
|
| 1237 |
$storeComplete['url'] = $storeUrls[self::STORES_SCOPE][$storeId];
|
| 1238 |
+
} elseif (array_key_exists(self::WEBSITES_SCOPE, $storeUrls)
|
| 1239 |
+
&& array_key_exists(
|
| 1240 |
+
$storeComplete[self::WEBSITE_ID],
|
| 1241 |
+
$storeUrls[self::WEBSITES_SCOPE]
|
| 1242 |
+
)
|
| 1243 |
+
) {
|
| 1244 |
+
$storeComplete['url'] = $storeUrls[self::WEBSITES_SCOPE]
|
| 1245 |
+
[$storeComplete[self::WEBSITE_ID]];
|
| 1246 |
+
|
| 1247 |
+
} elseif (array_key_exists(self::DEFAULT_SCOPE, $storeUrls)
|
| 1248 |
+
&& array_key_exists(0, $storeUrls[self::DEFAULT_SCOPE])
|
| 1249 |
+
) {
|
| 1250 |
$storeComplete['url'] = $storeUrls[self::DEFAULT_SCOPE][0];
|
| 1251 |
}
|
| 1252 |
} else {
|
| 1253 |
+
$storeComplete['url'] = $storeUrls[0].$value['code'];
|
| 1254 |
}
|
| 1255 |
|
| 1256 |
$multistoreData[] = $storeComplete;
|
| 1257 |
}
|
| 1258 |
+
|
| 1259 |
return $multistoreData;
|
| 1260 |
}
|
| 1261 |
|
| 1262 |
/**
|
| 1263 |
+
* CreateMultiStoreJson
|
| 1264 |
+
*
|
| 1265 |
+
* @param array $storesArr comment
|
| 1266 |
+
*
|
| 1267 |
* @return array
|
| 1268 |
*/
|
| 1269 |
protected function _createMultiStoreJson($storesArr)
|
| 1294 |
}
|
| 1295 |
|
| 1296 |
if ($useStoreCode) {
|
| 1297 |
+
$storeComplete['url'] = $storeUrls[0].$value['code'];
|
| 1298 |
}
|
| 1299 |
|
| 1300 |
$multistoreData[] = $storeComplete;
|
| 1301 |
}
|
| 1302 |
+
|
| 1303 |
return $multistoreData;
|
| 1304 |
}
|
| 1305 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Catalog.php
CHANGED
|
@@ -27,26 +27,29 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
|
|
| 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(
|
|
|
|
|
|
|
| 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')
|
|
|
|
| 50 |
}
|
| 51 |
|
| 52 |
if ($new === true) {
|
|
@@ -58,7 +61,9 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
|
|
| 58 |
|
| 59 |
public function getProductRenderer()
|
| 60 |
{
|
| 61 |
-
return Mage::getSingleton(
|
|
|
|
|
|
|
| 62 |
}
|
| 63 |
|
| 64 |
public function getBatchRenderer()
|
|
@@ -66,13 +71,67 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
|
|
| 66 |
return Mage::getSingleton('autocompleteplus_autosuggest/renderer_batches');
|
| 67 |
}
|
| 68 |
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
| 75 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
$xmlGenerator = $this->getXmlGenerator();
|
| 77 |
$count = ($count > 10000) ? 10000 : $count;
|
| 78 |
$this->setStoreId($storeId);
|
|
@@ -80,15 +139,15 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
|
|
| 80 |
$this->setMonthInterval($monthInterval);
|
| 81 |
$this->setChecksum($checksum);
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
|
|
|
| 88 |
|
| 89 |
$productCollection = $this->getProductCollection();
|
| 90 |
|
| 91 |
-
// @codingStandardsIgnoreLine
|
| 92 |
$productCollection->getSelect()->limit($count, $startInd);
|
| 93 |
if (is_numeric($storeId)) {
|
| 94 |
$productCollection->addStoreFilter($storeId);
|
|
@@ -124,7 +183,13 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
|
|
| 124 |
if ($this->getHasChecksum()) {
|
| 125 |
if ($this->getHelper()->isChecksumTableExists()) {
|
| 126 |
$checksum = $this->getHelper()->calculateChecksum($product);
|
| 127 |
-
$this->getHelper()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
}
|
| 129 |
}
|
| 130 |
}
|
|
@@ -132,52 +197,28 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
|
|
| 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(
|
|
|
|
|
|
|
| 170 |
}
|
|
|
|
| 171 |
return $this->_useAttributes;
|
| 172 |
}
|
| 173 |
|
| 174 |
public function renderUpdatesCatalogXml($count, $from, $to, $storeId)
|
| 175 |
{
|
| 176 |
-
$updates = Mage::getModel('autocompleteplus_autosuggest/batches')
|
| 177 |
-
->
|
| 178 |
-
|
| 179 |
-
'
|
| 180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
->addFieldToFilter('store_id', $storeId);
|
| 182 |
|
| 183 |
$this->setStoreId($storeId);
|
|
@@ -185,41 +226,37 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
|
|
| 185 |
|
| 186 |
$updates->setPageSize($count);
|
| 187 |
$updates->setCurPage(1);
|
| 188 |
-
$xmlGenerator= $this->getXmlGenerator();
|
| 189 |
|
| 190 |
-
$xmlGenerator->setRootAttributes(
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
|
|
|
|
|
|
| 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();
|
|
@@ -236,7 +273,6 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
|
|
| 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()
|
|
@@ -259,8 +295,8 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
|
|
| 259 |
{
|
| 260 |
$xmlGenerator = $this->getXmlGenerator();
|
| 261 |
$xmlGenerator->setRootAttributes(array(
|
| 262 |
-
'version'
|
| 263 |
-
'magento'
|
| 264 |
))->setRootElementName('catalog');
|
| 265 |
|
| 266 |
$productCollection = $this->getProductCollection();
|
|
@@ -273,7 +309,10 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
|
|
| 273 |
|
| 274 |
$productCollection->addAttributeToSelect($attributesToSelect);
|
| 275 |
|
| 276 |
-
$productCollection->addAttributeToFilter(
|
|
|
|
|
|
|
|
|
|
| 277 |
$productCollection->setPageSize($count);
|
| 278 |
$productCollection->setCurPage(1);
|
| 279 |
|
|
@@ -304,10 +343,12 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
|
|
| 304 |
public function renderCatalogByIds($ids, $storeId = 0)
|
| 305 |
{
|
| 306 |
$xmlGenerator = $this->getXmlGenerator();
|
| 307 |
-
$xmlGenerator->setRootAttributes(
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
|
|
|
|
|
|
| 311 |
|
| 312 |
$productCollection = $this->getProductCollection();
|
| 313 |
if (is_numeric($storeId)) {
|
|
@@ -319,7 +360,7 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
|
|
| 319 |
|
| 320 |
$productCollection->addAttributeToSelect($attributesToSelect);
|
| 321 |
|
| 322 |
-
$productCollection->addAttributeToFilter('entity_id', array('in'
|
| 323 |
|
| 324 |
Mage::getModel('review/review')->appendSummary($productCollection);
|
| 325 |
|
|
@@ -338,6 +379,8 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
|
|
| 338 |
}
|
| 339 |
|
| 340 |
/**
|
|
|
|
|
|
|
| 341 |
* @return array
|
| 342 |
*/
|
| 343 |
protected function _getAttributesToSelect()
|
|
@@ -358,7 +401,7 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
|
|
| 358 |
'meta_title',
|
| 359 |
'meta_description',
|
| 360 |
'special_price',
|
| 361 |
-
'sku'
|
| 362 |
);
|
| 363 |
|
| 364 |
if ($this->canUseAttributes()) {
|
|
@@ -367,8 +410,10 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
|
|
| 367 |
|
| 368 |
$attributesToSelect[] = $action;
|
| 369 |
}
|
|
|
|
| 370 |
return $attributesToSelect;
|
| 371 |
}
|
|
|
|
| 372 |
return $attributesToSelect;
|
| 373 |
}
|
| 374 |
}
|
| 27 |
if (!$this->_helper) {
|
| 28 |
$this->_helper = Mage::helper('autocompleteplus_autosuggest');
|
| 29 |
}
|
| 30 |
+
|
| 31 |
return $this->_helper;
|
| 32 |
}
|
| 33 |
|
| 34 |
public function getAttributes()
|
| 35 |
{
|
| 36 |
if (!$this->_attributes) {
|
|
|
|
| 37 |
$productModel = Mage::getModel('catalog/product');
|
| 38 |
+
$this->_attributes = Mage::getResourceModel(
|
| 39 |
+
'eav/entity_attribute_collection'
|
| 40 |
+
)
|
| 41 |
->setEntityTypeFilter($productModel->getResource()->getTypeId())
|
| 42 |
+
->addFieldToFilter('is_user_defined', '1');
|
|
|
|
| 43 |
}
|
| 44 |
+
|
| 45 |
return $this->_attributes;
|
| 46 |
}
|
| 47 |
|
| 48 |
public function getProductCollection($new = false)
|
| 49 |
{
|
| 50 |
if (!$this->_productCollection) {
|
| 51 |
+
$this->_productCollection = Mage::getModel('catalog/product')
|
| 52 |
+
->getCollection();
|
| 53 |
}
|
| 54 |
|
| 55 |
if ($new === true) {
|
| 61 |
|
| 62 |
public function getProductRenderer()
|
| 63 |
{
|
| 64 |
+
return Mage::getSingleton(
|
| 65 |
+
'autocompleteplus_autosuggest/renderer_catalog_product'
|
| 66 |
+
);
|
| 67 |
}
|
| 68 |
|
| 69 |
public function getBatchRenderer()
|
| 71 |
return Mage::getSingleton('autocompleteplus_autosuggest/renderer_batches');
|
| 72 |
}
|
| 73 |
|
| 74 |
+
/**
|
| 75 |
+
* GetAllProductIds
|
| 76 |
+
*
|
| 77 |
+
* Get all product ids from loaded products collection
|
| 78 |
+
*
|
| 79 |
+
* @return array
|
| 80 |
+
*/
|
| 81 |
+
public function getAllProductIds()
|
| 82 |
{
|
| 83 |
+
$ids = [];
|
| 84 |
+
|
| 85 |
+
foreach ($this->getProductCollection() as $product) {
|
| 86 |
+
$ids[] = $product->getID();
|
| 87 |
+
}
|
| 88 |
+
return $ids;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* GetOrdersPerProduct
|
| 93 |
+
*
|
| 94 |
+
* Get orders information for products from loaded product
|
| 95 |
+
* collection
|
| 96 |
+
*
|
| 97 |
+
* @return array
|
| 98 |
+
*/
|
| 99 |
+
public function getOrdersPerProduct()
|
| 100 |
+
{
|
| 101 |
+
$productIds = implode(',', $this->getAllProductIds());
|
| 102 |
+
$salesOrderItemCollection = Mage::getResourceModel(
|
| 103 |
+
'sales/order_item_collection'
|
| 104 |
+
);
|
| 105 |
+
$salesOrderItemCollection->getSelect()->reset(Zend_Db_Select::COLUMNS)
|
| 106 |
+
->columns(array('product_id', 'SUM(qty_ordered) as qty_ordered'))
|
| 107 |
+
->where(new Zend_Db_Expr('store_id = '.$this->getStoreId()))
|
| 108 |
+
->where(new Zend_Db_Expr('product_id IN ('.$productIds.')'))
|
| 109 |
+
->where(
|
| 110 |
+
new Zend_Db_Expr(
|
| 111 |
+
'created_at BETWEEN NOW() - INTERVAL '.
|
| 112 |
+
$this->getMonthInterval().
|
| 113 |
+
' MONTH AND NOW()'
|
| 114 |
+
)
|
| 115 |
+
)
|
| 116 |
+
->group(array('product_id'));
|
| 117 |
+
|
| 118 |
+
$products = array();
|
| 119 |
+
|
| 120 |
+
foreach ($salesOrderItemCollection as $item) {
|
| 121 |
+
$products[$item['product_id']] = (int)$item['qty_ordered'];
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
return $products;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
public function renderCatalogXml(
|
| 128 |
+
$startInd = 0,
|
| 129 |
+
$count = 10000,
|
| 130 |
+
$storeId = false,
|
| 131 |
+
$orders = false,
|
| 132 |
+
$monthInterval = 12,
|
| 133 |
+
$checksum = false
|
| 134 |
+
) {
|
| 135 |
$xmlGenerator = $this->getXmlGenerator();
|
| 136 |
$count = ($count > 10000) ? 10000 : $count;
|
| 137 |
$this->setStoreId($storeId);
|
| 139 |
$this->setMonthInterval($monthInterval);
|
| 140 |
$this->setChecksum($checksum);
|
| 141 |
|
| 142 |
+
$xmlGenerator->setRootAttributes(
|
| 143 |
+
array(
|
| 144 |
+
'version' => $this->getHelper()->getVersion(),
|
| 145 |
+
'magento' => $this->getHelper()->getMageVersion(),
|
| 146 |
+
)
|
| 147 |
+
)->setRootElementName('catalog');
|
| 148 |
|
| 149 |
$productCollection = $this->getProductCollection();
|
| 150 |
|
|
|
|
| 151 |
$productCollection->getSelect()->limit($count, $startInd);
|
| 152 |
if (is_numeric($storeId)) {
|
| 153 |
$productCollection->addStoreFilter($storeId);
|
| 183 |
if ($this->getHasChecksum()) {
|
| 184 |
if ($this->getHelper()->isChecksumTableExists()) {
|
| 185 |
$checksum = $this->getHelper()->calculateChecksum($product);
|
| 186 |
+
$this->getHelper()
|
| 187 |
+
->updateSavedProductChecksum(
|
| 188 |
+
$product->getId(),
|
| 189 |
+
$product->getSku(),
|
| 190 |
+
$this->getStoreId(),
|
| 191 |
+
$checksum
|
| 192 |
+
);
|
| 193 |
}
|
| 194 |
}
|
| 195 |
}
|
| 197 |
return $xmlGenerator->generateXml();
|
| 198 |
}
|
| 199 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
public function canUseAttributes()
|
| 201 |
{
|
| 202 |
if (!$this->_useAttributes) {
|
| 203 |
+
$this->_useAttributes = Mage::getStoreConfigFlag(
|
| 204 |
+
'autocompleteplus/config/attributes'
|
| 205 |
+
);
|
| 206 |
}
|
| 207 |
+
|
| 208 |
return $this->_useAttributes;
|
| 209 |
}
|
| 210 |
|
| 211 |
public function renderUpdatesCatalogXml($count, $from, $to, $storeId)
|
| 212 |
{
|
| 213 |
+
$updates = Mage::getModel('autocompleteplus_autosuggest/batches')
|
| 214 |
+
->getCollection()
|
| 215 |
+
->addFieldToFilter(
|
| 216 |
+
'update_date',
|
| 217 |
+
array(
|
| 218 |
+
'from' => $from,
|
| 219 |
+
'to' => $to,
|
| 220 |
+
)
|
| 221 |
+
)
|
| 222 |
->addFieldToFilter('store_id', $storeId);
|
| 223 |
|
| 224 |
$this->setStoreId($storeId);
|
| 226 |
|
| 227 |
$updates->setPageSize($count);
|
| 228 |
$updates->setCurPage(1);
|
| 229 |
+
$xmlGenerator = $this->getXmlGenerator();
|
| 230 |
|
| 231 |
+
$xmlGenerator->setRootAttributes(
|
| 232 |
+
array(
|
| 233 |
+
'version' => $this->getHelper()->getVersion(),
|
| 234 |
+
'magento' => $this->getHelper()->getMageVersion(),
|
| 235 |
+
'fromdatetime' => $from,
|
| 236 |
+
)
|
| 237 |
+
)->setRootElementName('catalog');
|
| 238 |
|
| 239 |
+
$updatesBulk = array();
|
| 240 |
|
| 241 |
+
$productIds = array();
|
| 242 |
|
| 243 |
foreach ($updates as $batch) {
|
|
|
|
| 244 |
if ($batch['action'] == 'update') {
|
|
|
|
| 245 |
if ($batch['product_id'] != null) {
|
| 246 |
$updatesBulk[$batch['product_id']] = $batch;
|
| 247 |
|
| 248 |
$productIds[] = $batch['product_id'];
|
|
|
|
| 249 |
} else {
|
| 250 |
$batch['action'] = 'remove';
|
| 251 |
$this->getBatchRenderer()
|
| 252 |
->setXmlElement($xmlGenerator)
|
| 253 |
->makeRemoveRow($batch);
|
| 254 |
}
|
|
|
|
| 255 |
} elseif ($batch['action'] == 'remove') {
|
|
|
|
| 256 |
$this->getBatchRenderer()
|
| 257 |
->setXmlElement($xmlGenerator)
|
| 258 |
->makeRemoveRow($batch);
|
| 259 |
}
|
|
|
|
| 260 |
}
|
| 261 |
|
| 262 |
$this->currency = Mage::app()->getStore($storeId)->getCurrentCurrencyCode();
|
| 273 |
->addAttributeToFilter('entity_id', array('in' => $productIds));
|
| 274 |
|
| 275 |
foreach ($productCollection as $product) {
|
|
|
|
| 276 |
$updatedate = $updatesBulk[$product->getId()]['update_date'];
|
| 277 |
|
| 278 |
$this->getProductRenderer()
|
| 295 |
{
|
| 296 |
$xmlGenerator = $this->getXmlGenerator();
|
| 297 |
$xmlGenerator->setRootAttributes(array(
|
| 298 |
+
'version' => $this->getHelper()->getVersion(),
|
| 299 |
+
'magento' => $this->getHelper()->getMageVersion(),
|
| 300 |
))->setRootElementName('catalog');
|
| 301 |
|
| 302 |
$productCollection = $this->getProductCollection();
|
| 309 |
|
| 310 |
$productCollection->addAttributeToSelect($attributesToSelect);
|
| 311 |
|
| 312 |
+
$productCollection->addAttributeToFilter(
|
| 313 |
+
'entity_id',
|
| 314 |
+
array('from' => $fromId)
|
| 315 |
+
);
|
| 316 |
$productCollection->setPageSize($count);
|
| 317 |
$productCollection->setCurPage(1);
|
| 318 |
|
| 343 |
public function renderCatalogByIds($ids, $storeId = 0)
|
| 344 |
{
|
| 345 |
$xmlGenerator = $this->getXmlGenerator();
|
| 346 |
+
$xmlGenerator->setRootAttributes(
|
| 347 |
+
array(
|
| 348 |
+
'version' => $this->getHelper()->getVersion(),
|
| 349 |
+
'magento' => $this->getHelper()->getMageVersion(),
|
| 350 |
+
)
|
| 351 |
+
)->setRootElementName('catalog');
|
| 352 |
|
| 353 |
$productCollection = $this->getProductCollection();
|
| 354 |
if (is_numeric($storeId)) {
|
| 360 |
|
| 361 |
$productCollection->addAttributeToSelect($attributesToSelect);
|
| 362 |
|
| 363 |
+
$productCollection->addAttributeToFilter('entity_id', array('in' => $ids));
|
| 364 |
|
| 365 |
Mage::getModel('review/review')->appendSummary($productCollection);
|
| 366 |
|
| 379 |
}
|
| 380 |
|
| 381 |
/**
|
| 382 |
+
* GetAttributesToSelect
|
| 383 |
+
*
|
| 384 |
* @return array
|
| 385 |
*/
|
| 386 |
protected function _getAttributesToSelect()
|
| 401 |
'meta_title',
|
| 402 |
'meta_description',
|
| 403 |
'special_price',
|
| 404 |
+
'sku',
|
| 405 |
);
|
| 406 |
|
| 407 |
if ($this->canUseAttributes()) {
|
| 410 |
|
| 411 |
$attributesToSelect[] = $action;
|
| 412 |
}
|
| 413 |
+
|
| 414 |
return $attributesToSelect;
|
| 415 |
}
|
| 416 |
+
|
| 417 |
return $attributesToSelect;
|
| 418 |
}
|
| 419 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Config.php
CHANGED
|
@@ -214,7 +214,8 @@ class Autocompleteplus_Autosuggest_Model_Config extends Mage_Core_Model_Abstract
|
|
| 214 |
}
|
| 215 |
|
| 216 |
/**
|
| 217 |
-
* Update robots.txt file with ISP sitemap URL
|
|
|
|
| 218 |
* @param $responseData
|
| 219 |
*/
|
| 220 |
protected function _updateRobotsTxt($responseData)
|
|
@@ -230,8 +231,8 @@ class Autocompleteplus_Autosuggest_Model_Config extends Mage_Core_Model_Abstract
|
|
| 230 |
$robotsTxtWritable = $fileIo->isWriteable('robots.txt');
|
| 231 |
|
| 232 |
if ($robotsTxtExists && $robotsTxtWritable && !$siteMapExists) {
|
| 233 |
-
$fileIo->write('robots.txt', $robotsTxtContent
|
| 234 |
-
}
|
| 235 |
$fileIo->write('robots.txt', $siteMapUrl);
|
| 236 |
} else {
|
| 237 |
$this->_sendError('Unable to properly update robots.txt with ISP Sitemap');
|
|
@@ -251,15 +252,15 @@ class Autocompleteplus_Autosuggest_Model_Config extends Mage_Core_Model_Abstract
|
|
| 251 |
public function generateConfig($UUID = null, $key = null)
|
| 252 |
{
|
| 253 |
$params = array(
|
| 254 |
-
'site'
|
| 255 |
-
'email'
|
| 256 |
-
'f'
|
| 257 |
'multistore' => $this->_getHelper()->getMultiStoreDataJson(),
|
| 258 |
);
|
| 259 |
|
| 260 |
if ($UUID && $key) {
|
| 261 |
$params['uuid'] = $UUID;
|
| 262 |
-
$params['key']
|
| 263 |
}
|
| 264 |
|
| 265 |
$responseData = null;
|
|
@@ -267,9 +268,9 @@ class Autocompleteplus_Autosuggest_Model_Config extends Mage_Core_Model_Abstract
|
|
| 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()
|
| 273 |
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
| 274 |
curl_setopt($client, CURLOPT_POSTFIELDS, $params);
|
| 275 |
|
|
@@ -278,7 +279,7 @@ class Autocompleteplus_Autosuggest_Model_Config extends Mage_Core_Model_Abstract
|
|
| 278 |
// @codingStandardsIgnoreEnd
|
| 279 |
|
| 280 |
if (!$response && ($key == null || $key == '')) {
|
| 281 |
-
$notSecureUrl = str_replace('https', 'http', $this->getEndpoint()
|
| 282 |
|
| 283 |
$client = curl_init($notSecureUrl);
|
| 284 |
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
|
@@ -299,10 +300,12 @@ class Autocompleteplus_Autosuggest_Model_Config extends Mage_Core_Model_Abstract
|
|
| 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 |
|
|
@@ -316,13 +319,12 @@ class Autocompleteplus_Autosuggest_Model_Config extends Mage_Core_Model_Abstract
|
|
| 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: '
|
| 321 |
-
' | authentication_key: '
|
| 322 |
}
|
| 323 |
}
|
| 324 |
|
| 325 |
-
|
| 326 |
Mage::dispatchEvent('autocompleteplus_autosuggest_config_creation_after',
|
| 327 |
array('config' => $this, 'response' => $response, 'responseData' => $responseData));
|
| 328 |
|
|
@@ -351,9 +353,9 @@ class Autocompleteplus_Autosuggest_Model_Config extends Mage_Core_Model_Abstract
|
|
| 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()
|
| 357 |
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
| 358 |
curl_setopt($client, CURLOPT_POSTFIELDS, $params);
|
| 359 |
$response = curl_exec($client);
|
|
@@ -372,18 +374,19 @@ class Autocompleteplus_Autosuggest_Model_Config extends Mage_Core_Model_Abstract
|
|
| 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 |
}
|
| 214 |
}
|
| 215 |
|
| 216 |
/**
|
| 217 |
+
* Update robots.txt file with ISP sitemap URL.
|
| 218 |
+
*
|
| 219 |
* @param $responseData
|
| 220 |
*/
|
| 221 |
protected function _updateRobotsTxt($responseData)
|
| 231 |
$robotsTxtWritable = $fileIo->isWriteable('robots.txt');
|
| 232 |
|
| 233 |
if ($robotsTxtExists && $robotsTxtWritable && !$siteMapExists) {
|
| 234 |
+
$fileIo->write('robots.txt', $robotsTxtContent.$siteMapUrl);
|
| 235 |
+
} elseif (!$robotsTxtExists && $baseDirWritable) {
|
| 236 |
$fileIo->write('robots.txt', $siteMapUrl);
|
| 237 |
} else {
|
| 238 |
$this->_sendError('Unable to properly update robots.txt with ISP Sitemap');
|
| 252 |
public function generateConfig($UUID = null, $key = null)
|
| 253 |
{
|
| 254 |
$params = array(
|
| 255 |
+
'site' => $this->_getHelper()->getConfigDataByFullPath('web/unsecure/base_url'),
|
| 256 |
+
'email' => Mage::getStoreConfig(self::XML_STORE_EMAIL_CONFIG),
|
| 257 |
+
'f' => $this->_getHelper()->getVersion(),
|
| 258 |
'multistore' => $this->_getHelper()->getMultiStoreDataJson(),
|
| 259 |
);
|
| 260 |
|
| 261 |
if ($UUID && $key) {
|
| 262 |
$params['uuid'] = $UUID;
|
| 263 |
+
$params['key'] = $key;
|
| 264 |
}
|
| 265 |
|
| 266 |
$responseData = null;
|
| 268 |
// @codingStandardsIgnoreStart
|
| 269 |
/**
|
| 270 |
* Due to backward compatibility issues with Magento < 1.8.1 and cURL/Zend
|
| 271 |
+
* We need to use PHP's implementation of cURL directly rather than Zend or Varien.
|
| 272 |
*/
|
| 273 |
+
$client = curl_init($this->getEndpoint().'/install');
|
| 274 |
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
| 275 |
curl_setopt($client, CURLOPT_POSTFIELDS, $params);
|
| 276 |
|
| 279 |
// @codingStandardsIgnoreEnd
|
| 280 |
|
| 281 |
if (!$response && ($key == null || $key == '')) {
|
| 282 |
+
$notSecureUrl = str_replace('https', 'http', $this->getEndpoint().'/install');
|
| 283 |
|
| 284 |
$client = curl_init($notSecureUrl);
|
| 285 |
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
| 300 |
if (isset($responseData['uuid']) && strlen($responseData['uuid']) > 50) {
|
| 301 |
Mage::log('Registration failed - please check response below', null, 'autocomplete.log', true);
|
| 302 |
$this->_sendError('Could not get license string.');
|
| 303 |
+
|
| 304 |
return false;
|
| 305 |
} elseif (!isset($responseData['uuid'])) {
|
| 306 |
Mage::log('Registration failed - please check response below', null, 'autocomplete.log', true);
|
| 307 |
$this->_sendError('Could not get license string.');
|
| 308 |
+
|
| 309 |
return false;
|
| 310 |
}
|
| 311 |
|
| 319 |
$this->setIsReachable($responseData['is_reachable']);
|
| 320 |
$this->setErrorMessage(isset($errorMessage) ? $errorMessage : '');
|
| 321 |
|
| 322 |
+
if (!$this->isConfigDataValid($responseData['uuid'], $responseData['authentication_key'])) {
|
| 323 |
+
$this->_sendError('UUID or Authentication key are not valid | got UUID: '.$responseData['uuid'].
|
| 324 |
+
' | authentication_key: '.$responseData['authentication_key']);
|
| 325 |
}
|
| 326 |
}
|
| 327 |
|
|
|
|
| 328 |
Mage::dispatchEvent('autocompleteplus_autosuggest_config_creation_after',
|
| 329 |
array('config' => $this, 'response' => $response, 'responseData' => $responseData));
|
| 330 |
|
| 353 |
// @codingStandardsIgnoreStart
|
| 354 |
/**
|
| 355 |
* Due to backward compatibility issues with Magento < 1.8.1 and cURL/Zend
|
| 356 |
+
* We need to use PHP's implementation of cURL directly rather than Zend or Varien.
|
| 357 |
*/
|
| 358 |
+
$client = curl_init($this->getEndpoint().'/install_error');
|
| 359 |
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
| 360 |
curl_setopt($client, CURLOPT_POSTFIELDS, $params);
|
| 361 |
$response = curl_exec($client);
|
| 374 |
'licensekey' => $this->getUUID(),
|
| 375 |
));
|
| 376 |
}
|
| 377 |
+
|
| 378 |
+
public function isConfigDataValid($input_uuid = null, $input_key = null)
|
| 379 |
+
{
|
| 380 |
$uuid = ($input_uuid) ? $input_uuid : $this->getUUID();
|
| 381 |
$authentication_key = ($input_key) ? $input_key : $this->getAuthorizationKey();
|
| 382 |
+
|
| 383 |
+
if (!$uuid || strlen($uuid) != 36 || substr_count($uuid, '-') != 4) {
|
| 384 |
return false;
|
| 385 |
}
|
| 386 |
+
if (!$authentication_key || strlen($authentication_key) == 0) {
|
| 387 |
return false;
|
| 388 |
}
|
| 389 |
+
|
| 390 |
return true;
|
| 391 |
}
|
| 392 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Batches.php
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 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 |
+
}
|
|
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Batches/Collection.php
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 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 |
+
}
|
|
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Checksum.php
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 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 |
+
}
|
|
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Checksum/Collection.php
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 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 |
+
}
|
|
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Fulltext/Collection.php
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 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 |
+
}
|
|
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Notifications.php
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 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 |
+
}
|
|
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Notifications/Collection.php
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 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 |
+
}
|
|
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Pusher.php
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 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 |
+
}
|
|
|
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Pusher/Collection.php
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 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 |
+
}
|
|
|
app/code/local/Autocompleteplus/Autosuggest/Model/Observer.php
CHANGED
|
@@ -176,7 +176,7 @@ class Autocompleteplus_Autosuggest_Model_Observer extends Mage_Core_Model_Abstra
|
|
| 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) {
|
|
@@ -210,13 +210,12 @@ class Autocompleteplus_Autosuggest_Model_Observer extends Mage_Core_Model_Abstra
|
|
| 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
|
|
@@ -253,7 +252,6 @@ class Autocompleteplus_Autosuggest_Model_Observer extends Mage_Core_Model_Abstra
|
|
| 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)
|
|
@@ -264,7 +262,6 @@ class Autocompleteplus_Autosuggest_Model_Observer extends Mage_Core_Model_Abstra
|
|
| 264 |
|
| 265 |
$update->save();
|
| 266 |
}
|
| 267 |
-
|
| 268 |
} catch (Exception $e) {
|
| 269 |
Mage::logException($e);
|
| 270 |
}
|
|
@@ -294,7 +291,7 @@ class Autocompleteplus_Autosuggest_Model_Observer extends Mage_Core_Model_Abstra
|
|
| 294 |
->addFieldToFilter('store_id', $product_store);
|
| 295 |
|
| 296 |
$batches->getSelect()
|
| 297 |
-
->order('update_date','DESC')
|
| 298 |
->limit(1);
|
| 299 |
|
| 300 |
// @codingStandardsIgnoreLine
|
|
@@ -403,7 +400,7 @@ class Autocompleteplus_Autosuggest_Model_Observer extends Mage_Core_Model_Abstra
|
|
| 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);
|
| 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) {
|
| 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 |
$batches = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()
|
| 214 |
->addFieldToFilter('product_id', $configurable_product)
|
| 215 |
->addFieldToFilter('store_id', $product_store);
|
| 216 |
|
| 217 |
$batches->getSelect()
|
| 218 |
+
->order('update_date', 'DESC')
|
| 219 |
->limit(1);
|
| 220 |
|
| 221 |
// @codingStandardsIgnoreLine
|
| 252 |
$sku = $product->getSku();
|
| 253 |
|
| 254 |
try {
|
|
|
|
| 255 |
$updates = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()
|
| 256 |
->addFieldToFilter('product_id', array('null' => true))
|
| 257 |
->addFieldToFilter('sku', $sku)
|
| 262 |
|
| 263 |
$update->save();
|
| 264 |
}
|
|
|
|
| 265 |
} catch (Exception $e) {
|
| 266 |
Mage::logException($e);
|
| 267 |
}
|
| 291 |
->addFieldToFilter('store_id', $product_store);
|
| 292 |
|
| 293 |
$batches->getSelect()
|
| 294 |
+
->order('update_date', 'DESC')
|
| 295 |
->limit(1);
|
| 296 |
|
| 297 |
// @codingStandardsIgnoreLine
|
| 400 |
// @codingStandardsIgnoreStart
|
| 401 |
/**
|
| 402 |
* Due to backward compatibility issues with Magento < 1.8.1 and cURL/Zend
|
| 403 |
+
* We need to use PHP's implementation of cURL directly rather than Zend or Varien.
|
| 404 |
*/
|
| 405 |
$client = curl_init($this->_getWebhookObjectUri());
|
| 406 |
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Abstract.php
CHANGED
|
@@ -16,12 +16,14 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Abstract extends Mage_Core_Mod
|
|
| 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 |
|
|
@@ -30,6 +32,7 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Abstract extends Mage_Core_Mod
|
|
| 30 |
if (!$this->_currency) {
|
| 31 |
$this->_currency = Mage::app()->getStore($this->getStoreId())->getCurrentCurrencyCode();
|
| 32 |
}
|
|
|
|
| 33 |
return $this->_currency;
|
| 34 |
}
|
| 35 |
|
|
@@ -38,12 +41,14 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Abstract extends Mage_Core_Mod
|
|
| 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 |
|
|
@@ -52,12 +57,14 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Abstract extends Mage_Core_Mod
|
|
| 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 |
|
|
@@ -66,6 +73,7 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Abstract extends Mage_Core_Mod
|
|
| 66 |
if (!$this->_helper) {
|
| 67 |
$this->_helper = Mage::helper('autocompleteplus_autosuggest');
|
| 68 |
}
|
|
|
|
| 69 |
return $this->_helper;
|
| 70 |
}
|
| 71 |
|
|
@@ -81,4 +89,4 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Abstract extends Mage_Core_Mod
|
|
| 81 |
|
| 82 |
return $this->_productCollection;
|
| 83 |
}
|
| 84 |
-
}
|
| 16 |
if (!$this->_storeId) {
|
| 17 |
$this->_storeId = Mage::app()->getStore()->getId();
|
| 18 |
}
|
| 19 |
+
|
| 20 |
return $this->_storeId;
|
| 21 |
}
|
| 22 |
|
| 23 |
public function setStoreId($storeId)
|
| 24 |
{
|
| 25 |
$this->_storeId = $storeId;
|
| 26 |
+
|
| 27 |
return $this;
|
| 28 |
}
|
| 29 |
|
| 32 |
if (!$this->_currency) {
|
| 33 |
$this->_currency = Mage::app()->getStore($this->getStoreId())->getCurrentCurrencyCode();
|
| 34 |
}
|
| 35 |
+
|
| 36 |
return $this->_currency;
|
| 37 |
}
|
| 38 |
|
| 41 |
if (!$this->_monthInterval) {
|
| 42 |
$this->_monthInterval = 12;
|
| 43 |
}
|
| 44 |
+
|
| 45 |
return $this->_monthInterval;
|
| 46 |
}
|
| 47 |
|
| 48 |
public function setMonthInterval($monthInterval)
|
| 49 |
{
|
| 50 |
$this->_monthInterval = $monthInterval;
|
| 51 |
+
|
| 52 |
return $this;
|
| 53 |
}
|
| 54 |
|
| 57 |
if ($this->_pageNum) {
|
| 58 |
$this->_pageNum = 1;
|
| 59 |
}
|
| 60 |
+
|
| 61 |
return $this->_pageNum;
|
| 62 |
}
|
| 63 |
|
| 64 |
public function setPageNum($pageNum)
|
| 65 |
{
|
| 66 |
$this->_pageNum = $pageNum;
|
| 67 |
+
|
| 68 |
return $this;
|
| 69 |
}
|
| 70 |
|
| 73 |
if (!$this->_helper) {
|
| 74 |
$this->_helper = Mage::helper('autocompleteplus_autosuggest');
|
| 75 |
}
|
| 76 |
+
|
| 77 |
return $this->_helper;
|
| 78 |
}
|
| 79 |
|
| 89 |
|
| 90 |
return $this->_productCollection;
|
| 91 |
}
|
| 92 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Batches.php
CHANGED
|
@@ -5,6 +5,7 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Batches extends Autocompletepl
|
|
| 5 |
public function setXmlElement(&$xmlGenerator)
|
| 6 |
{
|
| 7 |
$this->_xmlElement = $xmlGenerator;
|
|
|
|
| 8 |
return $this;
|
| 9 |
}
|
| 10 |
|
|
@@ -13,15 +14,16 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Batches extends Autocompletepl
|
|
| 13 |
return $this->_xmlElement;
|
| 14 |
}
|
| 15 |
|
| 16 |
-
public function makeRemoveRow($batch)
|
|
|
|
| 17 |
$productElement = $this->getXmlElement()->createChild('product', array(
|
| 18 |
-
'updatedate' =>
|
| 19 |
-
'action'
|
| 20 |
-
'id'
|
| 21 |
-
'storeid'
|
| 22 |
));
|
| 23 |
|
| 24 |
$this->getXmlElement()->createChild('sku', false, $batch['sku'], $productElement);
|
| 25 |
$this->getXmlElement()->createChild('id', false, $batch['product_id'], $productElement);
|
| 26 |
}
|
| 27 |
-
}
|
| 5 |
public function setXmlElement(&$xmlGenerator)
|
| 6 |
{
|
| 7 |
$this->_xmlElement = $xmlGenerator;
|
| 8 |
+
|
| 9 |
return $this;
|
| 10 |
}
|
| 11 |
|
| 14 |
return $this->_xmlElement;
|
| 15 |
}
|
| 16 |
|
| 17 |
+
public function makeRemoveRow($batch)
|
| 18 |
+
{
|
| 19 |
$productElement = $this->getXmlElement()->createChild('product', array(
|
| 20 |
+
'updatedate' => $batch['update_date'],
|
| 21 |
+
'action' => $batch['action'],
|
| 22 |
+
'id' => $batch['product_id'],
|
| 23 |
+
'storeid' => $batch['store_id'],
|
| 24 |
));
|
| 25 |
|
| 26 |
$this->getXmlElement()->createChild('sku', false, $batch['sku'], $productElement);
|
| 27 |
$this->getXmlElement()->createChild('id', false, $batch['product_id'], $productElement);
|
| 28 |
}
|
| 29 |
+
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Catalog/Product.php
CHANGED
|
@@ -1,6 +1,45 @@
|
|
| 1 |
<?php
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
{
|
| 5 |
protected $_standardImageFields = array('image', 'small_image', 'thumbnail');
|
| 6 |
protected $_useAttributes;
|
|
@@ -22,68 +61,135 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 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(
|
|
|
|
|
|
|
| 57 |
}
|
|
|
|
| 58 |
return $this->_imageField;
|
| 59 |
}
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
public function canUseAttributes()
|
| 62 |
{
|
| 63 |
if (!$this->_useAttributes) {
|
| 64 |
-
$this->_useAttributes = Mage::getStoreConfigFlag(
|
|
|
|
|
|
|
| 65 |
}
|
|
|
|
| 66 |
return $this->_useAttributes;
|
| 67 |
}
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
public function getRootCategoryId()
|
| 70 |
{
|
| 71 |
if (!$this->_rootCategoryId) {
|
| 72 |
-
$this->_rootCategoryId = Mage::app()
|
|
|
|
| 73 |
}
|
|
|
|
| 74 |
return $this->_rootCategoryId;
|
| 75 |
}
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
public function getSaleable()
|
| 78 |
{
|
| 79 |
-
return
|
| 80 |
}
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
public function getConfigurableChildren()
|
| 83 |
{
|
| 84 |
return $this->getProduct()->getTypeInstance()->getUsedProducts();
|
| 85 |
}
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
public function getConfigurableChildrenIds()
|
| 88 |
{
|
| 89 |
$configurableChildrenIds = array();
|
|
@@ -101,10 +207,18 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 101 |
return $configurableChildrenIds;
|
| 102 |
}
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
public function getProductCollection($new = false)
|
| 105 |
{
|
| 106 |
if (!$this->_productCollection) {
|
| 107 |
-
$this->_productCollection = Mage::getModel('catalog/product')
|
|
|
|
| 108 |
}
|
| 109 |
|
| 110 |
if ($new === true) {
|
|
@@ -114,6 +228,11 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 114 |
return $this->_productCollection;
|
| 115 |
}
|
| 116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
public function getCategoryMap()
|
| 118 |
{
|
| 119 |
if (!$this->_categories) {
|
|
@@ -121,14 +240,17 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 121 |
$categories = Mage::getModel('catalog/category')->getCollection();
|
| 122 |
|
| 123 |
foreach ($categories as $category) {
|
| 124 |
-
$categoryMap[] = new Varien_Object(
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
|
|
|
|
|
|
| 129 |
}
|
| 130 |
$this->_categories = $categoryMap;
|
| 131 |
}
|
|
|
|
| 132 |
return $this->_categories;
|
| 133 |
}
|
| 134 |
|
|
@@ -136,7 +258,9 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 136 |
{
|
| 137 |
$simple_products_price = array();
|
| 138 |
$pricesByAttributeValues = array();
|
| 139 |
-
$attributes = $this->getProduct()
|
|
|
|
|
|
|
| 140 |
$basePrice = $this->getProduct()->getFinalPrice();
|
| 141 |
$items = $attributes->getItems();
|
| 142 |
if (is_array($items)) {
|
|
@@ -144,10 +268,18 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 144 |
$prices = $attribute->getPrices();
|
| 145 |
if (is_array($prices)) {
|
| 146 |
foreach ($prices as $price) {
|
| 147 |
-
if ($price['is_percent']) {
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
}
|
| 152 |
}
|
| 153 |
}
|
|
@@ -157,7 +289,9 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 157 |
foreach ($this->getConfigurableChildren() as $sProduct) {
|
| 158 |
$totalPrice = $basePrice;
|
| 159 |
foreach ($attributes as $attribute) {
|
| 160 |
-
$value = $sProduct->getData(
|
|
|
|
|
|
|
| 161 |
if (isset($pricesByAttributeValues[$value])) {
|
| 162 |
$totalPrice += $pricesByAttributeValues[$value];
|
| 163 |
}
|
|
@@ -172,50 +306,80 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 172 |
{
|
| 173 |
$productCategories = $this->getProduct()->getCategoryIds();
|
| 174 |
$rootCategoryId = $this->getRootCategoryId();
|
| 175 |
-
$paths = array_map(
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
}
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
return array_filter($paths);
|
| 192 |
}
|
| 193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
public function getConfigurableAttributes()
|
| 195 |
{
|
| 196 |
// Collect options applicable to the configurable product
|
| 197 |
-
$productAttributeOptions = $this->getProduct()
|
|
|
|
|
|
|
| 198 |
$configurableAttributes = array();
|
| 199 |
|
| 200 |
foreach ($productAttributeOptions as $productAttribute) {
|
| 201 |
-
$attributeFull = Mage::getModel('eav/config')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
|
| 203 |
foreach ($productAttribute['values'] as $attribute) {
|
| 204 |
-
$configurableAttributes[$productAttribute['store_label']]['values'][]
|
|
|
|
| 205 |
}
|
| 206 |
|
| 207 |
-
$configurableAttributes[$productAttribute['store_label']]
|
| 208 |
-
|
|
|
|
|
|
|
| 209 |
}
|
| 210 |
|
| 211 |
return $configurableAttributes;
|
| 212 |
}
|
| 213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
public function getProductAttributes()
|
| 215 |
{
|
| 216 |
-
return $this->getProduct()
|
|
|
|
|
|
|
| 217 |
}
|
| 218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
public function getPriceRange()
|
| 220 |
{
|
| 221 |
$pricesByAttributeValues = array();
|
|
@@ -230,10 +394,18 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 230 |
$prices = $attribute->getPrices();
|
| 231 |
if (is_array($prices)) {
|
| 232 |
foreach ($prices as $price) {
|
| 233 |
-
if ($price['is_percent']) {
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
}
|
| 238 |
}
|
| 239 |
}
|
|
@@ -244,43 +416,64 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 244 |
foreach ($simple as $sProduct) {
|
| 245 |
$totalPrice = $basePrice;
|
| 246 |
foreach ($attributes as $attribute) {
|
| 247 |
-
$value = $sProduct->getData(
|
|
|
|
|
|
|
| 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 |
-
|
| 276 |
}
|
| 277 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
public function getOrderCount()
|
| 279 |
{
|
|
|
|
| 280 |
$orderData = $this->getOrderData();
|
| 281 |
-
|
|
|
|
|
|
|
|
|
|
| 282 |
}
|
| 283 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
public function getProductResource()
|
| 285 |
{
|
| 286 |
return Mage::getResourceSingleton('catalog/product');
|
|
@@ -289,82 +482,130 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 289 |
/**
|
| 290 |
* @TODO Refactor indentation/conditions
|
| 291 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
public function renderProductVariantXml($productXmlElem)
|
| 293 |
{
|
| 294 |
if ($this->canUseAttributes()) {
|
| 295 |
-
if ($this->getProduct()->isConfigurable()
|
|
|
|
|
|
|
| 296 |
$variants = array();
|
| 297 |
-
foreach ($this->getConfigurableAttributes()
|
| 298 |
-
|
|
|
|
|
|
|
|
|
|
| 299 |
$variants[] = $attrName;
|
| 300 |
$values = implode(' , ', $confAttrN['values']);
|
| 301 |
-
$this->getXmlElement()->createChild(
|
| 302 |
-
'
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
|
|
|
|
|
|
| 306 |
$values,
|
| 307 |
$productXmlElem
|
| 308 |
);
|
| 309 |
}
|
| 310 |
}
|
| 311 |
|
| 312 |
-
$simple_products_price = $this
|
|
|
|
| 313 |
|
| 314 |
if (count($variants) > 0) {
|
| 315 |
-
$variantElem = $this->getXmlElement()
|
|
|
|
| 316 |
foreach ($this->getConfigurableChildren() as $child_product) {
|
| 317 |
-
if (!in_array(
|
|
|
|
|
|
|
|
|
|
| 318 |
continue;
|
| 319 |
}
|
| 320 |
|
| 321 |
-
$is_variant_in_stock = (
|
|
|
|
|
|
|
| 322 |
|
| 323 |
if (method_exists($child_product, 'isSaleable')) {
|
| 324 |
-
$is_variant_sellable = (
|
|
|
|
|
|
|
| 325 |
} else {
|
| 326 |
$is_variant_sellable = '';
|
| 327 |
}
|
| 328 |
|
| 329 |
if (method_exists($child_product, 'getVisibility')) {
|
| 330 |
-
$is_variant_visible = (
|
|
|
|
|
|
|
| 331 |
} else {
|
| 332 |
$is_variant_visible = '';
|
| 333 |
}
|
| 334 |
|
| 335 |
-
$variant_price = (array_key_exists(
|
|
|
|
|
|
|
|
|
|
| 336 |
$simple_products_price[$child_product->getId()] : '';
|
| 337 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
|
| 339 |
-
$
|
| 340 |
-
'
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 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']
|
|
|
|
|
|
|
| 353 |
continue;
|
| 354 |
}
|
| 355 |
|
| 356 |
-
if (!$attribute['store_label']){
|
| 357 |
// skip variant attribute without a name
|
| 358 |
continue;
|
| 359 |
}
|
| 360 |
|
| 361 |
-
$this->getXmlElement()->createChild(
|
| 362 |
-
'
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 368 |
);
|
| 369 |
}
|
| 370 |
}
|
|
@@ -373,6 +614,14 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 373 |
}
|
| 374 |
}
|
| 375 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 376 |
public function renderProductAttributeXml($attr, $productXmlElem)
|
| 377 |
{
|
| 378 |
if ($this->canUseAttributes()) {
|
|
@@ -386,18 +635,17 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 386 |
|
| 387 |
$is_filterable = $attr->getIsFilterable();
|
| 388 |
$attribute_label = $attr->getFrontendLabel();
|
| 389 |
-
$_helper
|
| 390 |
|
| 391 |
try {
|
| 392 |
-
|
| 393 |
switch ($attr->getFrontendInput()) {
|
| 394 |
case 'select':
|
| 395 |
if (method_exists($this->getProduct(), 'getAttributeText')) {
|
| 396 |
-
|
| 397 |
-
*
|
| 398 |
* we make it as string to avoid null to be a key
|
| 399 |
*/
|
| 400 |
-
$attrValidKey = $attrValue != null ? self::ISPKEY
|
| 401 |
|
| 402 |
if (!array_key_exists($attrValidKey, $this->_attributesValuesCache[$action])) {
|
| 403 |
$attrValueText = $_helper->productAttribute(
|
|
@@ -428,16 +676,14 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 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,
|
|
@@ -455,10 +701,12 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 455 |
$saleable = 0;
|
| 456 |
|
| 457 |
try {
|
| 458 |
-
if ($this->getProduct()->
|
| 459 |
$saleable = 1;
|
|
|
|
|
|
|
| 460 |
}
|
| 461 |
-
}catch (Exception $e) {
|
| 462 |
Mage::log($e->getMessage(), null, 'autocomplete.log', true);
|
| 463 |
}
|
| 464 |
|
|
@@ -477,24 +725,24 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 477 |
}
|
| 478 |
|
| 479 |
$productElement = $this->getXmlElement()->createChild('product', array(
|
| 480 |
-
'price_min' =>
|
| 481 |
-
'price_max' =>
|
| 482 |
-
'store' =>
|
| 483 |
-
'store_id'
|
| 484 |
-
'storeid'
|
| 485 |
-
'id'
|
| 486 |
-
'type'
|
| 487 |
-
'currency'
|
| 488 |
-
'visibility'
|
| 489 |
-
'price' =>
|
| 490 |
-
'url'
|
| 491 |
-
'thumbs'
|
| 492 |
-
'base_image'
|
| 493 |
-
'selleable' =>
|
| 494 |
-
'action'
|
| 495 |
-
'last_updated'
|
| 496 |
-
'updatedate'
|
| 497 |
-
'get_by_id_status'
|
| 498 |
));
|
| 499 |
|
| 500 |
$productRating = $this->getProduct()->getRatingSummary();
|
|
@@ -507,7 +755,6 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 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 |
|
|
@@ -575,13 +822,11 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 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 |
|
|
@@ -591,20 +836,25 @@ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autoco
|
|
| 591 |
public function _getAdditionalProductUrl()
|
| 592 |
{
|
| 593 |
$is_get_url_path_supported = true;
|
| 594 |
-
if (method_exists('Mage'
|
|
|
|
|
|
|
|
|
|
| 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 |
}
|
| 1 |
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Products File
|
| 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 |
+
* PHP version 5
|
| 12 |
+
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product
|
| 24 |
+
*
|
| 25 |
+
* NOTICE OF LICENSE
|
| 26 |
+
*
|
| 27 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 28 |
+
* that is available through the world-wide-web at this URL:
|
| 29 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 30 |
+
*
|
| 31 |
+
* PHP version 5
|
| 32 |
+
*
|
| 33 |
+
* @category Mage
|
| 34 |
+
*
|
| 35 |
+
* @package Instantsearchplus
|
| 36 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 37 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 38 |
+
* @license Open Software License (OSL 3.0)*
|
| 39 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 40 |
+
*/
|
| 41 |
+
class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends
|
| 42 |
+
Autocompleteplus_Autosuggest_Model_Renderer_Abstract
|
| 43 |
{
|
| 44 |
protected $_standardImageFields = array('image', 'small_image', 'thumbnail');
|
| 45 |
protected $_useAttributes;
|
| 61 |
|
| 62 |
const ISPKEY = 'ISPKEY_';
|
| 63 |
|
| 64 |
+
/**
|
| 65 |
+
* Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product constructor.
|
| 66 |
+
*/
|
| 67 |
public function __construct()
|
| 68 |
{
|
| 69 |
$this->_attributesValuesCache = array();
|
| 70 |
$this->_attributesSetsCache = array();
|
| 71 |
}
|
| 72 |
|
| 73 |
+
/**
|
| 74 |
+
* SetXmlElement
|
| 75 |
+
*
|
| 76 |
+
* @param Autocompleteplus_Autosuggest_Xml_Generator $xmlGenerator comment
|
| 77 |
+
*
|
| 78 |
+
* @return $this
|
| 79 |
+
*/
|
| 80 |
public function setXmlElement(&$xmlGenerator)
|
| 81 |
{
|
| 82 |
$this->_xmlElement = $xmlGenerator;
|
| 83 |
+
|
| 84 |
return $this;
|
| 85 |
}
|
| 86 |
|
| 87 |
+
/**
|
| 88 |
+
* GetXmlElement
|
| 89 |
+
*
|
| 90 |
+
* @return mixed
|
| 91 |
+
*/
|
| 92 |
public function getXmlElement()
|
| 93 |
{
|
| 94 |
return $this->_xmlElement;
|
| 95 |
}
|
| 96 |
|
| 97 |
+
/**
|
| 98 |
+
* SetProduct
|
| 99 |
+
*
|
| 100 |
+
* @param Mage_Catalog_Model_Product $product comment
|
| 101 |
+
*
|
| 102 |
+
* @return $this
|
| 103 |
+
*/
|
| 104 |
public function setProduct($product)
|
| 105 |
{
|
| 106 |
$this->_product = $product;
|
| 107 |
+
|
| 108 |
return $this;
|
| 109 |
}
|
| 110 |
|
| 111 |
+
/**
|
| 112 |
+
* GetProduct
|
| 113 |
+
*
|
| 114 |
+
* @return mixed
|
| 115 |
+
*/
|
| 116 |
public function getProduct()
|
| 117 |
{
|
| 118 |
return $this->_product;
|
| 119 |
}
|
| 120 |
|
| 121 |
+
/**
|
| 122 |
+
* GetImageField
|
| 123 |
+
*
|
| 124 |
+
* @return mixed
|
| 125 |
+
*/
|
| 126 |
public function getImageField()
|
| 127 |
{
|
| 128 |
if (!$this->_imageField) {
|
| 129 |
+
$this->_imageField = Mage::getStoreConfig(
|
| 130 |
+
'autocompleteplus/config/imagefield'
|
| 131 |
+
);
|
| 132 |
}
|
| 133 |
+
|
| 134 |
return $this->_imageField;
|
| 135 |
}
|
| 136 |
|
| 137 |
+
/**
|
| 138 |
+
* CanUseAttributes
|
| 139 |
+
*
|
| 140 |
+
* @return bool
|
| 141 |
+
*/
|
| 142 |
public function canUseAttributes()
|
| 143 |
{
|
| 144 |
if (!$this->_useAttributes) {
|
| 145 |
+
$this->_useAttributes = Mage::getStoreConfigFlag(
|
| 146 |
+
'autocompleteplus/config/attributes'
|
| 147 |
+
);
|
| 148 |
}
|
| 149 |
+
|
| 150 |
return $this->_useAttributes;
|
| 151 |
}
|
| 152 |
|
| 153 |
+
/**
|
| 154 |
+
* GetRootCategoryId
|
| 155 |
+
*
|
| 156 |
+
* @return int
|
| 157 |
+
*/
|
| 158 |
public function getRootCategoryId()
|
| 159 |
{
|
| 160 |
if (!$this->_rootCategoryId) {
|
| 161 |
+
$this->_rootCategoryId = Mage::app()
|
| 162 |
+
->getStore($this->getStoreId())->getRootCategoryId();
|
| 163 |
}
|
| 164 |
+
|
| 165 |
return $this->_rootCategoryId;
|
| 166 |
}
|
| 167 |
|
| 168 |
+
/**
|
| 169 |
+
* GetSaleable
|
| 170 |
+
*
|
| 171 |
+
* @return bool
|
| 172 |
+
*/
|
| 173 |
public function getSaleable()
|
| 174 |
{
|
| 175 |
+
return (bool) $this->_saleable;
|
| 176 |
}
|
| 177 |
|
| 178 |
+
/**
|
| 179 |
+
* GetConfigurableChildren
|
| 180 |
+
*
|
| 181 |
+
* @return mixed
|
| 182 |
+
*/
|
| 183 |
public function getConfigurableChildren()
|
| 184 |
{
|
| 185 |
return $this->getProduct()->getTypeInstance()->getUsedProducts();
|
| 186 |
}
|
| 187 |
|
| 188 |
+
/**
|
| 189 |
+
* GetConfigurableChildrenIds
|
| 190 |
+
*
|
| 191 |
+
* @return array
|
| 192 |
+
*/
|
| 193 |
public function getConfigurableChildrenIds()
|
| 194 |
{
|
| 195 |
$configurableChildrenIds = array();
|
| 207 |
return $configurableChildrenIds;
|
| 208 |
}
|
| 209 |
|
| 210 |
+
/**
|
| 211 |
+
* GetProductCollection
|
| 212 |
+
*
|
| 213 |
+
* @param bool $new comment
|
| 214 |
+
*
|
| 215 |
+
* @return object
|
| 216 |
+
*/
|
| 217 |
public function getProductCollection($new = false)
|
| 218 |
{
|
| 219 |
if (!$this->_productCollection) {
|
| 220 |
+
$this->_productCollection = Mage::getModel('catalog/product')
|
| 221 |
+
->getCollection();
|
| 222 |
}
|
| 223 |
|
| 224 |
if ($new === true) {
|
| 228 |
return $this->_productCollection;
|
| 229 |
}
|
| 230 |
|
| 231 |
+
/**
|
| 232 |
+
* GetCategoryMap
|
| 233 |
+
*
|
| 234 |
+
* @return array
|
| 235 |
+
*/
|
| 236 |
public function getCategoryMap()
|
| 237 |
{
|
| 238 |
if (!$this->_categories) {
|
| 240 |
$categories = Mage::getModel('catalog/category')->getCollection();
|
| 241 |
|
| 242 |
foreach ($categories as $category) {
|
| 243 |
+
$categoryMap[] = new Varien_Object(
|
| 244 |
+
array(
|
| 245 |
+
'id' => $category->getId(),
|
| 246 |
+
'path' => $category->getPath(),
|
| 247 |
+
'parent_id' => $category->getParentId(),
|
| 248 |
+
)
|
| 249 |
+
);
|
| 250 |
}
|
| 251 |
$this->_categories = $categoryMap;
|
| 252 |
}
|
| 253 |
+
|
| 254 |
return $this->_categories;
|
| 255 |
}
|
| 256 |
|
| 258 |
{
|
| 259 |
$simple_products_price = array();
|
| 260 |
$pricesByAttributeValues = array();
|
| 261 |
+
$attributes = $this->getProduct()
|
| 262 |
+
->getTypeInstance(true)
|
| 263 |
+
->getConfigurableAttributes($this->getProduct());
|
| 264 |
$basePrice = $this->getProduct()->getFinalPrice();
|
| 265 |
$items = $attributes->getItems();
|
| 266 |
if (is_array($items)) {
|
| 268 |
$prices = $attribute->getPrices();
|
| 269 |
if (is_array($prices)) {
|
| 270 |
foreach ($prices as $price) {
|
| 271 |
+
if ($price['is_percent']) {
|
| 272 |
+
/**
|
| 273 |
+
* If the price is specified in percents
|
| 274 |
+
*/
|
| 275 |
+
$pricesByAttributeValues[$price['value_index']]
|
| 276 |
+
= (float) $price['pricing_value'] * $basePrice / 100;
|
| 277 |
+
} else {
|
| 278 |
+
/**
|
| 279 |
+
* If the price is absolute value
|
| 280 |
+
*/
|
| 281 |
+
$pricesByAttributeValues[$price['value_index']]
|
| 282 |
+
= (float) $price['pricing_value'];
|
| 283 |
}
|
| 284 |
}
|
| 285 |
}
|
| 289 |
foreach ($this->getConfigurableChildren() as $sProduct) {
|
| 290 |
$totalPrice = $basePrice;
|
| 291 |
foreach ($attributes as $attribute) {
|
| 292 |
+
$value = $sProduct->getData(
|
| 293 |
+
$attribute->getProductAttribute()->getAttributeCode()
|
| 294 |
+
);
|
| 295 |
if (isset($pricesByAttributeValues[$value])) {
|
| 296 |
$totalPrice += $pricesByAttributeValues[$value];
|
| 297 |
}
|
| 306 |
{
|
| 307 |
$productCategories = $this->getProduct()->getCategoryIds();
|
| 308 |
$rootCategoryId = $this->getRootCategoryId();
|
| 309 |
+
$paths = array_map(
|
| 310 |
+
function ($category) use ($productCategories, $rootCategoryId) {
|
| 311 |
+
if (in_array($category->getId(), $productCategories)) {
|
| 312 |
+
$path = explode('/', $category->getPath());
|
| 313 |
+
//we don't want the root category for the entire site
|
| 314 |
+
array_shift($path);
|
| 315 |
+
if ($rootCategoryId
|
| 316 |
+
&& is_array($path)
|
| 317 |
+
&& isset($path[0])
|
| 318 |
+
&& $path[0] != $rootCategoryId
|
| 319 |
+
) {
|
| 320 |
+
return array();
|
| 321 |
+
}
|
| 322 |
+
//we want more specific categories first
|
| 323 |
+
return implode(':', array_reverse($path));
|
| 324 |
}
|
| 325 |
+
},
|
| 326 |
+
$this->getCategoryMap()
|
| 327 |
+
);
|
| 328 |
+
|
| 329 |
return array_filter($paths);
|
| 330 |
}
|
| 331 |
|
| 332 |
+
/**
|
| 333 |
+
* GetConfigurableAttributes
|
| 334 |
+
*
|
| 335 |
+
* @return array
|
| 336 |
+
*/
|
| 337 |
public function getConfigurableAttributes()
|
| 338 |
{
|
| 339 |
// Collect options applicable to the configurable product
|
| 340 |
+
$productAttributeOptions = $this->getProduct()
|
| 341 |
+
->getTypeInstance()
|
| 342 |
+
->getConfigurableAttributesAsArray($this->getProduct());
|
| 343 |
$configurableAttributes = array();
|
| 344 |
|
| 345 |
foreach ($productAttributeOptions as $productAttribute) {
|
| 346 |
+
$attributeFull = Mage::getModel('eav/config')
|
| 347 |
+
->getAttribute(
|
| 348 |
+
'catalog_product',
|
| 349 |
+
$productAttribute['attribute_code']
|
| 350 |
+
);
|
| 351 |
|
| 352 |
foreach ($productAttribute['values'] as $attribute) {
|
| 353 |
+
$configurableAttributes[$productAttribute['store_label']]['values'][]
|
| 354 |
+
= $attribute['store_label'];
|
| 355 |
}
|
| 356 |
|
| 357 |
+
$configurableAttributes[$productAttribute['store_label']]
|
| 358 |
+
['is_filterable'] = $attributeFull['is_filterable'];
|
| 359 |
+
$configurableAttributes[$productAttribute['store_label']]
|
| 360 |
+
['frontend_input'] = $attributeFull['frontend_input'];
|
| 361 |
}
|
| 362 |
|
| 363 |
return $configurableAttributes;
|
| 364 |
}
|
| 365 |
|
| 366 |
+
/**
|
| 367 |
+
* GetProductAttributes
|
| 368 |
+
*
|
| 369 |
+
* @return mixed
|
| 370 |
+
*/
|
| 371 |
public function getProductAttributes()
|
| 372 |
{
|
| 373 |
+
return $this->getProduct()
|
| 374 |
+
->getTypeInstance()
|
| 375 |
+
->getConfigurableAttributes($this->getProduct());
|
| 376 |
}
|
| 377 |
|
| 378 |
+
/**
|
| 379 |
+
* GetPriceRange
|
| 380 |
+
*
|
| 381 |
+
* @return array
|
| 382 |
+
*/
|
| 383 |
public function getPriceRange()
|
| 384 |
{
|
| 385 |
$pricesByAttributeValues = array();
|
| 394 |
$prices = $attribute->getPrices();
|
| 395 |
if (is_array($prices)) {
|
| 396 |
foreach ($prices as $price) {
|
| 397 |
+
if ($price['is_percent']) {
|
| 398 |
+
/**
|
| 399 |
+
* If the price is specified in percents
|
| 400 |
+
*/
|
| 401 |
+
$pricesByAttributeValues[$price['value_index']]
|
| 402 |
+
= (float) $price['pricing_value'] * $basePrice / 100;
|
| 403 |
+
} else {
|
| 404 |
+
/**
|
| 405 |
+
* If the price is absolute value
|
| 406 |
+
*/
|
| 407 |
+
$pricesByAttributeValues[$price['value_index']]
|
| 408 |
+
= (float) $price['pricing_value'];
|
| 409 |
}
|
| 410 |
}
|
| 411 |
}
|
| 416 |
foreach ($simple as $sProduct) {
|
| 417 |
$totalPrice = $basePrice;
|
| 418 |
foreach ($attributes as $attribute) {
|
| 419 |
+
$value = $sProduct->getData(
|
| 420 |
+
$attribute->getProductAttribute()->getAttributeCode()
|
| 421 |
+
);
|
| 422 |
if (isset($pricesByAttributeValues[$value])) {
|
| 423 |
$totalPrice += $pricesByAttributeValues[$value];
|
| 424 |
}
|
| 425 |
}
|
| 426 |
+
if (!$min_price || $totalPrice < $min_price) {
|
| 427 |
$min_price = $totalPrice;
|
| 428 |
}
|
| 429 |
+
if (!$max_price || $totalPrice > $max_price) {
|
| 430 |
$max_price = $totalPrice;
|
| 431 |
}
|
| 432 |
}
|
| 433 |
+
if (is_null($min_price)) {
|
| 434 |
$min_price = 0;
|
| 435 |
}
|
| 436 |
+
if (is_null($max_price)) {
|
| 437 |
$max_price = 0;
|
| 438 |
}
|
| 439 |
|
| 440 |
return array(
|
| 441 |
'price_min' => $min_price,
|
| 442 |
+
'price_max' => $max_price,
|
| 443 |
);
|
| 444 |
}
|
| 445 |
|
| 446 |
+
/**
|
| 447 |
+
* GetSimpleProductParent
|
| 448 |
+
*
|
| 449 |
+
* @return mixed
|
| 450 |
+
*/
|
| 451 |
public function getSimpleProductParent()
|
| 452 |
{
|
| 453 |
return Mage::getModel('catalog/product_type_configurable')
|
| 454 |
+
->getParentIdsByChild($this->getProduct()->getId());
|
| 455 |
}
|
| 456 |
|
| 457 |
+
/**
|
| 458 |
+
* GetOrderCount
|
| 459 |
+
*
|
| 460 |
+
* @return int
|
| 461 |
+
*/
|
| 462 |
public function getOrderCount()
|
| 463 |
{
|
| 464 |
+
|
| 465 |
$orderData = $this->getOrderData();
|
| 466 |
+
|
| 467 |
+
return ($this->getOrderData() != null
|
| 468 |
+
&& array_key_exists($this->getProduct()->getId(), $orderData))
|
| 469 |
+
? $orderData[$this->getProduct()->getId()] : 0;
|
| 470 |
}
|
| 471 |
|
| 472 |
+
/**
|
| 473 |
+
* GetProductResource
|
| 474 |
+
*
|
| 475 |
+
* @return object
|
| 476 |
+
*/
|
| 477 |
public function getProductResource()
|
| 478 |
{
|
| 479 |
return Mage::getResourceSingleton('catalog/product');
|
| 482 |
/**
|
| 483 |
* @TODO Refactor indentation/conditions
|
| 484 |
*/
|
| 485 |
+
/**
|
| 486 |
+
* RenderProductVariantXml
|
| 487 |
+
*
|
| 488 |
+
* @param mixed $productXmlElem comment
|
| 489 |
+
*
|
| 490 |
+
* @return void
|
| 491 |
+
*/
|
| 492 |
public function renderProductVariantXml($productXmlElem)
|
| 493 |
{
|
| 494 |
if ($this->canUseAttributes()) {
|
| 495 |
+
if ($this->getProduct()->isConfigurable()
|
| 496 |
+
&& count($this->getConfigurableAttributes()) > 0
|
| 497 |
+
) {
|
| 498 |
$variants = array();
|
| 499 |
+
foreach ($this->getConfigurableAttributes()
|
| 500 |
+
as $attrName => $confAttrN) {
|
| 501 |
+
if (is_array($confAttrN)
|
| 502 |
+
&& array_key_exists('values', $confAttrN)
|
| 503 |
+
) {
|
| 504 |
$variants[] = $attrName;
|
| 505 |
$values = implode(' , ', $confAttrN['values']);
|
| 506 |
+
$this->getXmlElement()->createChild(
|
| 507 |
+
'attribute',
|
| 508 |
+
array(
|
| 509 |
+
'is_configurable' => 1,
|
| 510 |
+
'is_filterable' => $confAttrN['is_filterable'],
|
| 511 |
+
'name' => $attrName,
|
| 512 |
+
),
|
| 513 |
$values,
|
| 514 |
$productXmlElem
|
| 515 |
);
|
| 516 |
}
|
| 517 |
}
|
| 518 |
|
| 519 |
+
$simple_products_price = $this
|
| 520 |
+
->getSimpleProductsPriceOfConfigurable();
|
| 521 |
|
| 522 |
if (count($variants) > 0) {
|
| 523 |
+
$variantElem = $this->getXmlElement()
|
| 524 |
+
->createChild('variants', false, false, $productXmlElem);
|
| 525 |
foreach ($this->getConfigurableChildren() as $child_product) {
|
| 526 |
+
if (!in_array(
|
| 527 |
+
$this->getProduct()->getStoreId(),
|
| 528 |
+
$child_product->getStoreIds()
|
| 529 |
+
)) {
|
| 530 |
continue;
|
| 531 |
}
|
| 532 |
|
| 533 |
+
$is_variant_in_stock = (
|
| 534 |
+
$child_product->getStockItem()->getIsInStock()
|
| 535 |
+
) ? 1 : 0;
|
| 536 |
|
| 537 |
if (method_exists($child_product, 'isSaleable')) {
|
| 538 |
+
$is_variant_sellable = (
|
| 539 |
+
$child_product->isSaleable()
|
| 540 |
+
) ? 1 : 0;
|
| 541 |
} else {
|
| 542 |
$is_variant_sellable = '';
|
| 543 |
}
|
| 544 |
|
| 545 |
if (method_exists($child_product, 'getVisibility')) {
|
| 546 |
+
$is_variant_visible = (
|
| 547 |
+
$child_product->getVisibility()
|
| 548 |
+
) ? 1 : 0;
|
| 549 |
} else {
|
| 550 |
$is_variant_visible = '';
|
| 551 |
}
|
| 552 |
|
| 553 |
+
$variant_price = (array_key_exists(
|
| 554 |
+
$child_product->getId(),
|
| 555 |
+
$simple_products_price
|
| 556 |
+
)) ?
|
| 557 |
$simple_products_price[$child_product->getId()] : '';
|
| 558 |
|
| 559 |
+
$productVariation = $this->getXmlElement()
|
| 560 |
+
->createChild(
|
| 561 |
+
'variant',
|
| 562 |
+
array(
|
| 563 |
+
'id' => $child_product->getId(),
|
| 564 |
+
'type' => $child_product->getTypeID(),
|
| 565 |
+
'visibility' => $is_variant_visible,
|
| 566 |
+
'is_in_stock' => $is_variant_in_stock,
|
| 567 |
+
'is_seallable' => $is_variant_sellable,
|
| 568 |
+
'price' => $variant_price,
|
| 569 |
+
),
|
| 570 |
+
false,
|
| 571 |
+
$variantElem
|
| 572 |
+
);
|
| 573 |
|
| 574 |
+
$this->getXmlElement()->createChild(
|
| 575 |
+
'name',
|
| 576 |
+
false,
|
| 577 |
+
$child_product->getName(),
|
| 578 |
+
$productVariation
|
| 579 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 580 |
|
| 581 |
$attributes = $child_product->getAttributes();
|
| 582 |
foreach ($attributes as $attribute) {
|
| 583 |
+
if (!$attribute['is_configurable']
|
| 584 |
+
|| !in_array($attribute['store_label'], $variants)
|
| 585 |
+
) {
|
| 586 |
continue;
|
| 587 |
}
|
| 588 |
|
| 589 |
+
if (!$attribute['store_label']) {
|
| 590 |
// skip variant attribute without a name
|
| 591 |
continue;
|
| 592 |
}
|
| 593 |
|
| 594 |
+
$this->getXmlElement()->createChild(
|
| 595 |
+
'variant_attribute',
|
| 596 |
+
array(
|
| 597 |
+
'is_configurable' => 1,
|
| 598 |
+
'is_filterable' => $attribute->getIsFilterable(),
|
| 599 |
+
'name' => $attribute['store_label'],
|
| 600 |
+
'name_code' => $attribute->getId(),
|
| 601 |
+
'value_code' => $child_product->getData(
|
| 602 |
+
$attribute->getAttributeCode()
|
| 603 |
+
),
|
| 604 |
+
), utf8_encode(
|
| 605 |
+
htmlspecialchars(
|
| 606 |
+
$attribute->getFrontend()->getValue($child_product)
|
| 607 |
+
)
|
| 608 |
+
), $productVariation
|
| 609 |
);
|
| 610 |
}
|
| 611 |
}
|
| 614 |
}
|
| 615 |
}
|
| 616 |
|
| 617 |
+
/**
|
| 618 |
+
* RenderProductAttributeXml
|
| 619 |
+
*
|
| 620 |
+
* @param mixed $attr comment
|
| 621 |
+
* @param mixed $productXmlElem comment
|
| 622 |
+
*
|
| 623 |
+
* @return void
|
| 624 |
+
*/
|
| 625 |
public function renderProductAttributeXml($attr, $productXmlElem)
|
| 626 |
{
|
| 627 |
if ($this->canUseAttributes()) {
|
| 635 |
|
| 636 |
$is_filterable = $attr->getIsFilterable();
|
| 637 |
$attribute_label = $attr->getFrontendLabel();
|
| 638 |
+
$_helper = $this->_getOutputHelper();
|
| 639 |
|
| 640 |
try {
|
|
|
|
| 641 |
switch ($attr->getFrontendInput()) {
|
| 642 |
case 'select':
|
| 643 |
if (method_exists($this->getProduct(), 'getAttributeText')) {
|
| 644 |
+
/**
|
| 645 |
+
* We generate key for cached attributes array
|
| 646 |
* we make it as string to avoid null to be a key
|
| 647 |
*/
|
| 648 |
+
$attrValidKey = $attrValue != null ? self::ISPKEY.$attrValue : self::ISPKEY;
|
| 649 |
|
| 650 |
if (!array_key_exists($attrValidKey, $this->_attributesValuesCache[$action])) {
|
| 651 |
$attrValueText = $_helper->productAttribute(
|
| 676 |
$attrValue = null;
|
| 677 |
break;
|
| 678 |
}
|
| 679 |
+
} catch (Exception $e) {
|
|
|
|
| 680 |
Mage::log($e->getMessage(), null, 'autocomplete.log', true);
|
| 681 |
}
|
| 682 |
|
|
|
|
| 683 |
if ($attrValue) {
|
| 684 |
$attributeElem = $this->getXmlElement()->createChild('attribute', array(
|
| 685 |
'is_filterable' => $is_filterable,
|
| 686 |
+
'name' => $attr->getAttributeCode(),
|
| 687 |
), false, $productXmlElem);
|
| 688 |
|
| 689 |
$this->getXmlElement()->createChild('attribute_values', false,
|
| 701 |
$saleable = 0;
|
| 702 |
|
| 703 |
try {
|
| 704 |
+
if ($this->getProduct()->getData('isp_sellable') == 1) {
|
| 705 |
$saleable = 1;
|
| 706 |
+
} else {
|
| 707 |
+
$saleable = $this->getProduct()->isSalable() ? 1 : 0;
|
| 708 |
}
|
| 709 |
+
} catch (Exception $e) {
|
| 710 |
Mage::log($e->getMessage(), null, 'autocomplete.log', true);
|
| 711 |
}
|
| 712 |
|
| 725 |
}
|
| 726 |
|
| 727 |
$productElement = $this->getXmlElement()->createChild('product', array(
|
| 728 |
+
'price_min' => ($priceRange['price_min']),
|
| 729 |
+
'price_max' => ($priceRange['price_max']),
|
| 730 |
+
'store' => ($this->getStoreId()),
|
| 731 |
+
'store_id' => ($this->getStoreId()),
|
| 732 |
+
'storeid' => ($this->getStoreId()),
|
| 733 |
+
'id' => ($this->getProduct()->getId()),
|
| 734 |
+
'type' => ($this->getProduct()->getTypeId()),
|
| 735 |
+
'currency' => ($this->getCurrency()),
|
| 736 |
+
'visibility' => ($this->getProduct()->getVisibility()),
|
| 737 |
+
'price' => ($this->getProduct()->getFinalPrice()),
|
| 738 |
+
'url' => $url,
|
| 739 |
+
'thumbs' => utf8_encode(htmlspecialchars((Mage::helper('catalog/image')->init($this->getProduct(), $this->getImageField())))),
|
| 740 |
+
'base_image' => utf8_encode(htmlspecialchars((Mage::getModel('catalog/product_media_config')->getMediaUrl($this->getProduct()->getImage())))),
|
| 741 |
+
'selleable' => ($saleable),
|
| 742 |
+
'action' => ($this->getAction()),
|
| 743 |
+
'last_updated' => ($this->getProduct()->getUpdatedAt()),
|
| 744 |
+
'updatedate' => ($this->getUpdateDate()),
|
| 745 |
+
'get_by_id_status' => intval($this->getGetByIdStatus()),
|
| 746 |
));
|
| 747 |
|
| 748 |
$productRating = $this->getProduct()->getRatingSummary();
|
| 755 |
$this->getXmlElement()->createChild('sku', false,
|
| 756 |
$this->getProduct()->getSku(), $productElement);
|
| 757 |
|
|
|
|
| 758 |
$this->getXmlElement()->createChild('url_additional', false,
|
| 759 |
$this->_getAdditionalProductUrl(), $productElement);
|
| 760 |
|
| 822 |
$this->getProduct()->getMetaTitle(), $productElement);
|
| 823 |
$this->getXmlElement()->createChild('meta_description', false,
|
| 824 |
$this->getProduct()->getMetaDescription(), $productElement);
|
|
|
|
| 825 |
}
|
| 826 |
|
| 827 |
protected function _getOutputHelper()
|
| 828 |
{
|
| 829 |
+
if ($this->_outputHelper == null) {
|
|
|
|
| 830 |
$this->_outputHelper = Mage::helper('catalog/output');
|
| 831 |
}
|
| 832 |
|
| 836 |
public function _getAdditionalProductUrl()
|
| 837 |
{
|
| 838 |
$is_get_url_path_supported = true;
|
| 839 |
+
if (method_exists('Mage', 'getVersionInfo')) {
|
| 840 |
+
/**
|
| 841 |
+
* GetUrlPath is not supported on EE 1.13... & 1.14...
|
| 842 |
+
*/
|
| 843 |
$edition_info = Mage::getVersionInfo();
|
| 844 |
+
if ($edition_info['major'] == 1 && $edition_info['minor'] >= 13) {
|
| 845 |
$is_get_url_path_supported = false;
|
| 846 |
}
|
| 847 |
}
|
| 848 |
|
| 849 |
+
if (method_exists($this->getProduct(), 'getUrlPath') && $is_get_url_path_supported) {
|
| 850 |
$product_url = $this->getProduct()->getUrlPath();
|
| 851 |
+
if ($product_url != '') {
|
| 852 |
$product_url = Mage::getUrl($product_url);
|
| 853 |
+
|
| 854 |
return $product_url;
|
| 855 |
}
|
| 856 |
}
|
| 857 |
+
|
| 858 |
return '';
|
| 859 |
}
|
| 860 |
}
|
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Batches/Collection.php
CHANGED
|
@@ -10,11 +10,13 @@ class Autocompleteplus_Autosuggest_Model_Resource_Batches_Collection extends Mag
|
|
| 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);
|
| 10 |
$this->_init('autocompleteplus_autosuggest/batches');
|
| 11 |
}
|
| 12 |
|
| 13 |
+
protected function _getWriteAdapter()
|
| 14 |
+
{
|
| 15 |
return Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 16 |
}
|
| 17 |
|
| 18 |
+
public function clear()
|
| 19 |
+
{
|
| 20 |
$dbAdapter = $this->_getWriteAdapter();
|
| 21 |
|
| 22 |
Zend_Db_Table::setDefaultAdapter($dbAdapter);
|
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Notifications/Collection.php
CHANGED
|
@@ -13,8 +13,7 @@
|
|
| 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 |
{
|
| 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 extends Mage_Core_Model_Mysql4_Collection_Abstract
|
|
|
|
| 17 |
{
|
| 18 |
protected function _construct()
|
| 19 |
{
|
app/code/local/Autocompleteplus/Autosuggest/Model/Service.php
CHANGED
|
@@ -15,14 +15,14 @@ class Autocompleteplus_Autosuggest_Model_Service
|
|
| 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
|
| 26 |
$inserts[] = array(
|
| 27 |
'store_id' => $id,
|
| 28 |
'to_send' => $productsCount,
|
| 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,
|
app/code/local/Autocompleteplus/Autosuggest/controllers/CategoriesController.php
CHANGED
|
@@ -45,11 +45,11 @@ class Autocompleteplus_Autosuggest_CategoriesController extends Mage_Core_Contro
|
|
| 45 |
'image' => sprintf('%scatalog/category/%s', $mediaUrl, $node->getImage()),
|
| 46 |
'thumbnail' => $thumbnail,
|
| 47 |
'description' => strip_tags($node->getDescription()),
|
| 48 |
-
'parent_id'
|
| 49 |
-
'name'
|
| 50 |
-
'url_path'
|
| 51 |
-
'is_active'
|
| 52 |
-
'children'
|
| 53 |
);
|
| 54 |
|
| 55 |
foreach ($node->getChildren() as $child) {
|
|
@@ -80,7 +80,7 @@ class Autocompleteplus_Autosuggest_CategoriesController extends Mage_Core_Contro
|
|
| 80 |
->addAttributeToFilter('is_active', array('eq' => true));
|
| 81 |
|
| 82 |
if (!$helper->getConfigDataByFullPath('catalog/frontend/flat_catalog_category')) {
|
| 83 |
-
$collection
|
| 84 |
->addAttributeToSelect('description')
|
| 85 |
->addAttributeToSelect('thumbnail');
|
| 86 |
} else {
|
|
@@ -88,22 +88,21 @@ class Autocompleteplus_Autosuggest_CategoriesController extends Mage_Core_Contro
|
|
| 88 |
|
| 89 |
$readConnection = $resource->getConnection('core_read');
|
| 90 |
|
| 91 |
-
$tableName
|
| 92 |
|
| 93 |
-
$tableInfo
|
| 94 |
|
| 95 |
-
if (array_key_exists('thumbnail'
|
| 96 |
-
$collection
|
| 97 |
}
|
| 98 |
|
| 99 |
-
if (array_key_exists('image'
|
| 100 |
-
$collection
|
| 101 |
}
|
| 102 |
|
| 103 |
-
if (array_key_exists('description'
|
| 104 |
-
$collection
|
| 105 |
}
|
| 106 |
-
|
| 107 |
}
|
| 108 |
|
| 109 |
$tree->addCollectionData($collection, true);
|
| 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) {
|
| 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 {
|
| 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 |
$tree->addCollectionData($collection, true);
|
app/code/local/Autocompleteplus/Autosuggest/controllers/LayeredController.php
CHANGED
|
@@ -1,7 +1,30 @@
|
|
| 1 |
<?php
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controller_Front_Action
|
| 4 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
public function preDispatch()
|
| 6 |
{
|
| 7 |
parent::preDispatch();
|
|
@@ -10,11 +33,21 @@ class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controlle
|
|
| 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();
|
|
@@ -25,7 +58,9 @@ class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controlle
|
|
| 25 |
$scopeId = $request->getParam('store_id', 1);
|
| 26 |
|
| 27 |
if (!$this->valid($uuid, $authkey)) {
|
| 28 |
-
$resp = json_encode(
|
|
|
|
|
|
|
| 29 |
$response->setBody($resp);
|
| 30 |
|
| 31 |
return;
|
|
@@ -35,7 +70,7 @@ class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controlle
|
|
| 35 |
$this->_getConfig()->enableLayeredNavigation($scope, $scopeId);
|
| 36 |
Mage::app()->getCacheInstance()->cleanType('config');
|
| 37 |
} catch (Exception $e) {
|
| 38 |
-
$resp = json_encode(array('status' => 'error: '
|
| 39 |
$response->setBody($resp);
|
| 40 |
|
| 41 |
Mage::logException($e);
|
|
@@ -50,6 +85,11 @@ class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controlle
|
|
| 50 |
$response->setBody(json_encode($resp));
|
| 51 |
}
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
public function setLayeredSearchOffAction()
|
| 54 |
{
|
| 55 |
$request = $this->getRequest();
|
|
@@ -60,7 +100,11 @@ class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controlle
|
|
| 60 |
$scopeId = $request->getParam('store_id', 1);
|
| 61 |
|
| 62 |
if (!$this->valid($uuid, $authkey)) {
|
| 63 |
-
$resp = json_encode(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
$response->setBody($resp);
|
| 66 |
|
|
@@ -71,7 +115,7 @@ class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controlle
|
|
| 71 |
$this->_getConfig()->disableLayeredNavigation($scope, $scopeId);
|
| 72 |
Mage::app()->getCacheInstance()->cleanType('config');
|
| 73 |
} catch (Exception $e) {
|
| 74 |
-
$resp = json_encode(array('status' => 'error: '
|
| 75 |
$response->setBody($resp);
|
| 76 |
|
| 77 |
Mage::logException($e);
|
|
@@ -86,6 +130,11 @@ class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controlle
|
|
| 86 |
$response->setBody(json_encode($resp));
|
| 87 |
}
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
public function getLayeredSearchConfigAction()
|
| 90 |
{
|
| 91 |
$request = $this->getRequest();
|
|
@@ -96,7 +145,11 @@ class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controlle
|
|
| 96 |
$scopeId = $request->getParam('store_id', 1);
|
| 97 |
|
| 98 |
if (!$this->valid($uuid, $authkey)) {
|
| 99 |
-
$resp = json_encode(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
$response->setBody($resp);
|
| 101 |
|
| 102 |
return;
|
|
@@ -105,7 +158,7 @@ class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controlle
|
|
| 105 |
Mage::app()->getCacheInstance()->cleanType('config');
|
| 106 |
$current_state = $this->_getConfig()->getLayeredNavigationStatus($scopeId);
|
| 107 |
} catch (Exception $e) {
|
| 108 |
-
$resp = json_encode(array('status' => 'error: '
|
| 109 |
$response->setBody($resp);
|
| 110 |
|
| 111 |
Mage::logException($e);
|
|
@@ -117,10 +170,19 @@ class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controlle
|
|
| 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 |
|
| 1 |
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Autocompleteplus_Autosuggest_LayeredController
|
| 4 |
+
* Used in creating options for Yes|No config value selection.
|
| 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 |
+
* PHP version 5
|
| 12 |
+
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
+
*/
|
| 21 |
class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controller_Front_Action
|
| 22 |
{
|
| 23 |
+
/**
|
| 24 |
+
* Set headers
|
| 25 |
+
*
|
| 26 |
+
* @return void
|
| 27 |
+
*/
|
| 28 |
public function preDispatch()
|
| 29 |
{
|
| 30 |
parent::preDispatch();
|
| 33 |
$this->getResponse()->setHeader('Content-type', 'application/json');
|
| 34 |
}
|
| 35 |
|
| 36 |
+
/**
|
| 37 |
+
* Get ext config
|
| 38 |
+
*
|
| 39 |
+
* @return false|Mage_Core_Model_Abstract
|
| 40 |
+
*/
|
| 41 |
protected function _getConfig()
|
| 42 |
{
|
| 43 |
return Mage::getModel('autocompleteplus_autosuggest/config');
|
| 44 |
}
|
| 45 |
|
| 46 |
+
/**
|
| 47 |
+
* Switches on layered search
|
| 48 |
+
*
|
| 49 |
+
* @return void
|
| 50 |
+
*/
|
| 51 |
public function setLayeredSearchOnAction()
|
| 52 |
{
|
| 53 |
$response = $this->getResponse();
|
| 58 |
$scopeId = $request->getParam('store_id', 1);
|
| 59 |
|
| 60 |
if (!$this->valid($uuid, $authkey)) {
|
| 61 |
+
$resp = json_encode(
|
| 62 |
+
array('status' => 'error: '.'Authentication failed')
|
| 63 |
+
);
|
| 64 |
$response->setBody($resp);
|
| 65 |
|
| 66 |
return;
|
| 70 |
$this->_getConfig()->enableLayeredNavigation($scope, $scopeId);
|
| 71 |
Mage::app()->getCacheInstance()->cleanType('config');
|
| 72 |
} catch (Exception $e) {
|
| 73 |
+
$resp = json_encode(array('status' => 'error: '.$e->getMessage()));
|
| 74 |
$response->setBody($resp);
|
| 75 |
|
| 76 |
Mage::logException($e);
|
| 85 |
$response->setBody(json_encode($resp));
|
| 86 |
}
|
| 87 |
|
| 88 |
+
/**
|
| 89 |
+
* Switches off layered search
|
| 90 |
+
*
|
| 91 |
+
* @return void
|
| 92 |
+
*/
|
| 93 |
public function setLayeredSearchOffAction()
|
| 94 |
{
|
| 95 |
$request = $this->getRequest();
|
| 100 |
$scopeId = $request->getParam('store_id', 1);
|
| 101 |
|
| 102 |
if (!$this->valid($uuid, $authkey)) {
|
| 103 |
+
$resp = json_encode(
|
| 104 |
+
array(
|
| 105 |
+
'status' => 'error: '.'Authentication failed'
|
| 106 |
+
)
|
| 107 |
+
);
|
| 108 |
|
| 109 |
$response->setBody($resp);
|
| 110 |
|
| 115 |
$this->_getConfig()->disableLayeredNavigation($scope, $scopeId);
|
| 116 |
Mage::app()->getCacheInstance()->cleanType('config');
|
| 117 |
} catch (Exception $e) {
|
| 118 |
+
$resp = json_encode(array('status' => 'error: '.$e->getMessage()));
|
| 119 |
$response->setBody($resp);
|
| 120 |
|
| 121 |
Mage::logException($e);
|
| 130 |
$response->setBody(json_encode($resp));
|
| 131 |
}
|
| 132 |
|
| 133 |
+
/**
|
| 134 |
+
* Get layered configuration
|
| 135 |
+
*
|
| 136 |
+
* @return void
|
| 137 |
+
*/
|
| 138 |
public function getLayeredSearchConfigAction()
|
| 139 |
{
|
| 140 |
$request = $this->getRequest();
|
| 145 |
$scopeId = $request->getParam('store_id', 1);
|
| 146 |
|
| 147 |
if (!$this->valid($uuid, $authkey)) {
|
| 148 |
+
$resp = json_encode(
|
| 149 |
+
array(
|
| 150 |
+
'status' => $this->__('error: Authentication failed')
|
| 151 |
+
)
|
| 152 |
+
);
|
| 153 |
$response->setBody($resp);
|
| 154 |
|
| 155 |
return;
|
| 158 |
Mage::app()->getCacheInstance()->cleanType('config');
|
| 159 |
$current_state = $this->_getConfig()->getLayeredNavigationStatus($scopeId);
|
| 160 |
} catch (Exception $e) {
|
| 161 |
+
$resp = json_encode(array('status' => 'error: '.$e->getMessage()));
|
| 162 |
$response->setBody($resp);
|
| 163 |
|
| 164 |
Mage::logException($e);
|
| 170 |
$response->setBody($resp);
|
| 171 |
}
|
| 172 |
|
| 173 |
+
/**
|
| 174 |
+
* Checks if uuid is valid
|
| 175 |
+
*
|
| 176 |
+
* @param string $uuid
|
| 177 |
+
* @param string $authkey
|
| 178 |
+
*
|
| 179 |
+
* @return bool
|
| 180 |
+
*/
|
| 181 |
protected function valid($uuid, $authkey)
|
| 182 |
{
|
| 183 |
if ($this->_getConfig()->getAuthorizationKey() == $authkey
|
| 184 |
+
&& $this->_getConfig()->getUUID() == $uuid
|
| 185 |
+
) {
|
| 186 |
return true;
|
| 187 |
}
|
| 188 |
|
app/code/local/Autocompleteplus/Autosuggest/controllers/ProductsController.php
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
*
|
| 4 |
*
|
| 5 |
* NOTICE OF LICENSE
|
| 6 |
*
|
|
@@ -8,14 +8,38 @@
|
|
| 8 |
* that is available through the world-wide-web at this URL:
|
| 9 |
* http://opensource.org/licenses/osl-3.0.php
|
| 10 |
*
|
| 11 |
-
*
|
| 12 |
*
|
| 13 |
-
* @
|
| 14 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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;
|
|
@@ -25,11 +49,21 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 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');
|
|
@@ -46,13 +80,25 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 46 |
|
| 47 |
Mage::app()->setCurrentStore($storeId);
|
| 48 |
|
| 49 |
-
$xml = $catalogModel->renderCatalogXml(
|
| 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();
|
|
@@ -69,7 +115,9 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 69 |
$returnArr = array(
|
| 70 |
'status' => self::STATUS_FAILURE,
|
| 71 |
'error_code' => self::MISSING_PARAMETER,
|
| 72 |
-
'error_details' => $this->__(
|
|
|
|
|
|
|
| 73 |
);
|
| 74 |
$response->setHeader('Content-type', 'application/json');
|
| 75 |
$response->setHttpResponseCode(400);
|
|
@@ -89,6 +137,11 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 89 |
$response->setBody($xml);
|
| 90 |
}
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
public function checkinstallAction()
|
| 93 |
{
|
| 94 |
$response = $this->getResponse();
|
|
@@ -97,29 +150,56 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 97 |
$response->setBody($installStatus);
|
| 98 |
}
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
protected function _getInstallStatus()
|
| 101 |
{
|
| 102 |
-
|
|
|
|
|
|
|
| 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') ?
|
|
|
|
| 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()
|
|
@@ -151,7 +231,10 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 151 |
'site_url' => $site_url,
|
| 152 |
'store_id' => $store_id,
|
| 153 |
'modules' => $installedModules,
|
| 154 |
-
'enabled' => $enabled
|
|
|
|
|
|
|
|
|
|
| 155 |
);
|
| 156 |
|
| 157 |
$response->clearHeaders();
|
|
@@ -159,24 +242,39 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 159 |
$response->setBody(json_encode($result));
|
| 160 |
}
|
| 161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
public function getNumOfProductsAction()
|
| 163 |
{
|
| 164 |
-
$catalogReport = Mage::getModel(
|
|
|
|
|
|
|
| 165 |
$helper = Mage::helper('autocompleteplus_autosuggest');
|
| 166 |
|
| 167 |
-
$result = array(
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 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();
|
|
@@ -192,6 +290,11 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 192 |
$response->setBody(json_encode($result));
|
| 193 |
}
|
| 194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
public function getstoresAction()
|
| 196 |
{
|
| 197 |
$response = $this->getResponse();
|
|
@@ -201,6 +304,11 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 201 |
$response->setBody($helper->getMultiStoreDataJson());
|
| 202 |
}
|
| 203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
protected function _getRobotsPath()
|
| 205 |
{
|
| 206 |
if (!$this->_robotsPath) {
|
|
@@ -210,6 +318,11 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 210 |
return $this->_robotsPath;
|
| 211 |
}
|
| 212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
public function updatesitemapAction()
|
| 214 |
{
|
| 215 |
$helper = Mage::helper('autocompleteplus_autosuggest');
|
|
@@ -239,14 +352,18 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 239 |
|
| 240 |
$data = array();
|
| 241 |
$data['site'] = $url;
|
| 242 |
-
$data['msg'] = $this->__(
|
|
|
|
|
|
|
| 243 |
$res = $helper->sendPostCurl($command, $data);
|
| 244 |
}
|
| 245 |
}
|
| 246 |
|
| 247 |
if ($write) {
|
| 248 |
if ($io->isWritable($robotsPath)) {
|
| 249 |
-
|
|
|
|
|
|
|
| 250 |
$io->write($robotsPath, $sitemapUrl, FILE_APPEND | LOCK_EX);
|
| 251 |
} else {
|
| 252 |
//write message that file is not writteble
|
|
@@ -261,17 +378,34 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 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();
|
|
@@ -280,6 +414,11 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 280 |
$response->setBody($helper->getErrormessage());
|
| 281 |
}
|
| 282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
public function setIspUuidAction()
|
| 284 |
{
|
| 285 |
$helper = Mage::helper('autocompleteplus_autosuggest');
|
|
@@ -287,10 +426,12 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 287 |
$storeId = Mage::app()->getStore()->getStoreId();
|
| 288 |
$site_url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
|
| 289 |
|
| 290 |
-
$url = $url_domain.http_build_query(
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
|
|
|
|
|
|
| 294 |
|
| 295 |
$helper = Mage::helper('autocompleteplus_autosuggest');
|
| 296 |
$resp = $helper->sendCurl($url);
|
|
@@ -301,6 +442,11 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 301 |
}
|
| 302 |
}
|
| 303 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 304 |
public function checkDeletedAction()
|
| 305 |
{
|
| 306 |
$response = $this->getResponse();
|
|
@@ -321,27 +467,46 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 321 |
}
|
| 322 |
|
| 323 |
$sql_fetch = 'SELECT identifier FROM '.$table_prefix.'autocompleteplus_checksum WHERE store_id=?';
|
| 324 |
-
|
|
|
|
|
|
|
|
|
|
| 325 |
if (empty($updates)) {
|
| 326 |
return;
|
| 327 |
}
|
| 328 |
|
| 329 |
-
|
|
|
|
|
|
|
|
|
|
| 330 |
$collection = Mage::getResourceModel('catalog/product_collection');
|
| 331 |
$collection->addFieldToFilter('entity_id', array('in' => $checksum_ids));
|
| 332 |
$found_ids = $collection->getAllIds();
|
| 333 |
|
| 334 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
$removed_ids = array();
|
| 336 |
|
| 337 |
-
|
|
|
|
|
|
|
| 338 |
if (!empty($removed_products_list)) {
|
| 339 |
-
$write = Mage::getSingleton('core/resource')
|
|
|
|
| 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(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
$removed_ids[] = $product_id;
|
| 346 |
}
|
| 347 |
}
|
|
@@ -357,13 +522,24 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 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(
|
| 366 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 367 |
$start_index = $request->getParam('offset', 0);
|
| 368 |
$php_timeout = $request->getParam('timeout', -1);
|
| 369 |
$is_single = $request->getParam('is_single', 0);
|
|
@@ -373,14 +549,18 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 373 |
|
| 374 |
if (!$helper->isChecksumTableExists()) {
|
| 375 |
$helper->ispErrorLog('checksum table not exist');
|
| 376 |
-
$response->setBody(
|
|
|
|
|
|
|
| 377 |
|
| 378 |
return;
|
| 379 |
}
|
| 380 |
|
| 381 |
$max_exe_time = -1;
|
| 382 |
|
| 383 |
-
if ($count > self::MAX_NUM_OF_PRODUCTS_CHECKSUM_ITERATION
|
|
|
|
|
|
|
| 384 |
$max_exe_time = ini_get('max_execution_time');
|
| 385 |
ini_set('max_execution_time', $php_timeout);
|
| 386 |
}
|
|
@@ -397,11 +577,18 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 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 .= (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 403 |
$server_url = $checksum_server.'/magento_logging_record';
|
| 404 |
-
$request = $server_url.'?uuid='.$uuid.
|
|
|
|
|
|
|
| 405 |
if ($store_id) {
|
| 406 |
$request .= '&store_id='.$store_id;
|
| 407 |
}
|
|
@@ -413,16 +600,33 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 413 |
$iter = $start_index;
|
| 414 |
while ($iter < $count) {
|
| 415 |
// start updating the checksum table if needed
|
| 416 |
-
$num_of_updated_checksum += $helper->compareProductsChecksum(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 422 |
}
|
| 423 |
|
| 424 |
$process_time = time() - $start_time;
|
| 425 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
$args = array(
|
| 427 |
'uuid' => $uuid,
|
| 428 |
'site_url' => $site_url,
|
|
@@ -433,128 +637,148 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
|
|
| 433 |
'start_index' => $start_index,
|
| 434 |
'end_index' => $start_index + $count,
|
| 435 |
'count' => $count,
|
| 436 |
-
'ext_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(
|
|
|
|
|
|
|
| 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 |
-
|
| 465 |
-
$request = $this->getRequest();
|
| 466 |
$response = $this->getResponse();
|
| 467 |
|
| 468 |
$response->clearHeaders();
|
| 469 |
$response->setHeader('Content-type', 'application/json');
|
| 470 |
-
$pushId
|
| 471 |
-
$helper
|
| 472 |
-
$data
|
| 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')
|
|
|
|
| 483 |
$sent = $pusher->getSent();
|
| 484 |
|
| 485 |
-
if($sent==1){
|
| 486 |
-
$responseArr = array(
|
|
|
|
|
|
|
|
|
|
| 487 |
$response->setBody(json_encode($responseArr));
|
|
|
|
| 488 |
return;
|
| 489 |
-
} elseif ($sent==2){
|
| 490 |
-
$responseArr = array(
|
|
|
|
|
|
|
|
|
|
| 491 |
$response->setBody(json_encode($responseArr));
|
|
|
|
| 492 |
return;
|
| 493 |
} else {
|
| 494 |
$pusher->setSent(1);
|
| 495 |
$pusher->save();
|
| 496 |
}
|
| 497 |
|
| 498 |
-
$offset
|
| 499 |
-
$count
|
| 500 |
-
$storeId
|
| 501 |
-
$to_send
|
| 502 |
$total_batches = $pusher->gettotal_batches();
|
| 503 |
-
$catalogModel
|
| 504 |
-
$url
|
| 505 |
-
$server_url
|
| 506 |
-
$cmd_url
|
| 507 |
|
| 508 |
// setting post data and command url
|
| 509 |
-
$data['uuid']
|
| 510 |
-
$data['site_url']
|
| 511 |
-
$data['store_id']
|
| 512 |
$data['authentication_key'] = $helper->getKey();
|
| 513 |
-
$data['total_batches']
|
| 514 |
-
$data['batch_number']
|
| 515 |
-
$data['products']
|
|
|
|
| 516 |
|
| 517 |
-
if ($offset
|
| 518 |
$data['is_last'] = 1;
|
| 519 |
-
$count
|
| 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'
|
| 528 |
$response->setBody($responseArr);
|
|
|
|
| 529 |
return;
|
| 530 |
}
|
| 531 |
|
| 532 |
-
|
| 533 |
$pusher->setSent(2);
|
| 534 |
$pusher->save();
|
| 535 |
|
| 536 |
-
$nextPushId
|
| 537 |
$nextPushUrl = '';
|
| 538 |
|
| 539 |
-
if($nextPushId!=''){
|
| 540 |
-
$nextPushUrl
|
| 541 |
}
|
| 542 |
|
| 543 |
-
$totalPushes = Mage::getModel('autocompleteplus_autosuggest/pusher')
|
|
|
|
|
|
|
| 544 |
|
| 545 |
-
$updatedStatus = 'Syncing: push '
|
| 546 |
-
$updatedSuccessStatus = 'Successfully synced '
|
| 547 |
|
| 548 |
$responseArr = array(
|
| 549 |
-
'success'
|
| 550 |
-
'updatedStatus'
|
| 551 |
'updatedSuccessStatus' => $updatedSuccessStatus,
|
| 552 |
-
'message'
|
| 553 |
-
'nextPushUrl'
|
| 554 |
-
'count'
|
| 555 |
);
|
| 556 |
|
| 557 |
$response->setBody(json_encode($responseArr));
|
| 558 |
-
|
| 559 |
}
|
| 560 |
}
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* ProductsController File
|
| 4 |
*
|
| 5 |
* NOTICE OF LICENSE
|
| 6 |
*
|
| 8 |
* that is available through the world-wide-web at this URL:
|
| 9 |
* http://opensource.org/licenses/osl-3.0.php
|
| 10 |
*
|
| 11 |
+
* PHP version 5
|
| 12 |
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Autocompleteplus_Autosuggest_ProductsController
|
| 24 |
+
*
|
| 25 |
+
* NOTICE OF LICENSE
|
| 26 |
+
*
|
| 27 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 28 |
+
* that is available through the world-wide-web at this URL:
|
| 29 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 30 |
+
*
|
| 31 |
+
* PHP version 5
|
| 32 |
+
*
|
| 33 |
+
* @category Mage
|
| 34 |
+
*
|
| 35 |
+
* @package Instantsearchplus
|
| 36 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 37 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 38 |
+
* @license Open Software License (OSL 3.0)*
|
| 39 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 40 |
*/
|
| 41 |
class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_Autosuggest_Controller_Abstract
|
| 42 |
{
|
|
|
|
| 43 |
const MAX_NUM_OF_PRODUCTS_CHECKSUM_ITERATION = 250;
|
| 44 |
const MISSING_PARAMETER = 'false';
|
| 45 |
const PUSH_IN_PROGRESS = 1;
|
| 49 |
const URL_UUID_UPDATE = 'http://magento.instantsearchplus.com/update_uuid';
|
| 50 |
const XML_CONFIG_STORE_EMAIL = 'autocompleteplus/config/store_email';
|
| 51 |
|
| 52 |
+
/**
|
| 53 |
+
* Get ext config
|
| 54 |
+
*
|
| 55 |
+
* @return false|Mage_Core_Model_Abstract
|
| 56 |
+
*/
|
| 57 |
protected function _getConfig()
|
| 58 |
{
|
| 59 |
return Mage::getModel('autocompleteplus_autosuggest/config');
|
| 60 |
}
|
| 61 |
|
| 62 |
+
/**
|
| 63 |
+
* Returns products batch
|
| 64 |
+
*
|
| 65 |
+
* @return void
|
| 66 |
+
*/
|
| 67 |
public function sendAction()
|
| 68 |
{
|
| 69 |
Varien_Profiler::start('Autocompleteplus_Autosuggest_Products_Send');
|
| 80 |
|
| 81 |
Mage::app()->setCurrentStore($storeId);
|
| 82 |
|
| 83 |
+
$xml = $catalogModel->renderCatalogXml(
|
| 84 |
+
$startInd,
|
| 85 |
+
$count,
|
| 86 |
+
$storeId,
|
| 87 |
+
$orders,
|
| 88 |
+
$monthInterval,
|
| 89 |
+
$checksum
|
| 90 |
+
);
|
| 91 |
+
|
| 92 |
$response->setHeader('Content-type', 'text/xml');
|
| 93 |
$response->setBody($xml);
|
| 94 |
Varien_Profiler::stop('Autocompleteplus_Autosuggest_Products_Send');
|
| 95 |
}
|
| 96 |
|
| 97 |
+
/**
|
| 98 |
+
* Returns updated products batch
|
| 99 |
+
*
|
| 100 |
+
* @return void
|
| 101 |
+
*/
|
| 102 |
public function sendupdatedAction()
|
| 103 |
{
|
| 104 |
$request = $this->getRequest();
|
| 115 |
$returnArr = array(
|
| 116 |
'status' => self::STATUS_FAILURE,
|
| 117 |
'error_code' => self::MISSING_PARAMETER,
|
| 118 |
+
'error_details' => $this->__(
|
| 119 |
+
'The "store id" parameter is mandatory'
|
| 120 |
+
),
|
| 121 |
);
|
| 122 |
$response->setHeader('Content-type', 'application/json');
|
| 123 |
$response->setHttpResponseCode(400);
|
| 137 |
$response->setBody($xml);
|
| 138 |
}
|
| 139 |
|
| 140 |
+
/**
|
| 141 |
+
* Checks install
|
| 142 |
+
*
|
| 143 |
+
* @return void
|
| 144 |
+
*/
|
| 145 |
public function checkinstallAction()
|
| 146 |
{
|
| 147 |
$response = $this->getResponse();
|
| 150 |
$response->setBody($installStatus);
|
| 151 |
}
|
| 152 |
|
| 153 |
+
/**
|
| 154 |
+
* Returns install status
|
| 155 |
+
*
|
| 156 |
+
* @return string
|
| 157 |
+
*/
|
| 158 |
protected function _getInstallStatus()
|
| 159 |
{
|
| 160 |
+
$uuid = $this->_getConfig()->getUUID();
|
| 161 |
+
|
| 162 |
+
if (strlen($uuid) > 0 && $uuid != 'failed') {
|
| 163 |
return $this->__('the key exists');
|
| 164 |
}
|
| 165 |
|
| 166 |
return $this->__('no key inside');
|
| 167 |
}
|
| 168 |
|
| 169 |
+
/**
|
| 170 |
+
* Returns version info json
|
| 171 |
+
*
|
| 172 |
+
* @return void
|
| 173 |
+
*/
|
| 174 |
public function versAction()
|
| 175 |
{
|
| 176 |
$response = $this->getResponse();
|
| 177 |
$get_modules = $this->getRequest()->getParam('modules', false);
|
| 178 |
$mage = Mage::getVersion();
|
| 179 |
$ext = Mage::helper('autocompleteplus_autosuggest')->getVersion();
|
| 180 |
+
$edition = method_exists('Mage', 'getEdition') ?
|
| 181 |
+
Mage::getEdition() : 'Community';
|
| 182 |
$helper = Mage::helper('autocompleteplus_autosuggest');
|
| 183 |
$uuid = $this->_getConfig()->getUUID();
|
| 184 |
$site_url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
|
| 185 |
$store_id = Mage::app()->getStore()->getStoreId();
|
| 186 |
$installedModules = array();
|
| 187 |
|
| 188 |
+
$enabled = Mage::getStoreConfigFlag('autocompleteplus/config/enabled', 0);
|
| 189 |
+
|
| 190 |
+
$flatProductsEnabled = Mage::getStoreConfigFlag(
|
| 191 |
+
'catalog/frontend/flat_catalog_product', 0
|
| 192 |
+
);
|
| 193 |
+
|
| 194 |
+
$flatCategoriesEnabled = Mage::getStoreConfigFlag(
|
| 195 |
+
'catalog/frontend/flat_catalog_category', 0
|
| 196 |
+
);
|
| 197 |
+
|
| 198 |
+
if (defined('COMPILER_INCLUDE_PATH')) {
|
| 199 |
+
$compilerEnabled = true;
|
| 200 |
+
} else {
|
| 201 |
+
$compilerEnabled = false;
|
| 202 |
+
}
|
| 203 |
|
| 204 |
try {
|
| 205 |
$num_of_products = Mage::getModel('catalog/product')->getCollection()
|
| 231 |
'site_url' => $site_url,
|
| 232 |
'store_id' => $store_id,
|
| 233 |
'modules' => $installedModules,
|
| 234 |
+
'enabled' => $enabled,
|
| 235 |
+
'flat_products_enabled' => $flatProductsEnabled,
|
| 236 |
+
'flat_categories_enabled' => $flatCategoriesEnabled,
|
| 237 |
+
'compiler_enabled' => $compilerEnabled
|
| 238 |
);
|
| 239 |
|
| 240 |
$response->clearHeaders();
|
| 242 |
$response->setBody(json_encode($result));
|
| 243 |
}
|
| 244 |
|
| 245 |
+
/**
|
| 246 |
+
* Returns number of products
|
| 247 |
+
*
|
| 248 |
+
* @return string
|
| 249 |
+
*/
|
| 250 |
public function getNumOfProductsAction()
|
| 251 |
{
|
| 252 |
+
$catalogReport = Mage::getModel(
|
| 253 |
+
'autocompleteplus_autosuggest/catalogreport'
|
| 254 |
+
);
|
| 255 |
$helper = Mage::helper('autocompleteplus_autosuggest');
|
| 256 |
|
| 257 |
+
$result = array(
|
| 258 |
+
'num_of_products' => $catalogReport->getEnabledProductsCount(),
|
| 259 |
+
'num_of_disabled_products' => $catalogReport->getDisabledProductsCount(),
|
| 260 |
+
'num_of_searchable_products' => $catalogReport
|
| 261 |
+
->getSearchableProductsCount(),
|
| 262 |
+
'num_of_searchable_products2' => $catalogReport
|
| 263 |
+
->getSearchableProducts2Count(),
|
| 264 |
+
'uuid' => $this->_getConfig()->getUUID(),
|
| 265 |
+
'site_url' => $helper->getConfigDataByFullPath('web/unsecure/base_url'),
|
| 266 |
+
'store_id' => $catalogReport->getCurrentStoreId(),
|
| 267 |
+
);
|
| 268 |
|
| 269 |
$this->getResponse()->setHeader('Content-type', 'application/json');
|
| 270 |
$this->getResponse()->setBody(json_encode($result));
|
| 271 |
}
|
| 272 |
|
| 273 |
+
/**
|
| 274 |
+
* Returns conflicts json
|
| 275 |
+
*
|
| 276 |
+
* @return void
|
| 277 |
+
*/
|
| 278 |
public function getConflictAction()
|
| 279 |
{
|
| 280 |
$response = $this->getResponse();
|
| 290 |
$response->setBody(json_encode($result));
|
| 291 |
}
|
| 292 |
|
| 293 |
+
/**
|
| 294 |
+
* Returns orders json
|
| 295 |
+
*
|
| 296 |
+
* @return void
|
| 297 |
+
*/
|
| 298 |
public function getstoresAction()
|
| 299 |
{
|
| 300 |
$response = $this->getResponse();
|
| 304 |
$response->setBody($helper->getMultiStoreDataJson());
|
| 305 |
}
|
| 306 |
|
| 307 |
+
/**
|
| 308 |
+
* Returns robots path
|
| 309 |
+
*
|
| 310 |
+
* @return string
|
| 311 |
+
*/
|
| 312 |
protected function _getRobotsPath()
|
| 313 |
{
|
| 314 |
if (!$this->_robotsPath) {
|
| 318 |
return $this->_robotsPath;
|
| 319 |
}
|
| 320 |
|
| 321 |
+
/**
|
| 322 |
+
* Updates sitemap
|
| 323 |
+
*
|
| 324 |
+
* @return void
|
| 325 |
+
*/
|
| 326 |
public function updatesitemapAction()
|
| 327 |
{
|
| 328 |
$helper = Mage::helper('autocompleteplus_autosuggest');
|
| 352 |
|
| 353 |
$data = array();
|
| 354 |
$data['site'] = $url;
|
| 355 |
+
$data['msg'] = $this->__(
|
| 356 |
+
'Directory %s is not writable.', Mage::getBaseDir()
|
| 357 |
+
);
|
| 358 |
$res = $helper->sendPostCurl($command, $data);
|
| 359 |
}
|
| 360 |
}
|
| 361 |
|
| 362 |
if ($write) {
|
| 363 |
if ($io->isWritable($robotsPath)) {
|
| 364 |
+
/**
|
| 365 |
+
* Append sitemap
|
| 366 |
+
*/
|
| 367 |
$io->write($robotsPath, $sitemapUrl, FILE_APPEND | LOCK_EX);
|
| 368 |
} else {
|
| 369 |
//write message that file is not writteble
|
| 378 |
}
|
| 379 |
}
|
| 380 |
|
| 381 |
+
/**
|
| 382 |
+
* Set uuid
|
| 383 |
+
*
|
| 384 |
+
* @param string $uuid
|
| 385 |
+
*
|
| 386 |
+
* @return string
|
| 387 |
+
*/
|
| 388 |
protected function _setUUID($uuid)
|
| 389 |
{
|
| 390 |
$this->_getConfig()->setUUID($uuid);
|
| 391 |
}
|
| 392 |
|
| 393 |
+
/**
|
| 394 |
+
* Returns uuid
|
| 395 |
+
*
|
| 396 |
+
* @return void
|
| 397 |
+
*/
|
| 398 |
public function getIspUuidAction()
|
| 399 |
{
|
| 400 |
$response = $this->getResponse();
|
| 401 |
$response->setBody($this->_getConfig()->getUUID());
|
| 402 |
}
|
| 403 |
|
| 404 |
+
/**
|
| 405 |
+
* Get error message
|
| 406 |
+
*
|
| 407 |
+
* @return void
|
| 408 |
+
*/
|
| 409 |
public function geterrormessageAction()
|
| 410 |
{
|
| 411 |
$response = $this->getResponse();
|
| 414 |
$response->setBody($helper->getErrormessage());
|
| 415 |
}
|
| 416 |
|
| 417 |
+
/**
|
| 418 |
+
* Sets uuid
|
| 419 |
+
*
|
| 420 |
+
* @return void
|
| 421 |
+
*/
|
| 422 |
public function setIspUuidAction()
|
| 423 |
{
|
| 424 |
$helper = Mage::helper('autocompleteplus_autosuggest');
|
| 426 |
$storeId = Mage::app()->getStore()->getStoreId();
|
| 427 |
$site_url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
|
| 428 |
|
| 429 |
+
$url = $url_domain.http_build_query(
|
| 430 |
+
array(
|
| 431 |
+
'store_id' => $storeId,
|
| 432 |
+
'site_url' => $site_url,
|
| 433 |
+
)
|
| 434 |
+
);
|
| 435 |
|
| 436 |
$helper = Mage::helper('autocompleteplus_autosuggest');
|
| 437 |
$resp = $helper->sendCurl($url);
|
| 442 |
}
|
| 443 |
}
|
| 444 |
|
| 445 |
+
/**
|
| 446 |
+
* Checks deletes
|
| 447 |
+
*
|
| 448 |
+
* @return void
|
| 449 |
+
*/
|
| 450 |
public function checkDeletedAction()
|
| 451 |
{
|
| 452 |
$response = $this->getResponse();
|
| 467 |
}
|
| 468 |
|
| 469 |
$sql_fetch = 'SELECT identifier FROM '.$table_prefix.'autocompleteplus_checksum WHERE store_id=?';
|
| 470 |
+
/**
|
| 471 |
+
* Empty array if fails
|
| 472 |
+
*/
|
| 473 |
+
$updates = $read->fetchPairs($sql_fetch, array($store_id));
|
| 474 |
if (empty($updates)) {
|
| 475 |
return;
|
| 476 |
}
|
| 477 |
|
| 478 |
+
/**
|
| 479 |
+
* Array of all checksum table identifiers
|
| 480 |
+
*/
|
| 481 |
+
$checksum_ids = array_keys($updates);
|
| 482 |
$collection = Mage::getResourceModel('catalog/product_collection');
|
| 483 |
$collection->addFieldToFilter('entity_id', array('in' => $checksum_ids));
|
| 484 |
$found_ids = $collection->getAllIds();
|
| 485 |
|
| 486 |
+
/**
|
| 487 |
+
* List of identifiers that are not
|
| 488 |
+
* present in the store (removed at some point)
|
| 489 |
+
*/
|
| 490 |
+
$removed_products_list = array_diff($checksum_ids, $found_ids);
|
| 491 |
$removed_ids = array();
|
| 492 |
|
| 493 |
+
/**
|
| 494 |
+
* Removing non-existing identifiers from checksum table
|
| 495 |
+
*/
|
| 496 |
if (!empty($removed_products_list)) {
|
| 497 |
+
$write = Mage::getSingleton('core/resource')
|
| 498 |
+
->getConnection('core_write');
|
| 499 |
$sql_delete = 'DELETE FROM '.$table_prefix.'autocompleteplus_checksum WHERE identifier IN ('.implode(',', $removed_products_list).')';
|
| 500 |
$write->query($sql_delete);
|
| 501 |
|
| 502 |
foreach ($removed_products_list as $product_id) {
|
| 503 |
+
$helper->deleteProductFromTables(
|
| 504 |
+
$read,
|
| 505 |
+
$write,
|
| 506 |
+
$table_prefix,
|
| 507 |
+
$product_id,
|
| 508 |
+
$store_id
|
| 509 |
+
);
|
| 510 |
$removed_ids[] = $product_id;
|
| 511 |
}
|
| 512 |
}
|
| 522 |
$response->setBody(json_encode($args)); // returning the summary
|
| 523 |
}
|
| 524 |
|
| 525 |
+
/**
|
| 526 |
+
* Returns checksum
|
| 527 |
+
*
|
| 528 |
+
* @return void
|
| 529 |
+
*/
|
| 530 |
public function checksumAction()
|
| 531 |
{
|
| 532 |
$request = $this->getRequest();
|
| 533 |
$response = $this->getResponse();
|
| 534 |
$helper = Mage::helper('autocompleteplus_autosuggest');
|
| 535 |
+
$store_id = $request->getParam(
|
| 536 |
+
'store_id',
|
| 537 |
+
Mage::app()->getStore()->getStoreId()
|
| 538 |
+
);
|
| 539 |
+
$count = $request->getParam(
|
| 540 |
+
'count',
|
| 541 |
+
self::MAX_NUM_OF_PRODUCTS_CHECKSUM_ITERATION
|
| 542 |
+
);
|
| 543 |
$start_index = $request->getParam('offset', 0);
|
| 544 |
$php_timeout = $request->getParam('timeout', -1);
|
| 545 |
$is_single = $request->getParam('is_single', 0);
|
| 549 |
|
| 550 |
if (!$helper->isChecksumTableExists()) {
|
| 551 |
$helper->ispErrorLog('checksum table not exist');
|
| 552 |
+
$response->setBody(
|
| 553 |
+
json_encode(array('status' => 'checksum table not exist'))
|
| 554 |
+
);
|
| 555 |
|
| 556 |
return;
|
| 557 |
}
|
| 558 |
|
| 559 |
$max_exe_time = -1;
|
| 560 |
|
| 561 |
+
if ($count > self::MAX_NUM_OF_PRODUCTS_CHECKSUM_ITERATION
|
| 562 |
+
&& $php_timeout != -1
|
| 563 |
+
) {
|
| 564 |
$max_exe_time = ini_get('max_execution_time');
|
| 565 |
ini_set('max_execution_time', $php_timeout);
|
| 566 |
}
|
| 577 |
$count = $num_of_products - $start_index;
|
| 578 |
}
|
| 579 |
|
| 580 |
+
// sending log to the server
|
| 581 |
$log_msg = 'Update checksum is starting...';
|
| 582 |
+
$log_msg .= (
|
| 583 |
+
' number of products in this store: '.
|
| 584 |
+
$num_of_products.' | from: '.
|
| 585 |
+
$start_index.', to: '.($start_index + $count)
|
| 586 |
+
);
|
| 587 |
+
|
| 588 |
$server_url = $checksum_server.'/magento_logging_record';
|
| 589 |
+
$request = $server_url.'?uuid='.$uuid.
|
| 590 |
+
'&site_url='.$site_url.'&msg='.urlencode($log_msg);
|
| 591 |
+
|
| 592 |
if ($store_id) {
|
| 593 |
$request .= '&store_id='.$store_id;
|
| 594 |
}
|
| 600 |
$iter = $start_index;
|
| 601 |
while ($iter < $count) {
|
| 602 |
// start updating the checksum table if needed
|
| 603 |
+
$num_of_updated_checksum += $helper->compareProductsChecksum(
|
| 604 |
+
$iter,
|
| 605 |
+
self::MAX_NUM_OF_PRODUCTS_CHECKSUM_ITERATION,
|
| 606 |
+
$store_id
|
| 607 |
+
);
|
| 608 |
$iter += self::MAX_NUM_OF_PRODUCTS_CHECKSUM_ITERATION;
|
| 609 |
}
|
| 610 |
} else {
|
| 611 |
// start updating the checksum table if needed
|
| 612 |
+
$num_of_updated_checksum = $helper->compareProductsChecksum(
|
| 613 |
+
$start_index,
|
| 614 |
+
$count,
|
| 615 |
+
$store_id
|
| 616 |
+
);
|
| 617 |
}
|
| 618 |
|
| 619 |
$process_time = time() - $start_time;
|
| 620 |
+
$extVersion = (string) Mage::getConfig()
|
| 621 |
+
->getNode()
|
| 622 |
+
->modules
|
| 623 |
+
->Autocompleteplus_Autosuggest
|
| 624 |
+
->version;
|
| 625 |
+
|
| 626 |
+
/**
|
| 627 |
+
* Sending confirmation/summary to the server
|
| 628 |
+
*/
|
| 629 |
+
|
| 630 |
$args = array(
|
| 631 |
'uuid' => $uuid,
|
| 632 |
'site_url' => $site_url,
|
| 637 |
'start_index' => $start_index,
|
| 638 |
'end_index' => $start_index + $count,
|
| 639 |
'count' => $count,
|
| 640 |
+
'ext_version' => $extVersion,
|
| 641 |
'mage_version' => Mage::getVersion(),
|
| 642 |
'latency' => $process_time,
|
| 643 |
);
|
| 644 |
+
|
| 645 |
if ($is_single) {
|
| 646 |
$args['is_single'] = 1;
|
| 647 |
}
|
| 648 |
|
| 649 |
$response->setBody(json_encode($args));
|
| 650 |
|
| 651 |
+
$resp = $helper->sendCurl(
|
| 652 |
+
$checksum_server.'/magento_checksum_iterator?'.http_build_query($args)
|
| 653 |
+
);
|
| 654 |
|
| 655 |
if ($max_exe_time != -1) { // restore php max execution time
|
| 656 |
ini_set('max_execution_time', $max_exe_time);
|
| 657 |
}
|
| 658 |
}
|
| 659 |
|
| 660 |
+
/**
|
| 661 |
+
* Checks connection
|
| 662 |
+
*
|
| 663 |
+
* @return void
|
| 664 |
+
*/
|
| 665 |
public function connectionAction()
|
| 666 |
{
|
| 667 |
$this->getResponse()->setBody(1);
|
| 668 |
}
|
| 669 |
|
| 670 |
/**
|
| 671 |
+
* Bulk Push to ISP with JSON.
|
| 672 |
+
*
|
| 673 |
* @return void
|
| 674 |
*/
|
| 675 |
public function pushbulkAction()
|
| 676 |
{
|
| 677 |
+
$request = $this->getRequest();
|
|
|
|
| 678 |
$response = $this->getResponse();
|
| 679 |
|
| 680 |
$response->clearHeaders();
|
| 681 |
$response->setHeader('Content-type', 'application/json');
|
| 682 |
+
$pushId = $request->getParam('pushid', null);
|
| 683 |
+
$helper = Mage::helper('autocompleteplus_autosuggest');
|
| 684 |
+
$data = array();
|
| 685 |
|
| 686 |
+
if (!isset($pushId)) {
|
| 687 |
+
$responseArr = array('success' => false, 'message' => 'Missing pushid!');
|
| 688 |
$response->clearHeaders();
|
| 689 |
$response->setHeader('Content-type', 'application/json');
|
| 690 |
$response->setBody(json_encode($responseArr));
|
| 691 |
+
|
| 692 |
return;
|
| 693 |
}
|
| 694 |
|
| 695 |
+
$pusher = Mage::getModel('autocompleteplus_autosuggest/pusher')
|
| 696 |
+
->load($pushId);
|
| 697 |
$sent = $pusher->getSent();
|
| 698 |
|
| 699 |
+
if ($sent == 1) {
|
| 700 |
+
$responseArr = array(
|
| 701 |
+
'success' => false,
|
| 702 |
+
'message' => 'push is in process'
|
| 703 |
+
);
|
| 704 |
$response->setBody(json_encode($responseArr));
|
| 705 |
+
|
| 706 |
return;
|
| 707 |
+
} elseif ($sent == 2) {
|
| 708 |
+
$responseArr = array(
|
| 709 |
+
'success' => false,
|
| 710 |
+
'message' => 'push was already sent'
|
| 711 |
+
);
|
| 712 |
$response->setBody(json_encode($responseArr));
|
| 713 |
+
|
| 714 |
return;
|
| 715 |
} else {
|
| 716 |
$pusher->setSent(1);
|
| 717 |
$pusher->save();
|
| 718 |
}
|
| 719 |
|
| 720 |
+
$offset = $pusher->getoffset();
|
| 721 |
+
$count = 100;
|
| 722 |
+
$storeId = $pusher->getstore_id();
|
| 723 |
+
$to_send = $pusher->getto_send();
|
| 724 |
$total_batches = $pusher->gettotal_batches();
|
| 725 |
+
$catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
|
| 726 |
+
$url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
|
| 727 |
+
$server_url = $helper->getServerUrl();
|
| 728 |
+
$cmd_url = $server_url.'/magento_fetch_products';
|
| 729 |
|
| 730 |
// setting post data and command url
|
| 731 |
+
$data['uuid'] = $helper->getUUID();
|
| 732 |
+
$data['site_url'] = $url;
|
| 733 |
+
$data['store_id'] = $storeId;
|
| 734 |
$data['authentication_key'] = $helper->getKey();
|
| 735 |
+
$data['total_batches'] = $total_batches;
|
| 736 |
+
$data['batch_number'] = $pusher->getbatch_number();
|
| 737 |
+
$data['products'] = $catalogModel
|
| 738 |
+
->renderCatalogXml($offset, $count, $storeId, '', '', '');
|
| 739 |
|
| 740 |
+
if ($offset + $count > $to_send) {
|
| 741 |
$data['is_last'] = 1;
|
| 742 |
+
$count = $to_send - $offset;
|
| 743 |
}
|
| 744 |
|
| 745 |
// sending products
|
| 746 |
$res2 = $helper->sendPostCurl($cmd_url, $data);
|
| 747 |
unset($data['products']);
|
| 748 |
|
| 749 |
+
if ($res2 !== 'ok') {
|
| 750 |
+
$responseArr = array('success' => false, 'message' => $res2);
|
| 751 |
$response->setBody($responseArr);
|
| 752 |
+
|
| 753 |
return;
|
| 754 |
}
|
| 755 |
|
|
|
|
| 756 |
$pusher->setSent(2);
|
| 757 |
$pusher->save();
|
| 758 |
|
| 759 |
+
$nextPushId = $helper->getPushId();
|
| 760 |
$nextPushUrl = '';
|
| 761 |
|
| 762 |
+
if ($nextPushId != '') {
|
| 763 |
+
$nextPushUrl = $helper->getPushUrl($nextPushId);
|
| 764 |
}
|
| 765 |
|
| 766 |
+
$totalPushes = Mage::getModel('autocompleteplus_autosuggest/pusher')
|
| 767 |
+
->getCollection()
|
| 768 |
+
->getSize();
|
| 769 |
|
| 770 |
+
$updatedStatus = 'Syncing: push '.$nextPushId.'/'.$totalPushes;
|
| 771 |
+
$updatedSuccessStatus = 'Successfully synced '.$count.' products';
|
| 772 |
|
| 773 |
$responseArr = array(
|
| 774 |
+
'success' => true,
|
| 775 |
+
'updatedStatus' => $updatedStatus,
|
| 776 |
'updatedSuccessStatus' => $updatedSuccessStatus,
|
| 777 |
+
'message' => '',
|
| 778 |
+
'nextPushUrl' => $nextPushUrl,
|
| 779 |
+
'count' => $count,
|
| 780 |
);
|
| 781 |
|
| 782 |
$response->setBody(json_encode($responseArr));
|
|
|
|
| 783 |
}
|
| 784 |
}
|
app/code/local/Autocompleteplus/Autosuggest/controllers/ProductsbyidController.php
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
*
|
| 4 |
*
|
| 5 |
* NOTICE OF LICENSE
|
| 6 |
*
|
|
@@ -8,13 +8,43 @@
|
|
| 8 |
* that is available through the world-wide-web at this URL:
|
| 9 |
* http://opensource.org/licenses/osl-3.0.php
|
| 10 |
*
|
| 11 |
-
*
|
| 12 |
*
|
| 13 |
-
* @
|
| 14 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
*/
|
| 16 |
class Autocompleteplus_Autosuggest_ProductsbyidController extends Autocompleteplus_Autosuggest_Controller_Abstract
|
| 17 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
public function getbyidAction()
|
| 19 |
{
|
| 20 |
$request = $this->getRequest();
|
|
@@ -40,12 +70,17 @@ class Autocompleteplus_Autosuggest_ProductsbyidController extends Autocompletepl
|
|
| 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();
|
|
@@ -58,7 +93,7 @@ class Autocompleteplus_Autosuggest_ProductsbyidController extends Autocompletepl
|
|
| 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);
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* ProductsbyidController File
|
| 4 |
*
|
| 5 |
* NOTICE OF LICENSE
|
| 6 |
*
|
| 8 |
* that is available through the world-wide-web at this URL:
|
| 9 |
* http://opensource.org/licenses/osl-3.0.php
|
| 10 |
*
|
| 11 |
+
* PHP version 5
|
| 12 |
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Autocompleteplus_Autosuggest_ProductsbyidController
|
| 24 |
+
*
|
| 25 |
+
* NOTICE OF LICENSE
|
| 26 |
+
*
|
| 27 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 28 |
+
* that is available through the world-wide-web at this URL:
|
| 29 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 30 |
+
*
|
| 31 |
+
* PHP version 5
|
| 32 |
+
*
|
| 33 |
+
* @category Mage
|
| 34 |
+
*
|
| 35 |
+
* @package Instantsearchplus
|
| 36 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 37 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 38 |
+
* @license Open Software License (OSL 3.0)*
|
| 39 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 40 |
*/
|
| 41 |
class Autocompleteplus_Autosuggest_ProductsbyidController extends Autocompleteplus_Autosuggest_Controller_Abstract
|
| 42 |
{
|
| 43 |
+
/**
|
| 44 |
+
* GetbyidAction
|
| 45 |
+
*
|
| 46 |
+
* @return void
|
| 47 |
+
*/
|
| 48 |
public function getbyidAction()
|
| 49 |
{
|
| 50 |
$request = $this->getRequest();
|
| 70 |
$ids = explode(',', $id);
|
| 71 |
$catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
|
| 72 |
$xml = $catalogModel->renderCatalogByIds($ids, $storeId);
|
| 73 |
+
|
| 74 |
$response->clearHeaders();
|
| 75 |
$response->setHeader('Content-type', 'text/xml');
|
| 76 |
$response->setBody($xml);
|
| 77 |
}
|
| 78 |
|
| 79 |
+
/**
|
| 80 |
+
* GetfromidAction
|
| 81 |
+
*
|
| 82 |
+
* @return void
|
| 83 |
+
*/
|
| 84 |
public function getfromidAction()
|
| 85 |
{
|
| 86 |
$request = $this->getRequest();
|
| 93 |
|
| 94 |
$catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
|
| 95 |
$xml = $catalogModel->renderCatalogFromIds($count, $fromId, $storeId);
|
| 96 |
+
|
| 97 |
$response->clearHeaders();
|
| 98 |
$response->setHeader('Content-type', 'text/xml');
|
| 99 |
$response->setBody($xml);
|
app/code/local/Autocompleteplus/Autosuggest/controllers/SearchesController.php
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
*
|
| 4 |
*
|
| 5 |
* NOTICE OF LICENSE
|
| 6 |
*
|
|
@@ -8,17 +8,45 @@
|
|
| 8 |
* that is available through the world-wide-web at this URL:
|
| 9 |
* http://opensource.org/licenses/osl-3.0.php
|
| 10 |
*
|
| 11 |
-
*
|
| 12 |
*
|
| 13 |
-
* @
|
| 14 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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();
|
|
@@ -36,15 +64,22 @@ class Autocompleteplus_Autosuggest_SearchesController extends Mage_Core_Controll
|
|
| 36 |
}
|
| 37 |
//retrieving page number
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
$searchesCount = $collection->
|
| 43 |
|
| 44 |
-
|
|
|
|
|
|
|
| 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>';
|
|
@@ -59,18 +94,13 @@ class Autocompleteplus_Autosuggest_SearchesController extends Mage_Core_Controll
|
|
| 59 |
return;
|
| 60 |
}
|
| 61 |
|
| 62 |
-
$
|
| 63 |
-
|
| 64 |
-
|
| 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="'
|
|
|
|
| 74 |
$xml .= $row;
|
| 75 |
}
|
| 76 |
|
|
@@ -81,7 +111,14 @@ class Autocompleteplus_Autosuggest_SearchesController extends Mage_Core_Controll
|
|
| 81 |
$response->setBody($xml);
|
| 82 |
}
|
| 83 |
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
{
|
| 86 |
$arr = array(
|
| 87 |
'&' => '&',
|
|
@@ -97,11 +134,25 @@ class Autocompleteplus_Autosuggest_SearchesController extends Mage_Core_Controll
|
|
| 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);
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* SearchesController File
|
| 4 |
*
|
| 5 |
* NOTICE OF LICENSE
|
| 6 |
*
|
| 8 |
* that is available through the world-wide-web at this URL:
|
| 9 |
* http://opensource.org/licenses/osl-3.0.php
|
| 10 |
*
|
| 11 |
+
* PHP version 5
|
| 12 |
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Autocompleteplus_Autosuggest_SearchesController
|
| 24 |
+
*
|
| 25 |
+
* NOTICE OF LICENSE
|
| 26 |
+
*
|
| 27 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 28 |
+
* that is available through the world-wide-web at this URL:
|
| 29 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 30 |
+
*
|
| 31 |
+
* PHP version 5
|
| 32 |
+
*
|
| 33 |
+
* @category Mage
|
| 34 |
+
*
|
| 35 |
+
* @package Instantsearchplus
|
| 36 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 37 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 38 |
+
* @license Open Software License (OSL 3.0)*
|
| 39 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 40 |
*/
|
| 41 |
class Autocompleteplus_Autosuggest_SearchesController extends Mage_Core_Controller_Front_Action
|
| 42 |
{
|
| 43 |
+
/**
|
| 44 |
+
* Sends searches of the magento at extension install
|
| 45 |
+
*
|
| 46 |
+
* @return void
|
| 47 |
+
*/
|
| 48 |
public function sendAction()
|
| 49 |
{
|
|
|
|
|
|
|
| 50 |
$post = $this->getRequest()->getParams();
|
| 51 |
|
| 52 |
$response = $this->getResponse();
|
| 64 |
}
|
| 65 |
//retrieving page number
|
| 66 |
|
| 67 |
+
/**
|
| 68 |
+
* Retrieving products collection to check
|
| 69 |
+
* if the offset is not bigger that the product count
|
| 70 |
+
*/
|
| 71 |
+
$collection = Mage::getModel('catalogsearch/query')->getCollection()
|
| 72 |
+
->setOrder('popularity', 'DESC');
|
| 73 |
+
|
| 74 |
+
$collection->getSelect()->limit($count, $startInd);
|
| 75 |
|
| 76 |
+
$searchesCount = $collection->getSize();
|
| 77 |
|
| 78 |
+
/**
|
| 79 |
+
* Since the retreiving of product count
|
| 80 |
+
* will load the entire collection of products,
|
| 81 |
* we need to annul it in order to get the specified page only
|
| 82 |
*/
|
|
|
|
| 83 |
|
| 84 |
$xml = '<?xml version="1.0"?>';
|
| 85 |
$xml .= '<searches>';
|
| 94 |
return;
|
| 95 |
}
|
| 96 |
|
| 97 |
+
foreach ($collection as $search) {
|
| 98 |
+
$search_term = htmlspecialchars($search->getData('query_text'));
|
| 99 |
+
$search_term = $this->xmlEscape($search_term);
|
| 100 |
+
$popularity = $search->getData('popularity');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
+
$row = '<search term="'.
|
| 103 |
+
$search_term.'" count="'.$popularity.'" ></search>';
|
| 104 |
$xml .= $row;
|
| 105 |
}
|
| 106 |
|
| 111 |
$response->setBody($xml);
|
| 112 |
}
|
| 113 |
|
| 114 |
+
/**
|
| 115 |
+
* Clear xml special chars
|
| 116 |
+
*
|
| 117 |
+
* @param mixed $term
|
| 118 |
+
*
|
| 119 |
+
* @return mixed
|
| 120 |
+
*/
|
| 121 |
+
protected function xmlEscape($term)
|
| 122 |
{
|
| 123 |
$arr = array(
|
| 124 |
'&' => '&',
|
| 134 |
return $term;
|
| 135 |
}
|
| 136 |
|
| 137 |
+
/**
|
| 138 |
+
* Get db connection object
|
| 139 |
+
*
|
| 140 |
+
* @param string $type
|
| 141 |
+
*
|
| 142 |
+
* @return mixed
|
| 143 |
+
*/
|
| 144 |
protected function _getConnection($type = 'core_read')
|
| 145 |
{
|
| 146 |
return Mage::getSingleton('core/resource')->getConnection($type);
|
| 147 |
}
|
| 148 |
|
| 149 |
+
/**
|
| 150 |
+
* Get table name
|
| 151 |
+
*
|
| 152 |
+
* @param string $tableName
|
| 153 |
+
*
|
| 154 |
+
* @return mixed
|
| 155 |
+
*/
|
| 156 |
protected function _getTableName($tableName)
|
| 157 |
{
|
| 158 |
return Mage::getSingleton('core/resource')->getTableName($tableName);
|
app/code/local/Autocompleteplus/Autosuggest/data/autosuggest_setup/data-install-3.0.0.5.php
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
$batchCollection = Mage::getModel('autocompleteplus_autosuggest/batches')
|
|
|
|
| 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')
|
| 4 |
+
->getCollection();
|
| 5 |
|
| 6 |
foreach ($batchCollection as $batch) {
|
| 7 |
$currentTime = $batch->getUpdateDate();
|
| 8 |
$batch->setUpdateDate($currentTime)->save();
|
| 9 |
+
}
|
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/config.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 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>
|
|
@@ -147,6 +147,13 @@
|
|
| 147 |
</item>
|
| 148 |
</quote>
|
| 149 |
</sales>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
</global>
|
| 151 |
<frontend>
|
| 152 |
<layout>
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<Autocompleteplus_Autosuggest>
|
| 5 |
+
<version>3.0.0.12</version>
|
| 6 |
<url>http://autocompleteplus.com/</url>
|
| 7 |
<modulename>Autocompleteplus_Autosuggest</modulename>
|
| 8 |
</Autocompleteplus_Autosuggest>
|
| 147 |
</item>
|
| 148 |
</quote>
|
| 149 |
</sales>
|
| 150 |
+
<rewrite>
|
| 151 |
+
<fancy_url>
|
| 152 |
+
<from><![CDATA[/instantsearchplus\/result\/(.*)/]]></from>
|
| 153 |
+
<to><![CDATA[/instantsearchplus/result/index/q/$1/]]></to>
|
| 154 |
+
<complete>1</complete>
|
| 155 |
+
</fancy_url>
|
| 156 |
+
</rewrite>
|
| 157 |
</global>
|
| 158 |
<frontend>
|
| 159 |
<layout>
|
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-install-2.0.1.1.php
CHANGED
|
@@ -15,7 +15,7 @@
|
|
| 15 |
*/
|
| 16 |
$helper = Mage::helper('autocompleteplus_autosuggest');
|
| 17 |
|
| 18 |
-
Mage::log(__FILE__
|
| 19 |
|
| 20 |
//getting site owner email
|
| 21 |
$storeMail = $helper->getConfigDataByFullPath('trans_email/ident_general/email');
|
| 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');
|
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.1.3-2.0.2.2.php
CHANGED
|
@@ -28,5 +28,5 @@ CREATE TABLE IF NOT EXISTS {$this->getTable('autocompleteplus_batches')} (
|
|
| 28 |
PRIMARY KEY (`id`)
|
| 29 |
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
|
| 30 |
|
| 31 |
-
Mage::log(__FILE__
|
| 32 |
$installer->endSetup();
|
| 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
|
@@ -33,5 +33,5 @@ CREATE TABLE IF NOT EXISTS `{$installer->getTable('autocompleteplus_autosuggest/
|
|
| 33 |
KEY `IDX_IS_ACTIVE` (`is_active`)
|
| 34 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 35 |
");
|
| 36 |
-
Mage::log(__FILE__
|
| 37 |
$installer->endSetup();
|
| 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
|
@@ -37,5 +37,5 @@ CREATE TABLE IF NOT EXISTS {$this->getTable('autocompleteplus_checksum')} (
|
|
| 37 |
|
| 38 |
");
|
| 39 |
|
| 40 |
-
Mage::log(__FILE__
|
| 41 |
$installer->endSetup();
|
| 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,5 +1,23 @@
|
|
| 1 |
<?php
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
$installer = $this;
|
| 4 |
|
| 5 |
$installer->startSetup();
|
|
@@ -7,12 +25,18 @@ $fileIo = new Varien_Io_File();
|
|
| 7 |
$baseDir = Mage::getBaseDir();
|
| 8 |
$fileIo->open(array('path' => $baseDir));
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
CREATE TABLE IF NOT EXISTS {$this->getTable('autocompleteplus_pusher')} (
|
| 18 |
|
|
@@ -32,70 +56,77 @@ if (!method_exists('Mage', 'getEdition') && file_exists($baseDir . DS . 'LICENSE
|
|
| 32 |
|
| 33 |
PRIMARY KEY (`id`)
|
| 34 |
|
| 35 |
-
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
| 36 |
-
|
| 37 |
-
");
|
| 38 |
} else {
|
| 39 |
-
$table = $installer->getConnection()
|
| 40 |
-
->
|
| 41 |
-
|
| 42 |
-
'
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
'
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
'unsigned' => true,
|
| 63 |
-
|
| 64 |
-
)
|
| 65 |
-
->addColumn(
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
'
|
| 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 |
-
}
|
| 99 |
if ($installer->tableExists($table->getName())) {
|
| 100 |
$installer->run("DROP TABLE IF EXISTS {$table->getName()};");
|
| 101 |
}
|
|
@@ -103,5 +134,5 @@ if (!method_exists('Mage', 'getEdition') && file_exists($baseDir . DS . 'LICENSE
|
|
| 103 |
|
| 104 |
$installer->getConnection()->createTable($table);
|
| 105 |
}
|
| 106 |
-
Mage::log(__FILE__
|
| 107 |
$installer->endSetup();
|
| 1 |
<?php
|
| 2 |
+
/**
|
| 3 |
+
* File mysql4-upgrade-2.0.5.4-2.0.5.5
|
| 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 |
+
* PHP version 5
|
| 12 |
+
*
|
| 13 |
+
* @category Mage
|
| 14 |
+
*
|
| 15 |
+
* @package Instantsearchplus
|
| 16 |
+
* @author Fast Simon <info@instantsearchplus.com>
|
| 17 |
+
* @copyright 2014 Fast Simon (http://www.instantsearchplus.com)
|
| 18 |
+
* @license Open Software License (OSL 3.0)*
|
| 19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
| 20 |
+
*/
|
| 21 |
$installer = $this;
|
| 22 |
|
| 23 |
$installer->startSetup();
|
| 25 |
$baseDir = Mage::getBaseDir();
|
| 26 |
$fileIo->open(array('path' => $baseDir));
|
| 27 |
|
| 28 |
+
/**
|
| 29 |
+
* GetEdition exist from version 1.12,
|
| 30 |
+
* LICENSE_EE.txt file only exists in EE edition,
|
| 31 |
+
* we need the condition to work on EE version less then 1.11.x.x
|
| 32 |
+
*/
|
| 33 |
+
if (!method_exists('Mage', 'getEdition')
|
| 34 |
+
&& file_exists($baseDir.DS.'LICENSE_EE.txt')
|
| 35 |
+
&& method_exists('Mage', 'getVersion')
|
| 36 |
+
&& version_compare(Mage::getVersion(), '1.10.0.0.', '<') === true
|
| 37 |
+
) {
|
| 38 |
+
$res = $installer->run(
|
| 39 |
+
"DROP TABLE IF EXISTS {$this->getTable('autocompleteplus_pusher')};
|
| 40 |
|
| 41 |
CREATE TABLE IF NOT EXISTS {$this->getTable('autocompleteplus_pusher')} (
|
| 42 |
|
| 56 |
|
| 57 |
PRIMARY KEY (`id`)
|
| 58 |
|
| 59 |
+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;"
|
| 60 |
+
);
|
|
|
|
| 61 |
} else {
|
| 62 |
+
$table = $installer->getConnection()
|
| 63 |
+
->newTable($installer->getTable('autocompleteplus_autosuggest/pusher'))
|
| 64 |
+
->addColumn(
|
| 65 |
+
'id',
|
| 66 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
| 67 |
+
null,
|
| 68 |
+
array('identity' => true,
|
| 69 |
+
'unsigned' => true,
|
| 70 |
+
'nullable' => false,
|
| 71 |
+
'primary' => true,
|
| 72 |
+
),
|
| 73 |
+
'Id'
|
| 74 |
+
)
|
| 75 |
+
->addColumn(
|
| 76 |
+
'store_id',
|
| 77 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
| 78 |
+
null,
|
| 79 |
+
array('nullable' => false,
|
| 80 |
+
'unsigned' => true,
|
| 81 |
+
)
|
| 82 |
+
)
|
| 83 |
+
->addColumn(
|
| 84 |
+
'to_send',
|
| 85 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
| 86 |
+
null,
|
| 87 |
+
array('nullable' => false,
|
| 88 |
+
'unsigned' => true,
|
| 89 |
+
),
|
| 90 |
+
'Amount left to send'
|
| 91 |
+
)
|
| 92 |
+
->addColumn(
|
| 93 |
+
'offset',
|
| 94 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
| 95 |
+
null,
|
| 96 |
+
array('nullable' => false,
|
| 97 |
+
'unsigned' => true,
|
| 98 |
+
)
|
| 99 |
+
)
|
| 100 |
+
->addColumn(
|
| 101 |
+
'total_batches',
|
| 102 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
| 103 |
+
null,
|
| 104 |
+
array('nullable' => false,
|
| 105 |
+
'unsigned' => true,
|
| 106 |
+
)
|
| 107 |
+
)
|
| 108 |
+
->addColumn(
|
| 109 |
+
'batch_number',
|
| 110 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
| 111 |
+
null,
|
| 112 |
+
array('nullable' => false,
|
| 113 |
'unsigned' => true,
|
| 114 |
+
)
|
| 115 |
+
)
|
| 116 |
+
->addColumn(
|
| 117 |
+
'sent',
|
| 118 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
| 119 |
+
null,
|
| 120 |
+
array('nullable' => false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
'unsigned' => true,
|
| 122 |
+
)
|
| 123 |
+
);
|
| 124 |
|
| 125 |
if (method_exists($installer->getConnection(), 'isTableExists')) {
|
| 126 |
if ($installer->getConnection()->isTableExists($table->getName())) {
|
| 127 |
$installer->getConnection()->dropTable($table->getName());
|
| 128 |
}
|
| 129 |
+
} elseif (method_exists($installer, 'tableExists')) {
|
| 130 |
if ($installer->tableExists($table->getName())) {
|
| 131 |
$installer->run("DROP TABLE IF EXISTS {$table->getName()};");
|
| 132 |
}
|
| 134 |
|
| 135 |
$installer->getConnection()->createTable($table);
|
| 136 |
}
|
| 137 |
+
Mage::log(__FILE__.' triggered', null, 'autocomplete.log', true);
|
| 138 |
$installer->endSetup();
|
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.7.0-2.0.7.1.php
CHANGED
|
@@ -4,5 +4,5 @@ $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__
|
| 8 |
$installer->endSetup();
|
| 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
|
@@ -16,7 +16,7 @@ $fileIo->open(array('path' => $baseDir));
|
|
| 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
|
| 20 |
$tableExists = $installer->getConnection()->showTableStatus($tableName);
|
| 21 |
} else {
|
| 22 |
if (method_exists($installer->getConnection(), 'isTableExists')) {
|
|
@@ -101,5 +101,5 @@ if ($tableExists) {
|
|
| 101 |
$res = $helper->sendPostCurl($command, $data);
|
| 102 |
}
|
| 103 |
|
| 104 |
-
Mage::log(__FILE__
|
| 105 |
}
|
| 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')) {
|
| 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
|
@@ -33,5 +33,5 @@ if ($row && isset($row[0]['licensekey']) && isset($row[0]['authkey'])) {
|
|
| 33 |
|
| 34 |
Mage::app()->getCacheInstance()->cleanType('config');
|
| 35 |
|
| 36 |
-
Mage::log(__FILE__
|
| 37 |
$installer->endSetup();
|
| 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.3-3.0.0.4.php
CHANGED
|
@@ -8,11 +8,11 @@ Mage::app()->getStore()->resetConfig();
|
|
| 8 |
|
| 9 |
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
| 10 |
|
| 11 |
-
if (
|
| 12 |
$config->generateConfig();
|
| 13 |
}
|
| 14 |
|
| 15 |
Mage::app()->getCacheInstance()->cleanType('config');
|
| 16 |
|
| 17 |
-
Mage::log(__FILE__
|
| 18 |
-
$installer->endSetup();
|
| 8 |
|
| 9 |
$config = Mage::getModel('autocompleteplus_autosuggest/config');
|
| 10 |
|
| 11 |
+
if (!$config->isConfigDataValid()) {
|
| 12 |
$config->generateConfig();
|
| 13 |
}
|
| 14 |
|
| 15 |
Mage::app()->getCacheInstance()->cleanType('config');
|
| 16 |
|
| 17 |
+
Mage::log(__FILE__.' triggered', null, 'autocomplete.log', true);
|
| 18 |
+
$installer->endSetup();
|
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-3.0.0.4-3.0.0.5.php
CHANGED
|
@@ -3,4 +3,4 @@
|
|
| 3 |
$installer = $this;
|
| 4 |
$installer->startSetup();
|
| 5 |
|
| 6 |
-
$installer->endSetup();
|
| 3 |
$installer = $this;
|
| 4 |
$installer->startSetup();
|
| 5 |
|
| 6 |
+
$installer->endSetup();
|
app/design/frontend/base/default/template/autocompleteplus/catalog/product/list.phtml
CHANGED
|
@@ -6,43 +6,51 @@ $query = htmlentities(Mage::app()->getRequest()->getParam('q'), ENT_QUOTES);
|
|
| 6 |
$match_value = '';
|
| 7 |
|
| 8 |
try{
|
| 9 |
-
$formkey_html = $this->getBlockHtml('formkey');
|
| 10 |
$pattern = '/.*form_key.*value=\"([^\"]+)\"/s';
|
| 11 |
-
if (preg_match($pattern, $formkey_html, $match)){
|
| 12 |
-
if ($match){
|
| 13 |
-
|
| 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 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
</script>
|
| 31 |
<?php
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
$
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
-
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 6 |
$match_value = '';
|
| 7 |
|
| 8 |
try{
|
| 9 |
+
$formkey_html = $this->getBlockHtml('formkey');
|
| 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 .
|
| 39 |
+
'/ma_load_search_page?isp_platform=magento&r=002&uuid=' .
|
| 40 |
+
$config->getUUID() . '&store_id=' . $store_id;
|
| 41 |
+
$resp = $helper->sendCurl($url);
|
| 42 |
+
$response_json = json_decode($resp);
|
| 43 |
+
$html = $response_json->html;
|
| 44 |
+
|
| 45 |
+
Mage::app()->getCacheInstance()
|
| 46 |
+
->save(
|
| 47 |
+
$html,
|
| 48 |
+
'autocomplete_template_serp',
|
| 49 |
+
array("autocomplete_cache"),
|
| 50 |
+
60
|
| 51 |
+
);
|
| 52 |
|
| 53 |
+
}
|
| 54 |
|
| 55 |
+
echo $html;
|
| 56 |
+
?>
|
package.xml
CHANGED
|
@@ -1,19 +1,20 @@
|
|
| 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 |
<authors><author><name>Adar</name><user>Adar</user><email>magento@autocompleteplus.com</email></author></authors>
|
| 14 |
-
<date>2016-10-
|
| 15 |
-
<time>
|
| 16 |
-
<contents><target name="magelocal"><dir name="Autocompleteplus"><dir name="Autosuggest"><dir name="Adminhtml"><dir name="Model"><file name="Attributes.php" hash="
|
| 17 |
<compatible/>
|
| 18 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 19 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>autocompleteplus_autosuggest</name>
|
| 4 |
+
<version>3.0.0.12</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>* purchase popularity fix;
|
| 12 |
+
* fancy url for instantsearchplus;
|
| 13 |
+
* additional params for vers request.</notes>
|
| 14 |
<authors><author><name>Adar</name><user>Adar</user><email>magento@autocompleteplus.com</email></author></authors>
|
| 15 |
+
<date>2016-10-27</date>
|
| 16 |
+
<time>14:48:47</time>
|
| 17 |
+
<contents><target name="magelocal"><dir name="Autocompleteplus"><dir name="Autosuggest"><dir name="Adminhtml"><dir name="Model"><file name="Attributes.php" hash="49fe7441c35332852c853b44894a2db5"/><file name="Button.php" hash="c430dd9ddae72c6b70b4a78c7eaf43a4"/></dir></dir><dir name="Block"><dir name="Adminhtml"><file name="Button.php" hash="bf595c3fb6fc73689b1050870889f4e6"/><file name="Process.php" hash="ae35ea7c927d9dd5f2ecd6d22a616248"/><file name="Sync.php" hash="326fb5f81fcee4f0c090dc8333b45dba"/></dir><file name="Autocomplete.php" hash="9e491587ca76c2e01aa09c4163e3ebd6"/><file name="Autocorrection.php" hash="554976c4a2cc284b328aa273af816943"/><file name="Inject.php" hash="59290f5699de591fb27e7bdf8884dba3"/><file name="Notifications.php" hash="29e412619a1562672d7230b767f85404"/></dir><dir name="Controller"><file name="Abstract.php" hash="5ef554246df910c77f5ed217d97707d4"/></dir><dir name="Helper"><file name="Data.php" hash="83e0631380da2b153d493996f037dc8b"/></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="cd803922ca8f4cde56191a4ecad73c22"/><file name="Catalogreport.php" hash="a3587900c62e9a7103153905add264a3"/><file name="Checksum.php" hash="574e3fa7632d99d664f85bf330a00a2a"/><file name="Config.php" hash="d2e5d53c89d20c10812bd25cd67aac00"/><file name="Layer.php" hash="b9071f27d04ae4dfeac1beb6c4d0a677"/><dir name="Mysql4"><dir name="Batches"><file name="Collection.php" hash="86edbdecb8cdca6cc7a19c6e1624d993"/></dir><file name="Batches.php" hash="3e3ef8be56d7252cff42c40be7a5b372"/><dir name="Checksum"><file name="Collection.php" hash="8bfc716a071b67b4f1d9534744428190"/></dir><file name="Checksum.php" hash="fc893ee654c1e60daecace7ca34e58b1"/><dir name="Fulltext"><file name="Collection.php" hash="0886aa3111137c8bffdcb849b5986061"/></dir><dir name="Notifications"><file name="Collection.php" hash="c385dd061d7f425be4ddb760d515c1b3"/></dir><file name="Notifications.php" hash="ee2a70e340b096ac41fed17ee75c7d44"/><dir name="Pusher"><file name="Collection.php" hash="12bb14c7cdb97ceacd78899ee014e0da"/></dir><file name="Pusher.php" hash="44db865564a0a6d2c6646bfe1ba4cf7a"/></dir><file name="Notifications.php" hash="b06b24bfcadf86781316db136cb0beba"/><file name="Observer.php" hash="596fb69d7874222f9aee81fe3eef3255"/><file name="Pusher.php" hash="958e6fcede116b927734c7f26175d3fe"/><dir name="Renderer"><file name="Abstract.php" hash="a70cad3d0e362a457e3410442e97afba"/><file name="Batches.php" hash="cc3c073de3b3a56d488833e02997a4f8"/><dir name="Catalog"><file name="Product.php" hash="95936c0b271350e432256168fd130a50"/></dir></dir><dir name="Resource"><dir name="Batches"><file name="Collection.php" hash="7957ecce6ba2195209151082119cc7a6"/></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="b4a8654bc187c0bbfea44bcde42c9333"/></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="02aaed296432fe1927c534a3a31a8a1d"/></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="c05776f8296c06a7ee3e3162cc66e884"/><file name="LayeredController.php" hash="bc188069af7cfb3fe0078dfca075e313"/><file name="ProductsController.php" hash="2f7c5a4ea4c568e18a63ba650326b3b0"/><file name="ProductsbyidController.php" hash="15a856a778b694d7b2e14389ebe24d64"/><file name="ResultController.php" hash="dc7e2f0d3364fa421e9a5c672ade14d7"/><file name="SearchesController.php" hash="a2bf7e235e006488b71bb963c50203ea"/></dir><dir name="data"><dir name="autosuggest_setup"><file name="data-install-3.0.0.5.php" hash="a3651727777fd93a277ed7e494f371f7"/><file name="data-upgrade-3.0.0.9-3.0.0.10.php" hash="d8cd4e52b16430dc0d60b81d75cf4d94"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="697b17c6d9e377ef754675680cf6e7a8"/><file name="cache.xml" hash="37e44e63ee5608af5f980028437b9329"/><file name="config.xml" hash="c71e327427b524ceb5c4a2e525a48c38"/><file name="system.xml" hash="300a4b648a61473b23cc3e5e7fc0c778"/></dir><dir name="sql"><dir name="autosuggest_setup"><file name="mysql4-install-2.0.1.1.php" hash="e6d94272870c619be1677e8426a052d9"/><file name="mysql4-upgrade-2.0.1.3-2.0.2.2.php" hash="a862dc72fa1b13a21b20495267e02885"/><file name="mysql4-upgrade-2.0.2.5-2.0.2.6.php" hash="a1a38dbd41a39c87aac13c8d1cbdfdb0"/><file name="mysql4-upgrade-2.0.4.6-2.0.4.7.php" hash="b3eb893002512ccf25c71dc7023df27d"/><file name="mysql4-upgrade-2.0.5.4-2.0.5.5.php" hash="27ecf7651c3420930f4b1e68e2f76372"/><file name="mysql4-upgrade-2.0.7.0-2.0.7.1.php" hash="a015b2dcec2273ae60006561712a921c"/><file name="mysql4-upgrade-2.0.7.2-2.0.7.3.php" hash="f65f55adb2fa46869b802dbfe8c2ef67"/><file name="mysql4-upgrade-2.0.8.8-3.0.0.0.php" hash="a01107446bea54c9b3c4d245b71692bc"/><file name="mysql4-upgrade-3.0.0.3-3.0.0.4.php" hash="6fb787b5742332b64da62394e2546edc"/><file name="mysql4-upgrade-3.0.0.4-3.0.0.5.php" hash="8c8f360b5d6a01ffe6fdcb8a2c50812f"/></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="e7c6153481cd496bea8867a28a00dccd"/></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>
|
| 18 |
<compatible/>
|
| 19 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 20 |
</package>
|
