Xrely_Autocomplete - Version 1.0.0

Version Notes

Initial release for basic features

Download this release

Release Info

Developer Jugal
Extension Xrely_Autocomplete
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (33) hide show
  1. app/code/community/Xrely/Autocomplete/Block/Adminhtml/Design.php +26 -0
  2. app/code/community/Xrely/Autocomplete/Block/Adminhtml/Notifications.php +33 -0
  3. app/code/community/Xrely/Autocomplete/Block/Adminhtml/Progress.php +12 -0
  4. app/code/community/Xrely/Autocomplete/Block/Adminhtml/Redirect.php +26 -0
  5. app/code/community/Xrely/Autocomplete/Block/Adminhtml/Syncbtn.php +31 -0
  6. app/code/community/Xrely/Autocomplete/Block/Adminhtml/Thumb.php +30 -0
  7. app/code/community/Xrely/Autocomplete/Block/Adminhtml/Upgrade.php +26 -0
  8. app/code/community/Xrely/Autocomplete/Block/Js.php +17 -0
  9. app/code/community/Xrely/Autocomplete/Block/Sync.php +12 -0
  10. app/code/community/Xrely/Autocomplete/Helper/Data.php +151 -0
  11. app/code/community/Xrely/Autocomplete/Helper/asas.sql +3 -0
  12. app/code/community/Xrely/Autocomplete/Model/Adminhtml/Thumb.php +28 -0
  13. app/code/community/Xrely/Autocomplete/Model/Observer.php +9 -0
  14. app/code/community/Xrely/Autocomplete/Model/Resource/Settings.php +9 -0
  15. app/code/community/Xrely/Autocomplete/Model/Resource/Settings/Collection.php +9 -0
  16. app/code/community/Xrely/Autocomplete/Model/Settings.php +44 -0
  17. app/code/community/Xrely/Autocomplete/controllers/Adminhtml/PublishController.php +185 -0
  18. app/code/community/Xrely/Autocomplete/controllers/Adminhtml/RedirectController.php +24 -0
  19. app/code/community/Xrely/Autocomplete/controllers/ListenController.php +33 -0
  20. app/code/community/Xrely/Autocomplete/data/xrely_autocomplete_setup/data-install-1.0.0.0.php +28 -0
  21. app/code/community/Xrely/Autocomplete/etc/adminhtml.xml +49 -0
  22. app/code/community/Xrely/Autocomplete/etc/config.xml +121 -0
  23. app/code/community/Xrely/Autocomplete/etc/system.xml +68 -0
  24. app/code/community/Xrely/Autocomplete/sql/xrely_autocomplete_setup/install-1.0.0.0.php +34 -0
  25. app/design/adminhtml/default/default/layout/xrely_autocomplete.xml +11 -0
  26. app/design/adminhtml/default/default/template/xrely_autocomplete/notification.phtml +3 -0
  27. app/design/adminhtml/default/default/template/xrely_autocomplete/progress.phtml +114 -0
  28. app/design/frontend/base/default/layout/xrely_autocomplete.xml +22 -0
  29. app/design/frontend/base/default/template/autocomplete/js.phtml +52 -0
  30. app/design/frontend/base/default/template/autocomplete/post_redirect.phtml +1 -0
  31. app/etc/modules/Xrely_Autocomplete.xml +19 -0
  32. js/xrely_autocomplete/admin.js +9 -0
  33. package.xml +18 -0
app/code/community/Xrely/Autocomplete/Block/Adminhtml/Design.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Xrely_Autocomplete_Block_Adminhtml_Design extends Mage_Core_Block_Template{
3
+
4
+
5
+ public function _toHtml()
6
+ {
7
+ $helper = Mage::helper('xrely_autocomplete');
8
+ $action = $helper->getDesignRedirectFormAction();
9
+ $html = "<form method='POST' action='".$action."' ><input name='API_KEY' type='hidden' value='".$helper->getAPIKey()."' /></form>";
10
+ return "<!DOCTYPE html>
11
+ <html>
12
+ <head>
13
+ <title>Signing in to dashboard</title>
14
+ ".$html."
15
+ </head>
16
+ <body>
17
+ <center style='margin-top:10%;font-size:20px;color: #eb5e00;'><b>Signing in to XRelY Dashboard</b></center>
18
+ <script type='text/javascript'>
19
+ setTimeout(function(){document.forms[0].submit();},1000);
20
+ </script>
21
+ </body>
22
+ </html>";
23
+
24
+ }
25
+
26
+ }
app/code/community/Xrely/Autocomplete/Block/Adminhtml/Notifications.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xrely_Autocomplete_Block_Adminhtml_Notifications extends Mage_Adminhtml_Block_Template
4
+ {
5
+
6
+ public function getMessage()
7
+ {
8
+ $message = null;
9
+ if (Mage::getStoreConfig('xrely_autocomplete/config/ini_sync') == 0)
10
+ {
11
+ $publishUrl = Mage::helper('adminhtml')->getUrl('xrely_autocomplete/adminhtml_publish/url');
12
+
13
+ $message = '<a class="label" href="'.$publishUrl.'" target="_blank"><strong class="label">XRelY Sync</strong></a> : Initial Syncronization is not done yet and it is necessary to start using XrelY\'s Autocomplete. <a href="'.$publishUrl.'">Let\'s do it</a>';
14
+ }
15
+ else
16
+ {
17
+ $datetime1 = new DateTime(date('Y-m-d H:i:s', Mage::getStoreConfig('xrely_autocomplete/config/time')));
18
+ $datetime2 = new DateTime(date('Y-m-d H:i:s'));
19
+ $oDiff = $datetime1->diff($datetime2);
20
+ if ($oDiff->m >= 2)
21
+ {
22
+ $upgradeUrl = Mage::helper("adminhtml")->getUrl("xrely_autocomplete/adminhtml_redirect/upgrade");
23
+ $message = '<a class="label" href="'.$upgradeUrl.'" target="_blank"><strong class="label">XRelY Upgrade</strong></a> : Free trial period is over, please <a href="'.$upgradeUrl.'">click</a> to Upgrade';
24
+ } else if(Mage::getStoreConfig('xrely_autocomplete/config/notify') == 1)
25
+ {
26
+ $data = json_decode(Mage::getStoreConfig('xrely_autocomplete/config/notify_msg'),true);
27
+ $message = '<a class="label" href="'.$data['url'].'" target="_blank"><strong class="label">XRelY Message</strong></a> : '.$data['text'];
28
+ }
29
+ }
30
+ return $message;
31
+ }
32
+
33
+ }
app/code/community/Xrely/Autocomplete/Block/Adminhtml/Progress.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this license header, choose License Headers in Project Properties.
5
+ * To change this template file, choose Tools | Templates
6
+ * and open the template in the editor.
7
+ */
8
+
9
+ class Xrely_Autocomplete_Block_Adminhtml_Progress extends Mage_Core_Block_Template{
10
+
11
+
12
+ }
app/code/community/Xrely/Autocomplete/Block/Adminhtml/Redirect.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Xrely_Autocomplete_Block_Adminhtml_Redirect extends Mage_Core_Block_Template{
3
+
4
+
5
+ public function _toHtml()
6
+ {
7
+ $helper = Mage::helper('xrely_autocomplete');
8
+ $action = $helper->getRedirectFormAction();
9
+ $html = "<form method='POST' action='".$action."' ><input name='API_KEY' type='hidden' value='".$helper->getAPIKey()."' /></form>";
10
+ return "<!DOCTYPE html>
11
+ <html>
12
+ <head>
13
+ <title>Signing in to dashboard</title>
14
+ ".$html."
15
+ </head>
16
+ <body>
17
+ <center style='margin-top:10%;font-size:20px;color: #eb5e00;'><b>Signing in to XRelY Dashboard</b></center>
18
+ <script type='text/javascript'>
19
+ setTimeout(function(){document.forms[0].submit();},1000);
20
+ </script>
21
+ </body>
22
+ </html>";
23
+
24
+ }
25
+
26
+ }
app/code/community/Xrely/Autocomplete/Block/Adminhtml/Syncbtn.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this license header, choose License Headers in Project Properties.
5
+ * To change this template file, choose Tools | Templates
6
+ * and open the template in the editor.
7
+ */
8
+
9
+ class Xrely_Autocomplete_Block_Adminhtml_Syncbtn extends Mage_Adminhtml_Block_System_Config_Form_Field
10
+ {
11
+
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
13
+ {
14
+ $this->setElement($element);
15
+ $url = Mage::helper('adminhtml')->getUrl('xrely_autocomplete/adminhtml_publish/url');
16
+ $html = $this->getLayout()->createBlock('adminhtml/widget_button')
17
+ ->setType('button')
18
+ ->setClass('scalable')
19
+ ->setLabel('Scan & Sync')
20
+ ->setOnClick("window.open('$url')")
21
+ ->toHtml();
22
+
23
+ return $html;
24
+ }
25
+
26
+ protected function getSnycUrl()
27
+ {
28
+
29
+ }
30
+
31
+ }
app/code/community/Xrely/Autocomplete/Block/Adminhtml/Thumb.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this license header, choose License Headers in Project Properties.
5
+ * To change this template file, choose Tools | Templates
6
+ * and open the template in the editor.
7
+ */
8
+ class Xrely_Autocomplete_Block_Adminhtml_Thumb extends Mage_Adminhtml_Block_System_Config_Form_Field
9
+ {
10
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
11
+ {
12
+ $this->setElement($element);
13
+ $url = Mage::helper('adminhtml')->getUrl('xrely_autocmplete/adminhtml_publish/url');
14
+ //
15
+ $html = $this->getLayout()->createBlock('adminhtml/widget_button')
16
+ ->setType('button')
17
+ ->setClass('scalable')
18
+ ->setLabel('Scan & Sync')
19
+ ->setOnClick("setLocation('$url')")
20
+ ->toHtml();
21
+
22
+ return $html;
23
+ }
24
+
25
+ protected function getSnycUrl()
26
+ {
27
+
28
+ }
29
+ }
30
+
app/code/community/Xrely/Autocomplete/Block/Adminhtml/Upgrade.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Xrely_Autocomplete_Block_Adminhtml_Upgrade extends Mage_Core_Block_Template{
3
+
4
+
5
+ public function _toHtml()
6
+ {
7
+ $helper = Mage::helper('xrely_autocomplete');
8
+ $action = $helper->getUpgradeRedirectFormAction();
9
+ $html = "<form method='POST' action='".$action."' ><input name='API_KEY' type='hidden' value='".$helper->getAPIKey()."' /></form>";
10
+ return "<!DOCTYPE html>
11
+ <html>
12
+ <head>
13
+ <title>Signing in to dashboard</title>
14
+ ".$html."
15
+ </head>
16
+ <body>
17
+ <center style='margin-top:10%;font-size:20px;color: #eb5e00;'><b>Signing in to XRelY Dashboard</b></center>
18
+ <script type='text/javascript'>
19
+ setTimeout(function(){document.forms[0].submit();},1000);
20
+ </script>
21
+ </body>
22
+ </html>";
23
+
24
+ }
25
+
26
+ }
app/code/community/Xrely/Autocomplete/Block/Js.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Xrely_Autocomplete_Block_Js extends Mage_Core_Block_Template
3
+ {
4
+ const XRELY_SCRIPT_BASE = 'autocomplete.xrely.com/';
5
+ const XRELY_FILE_PATH = 'js/autocomplete/autoScript.js';
6
+
7
+ public function getXrelyJsUrl()
8
+ {
9
+ $surl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
10
+ $partUrl = parse_url($surl);
11
+ if($partUrl["host"] == 'localhost')
12
+ {
13
+ $partUrl["host"] = Mage::getStoreConfig('xrely_autocomplete/config/localhost_domain',Mage::app()->getStore());
14
+ }
15
+ return "//".self::XRELY_SCRIPT_BASE.self::XRELY_FILE_PATH."?_=".$partUrl["host"]."&no=\"+((typeof jQuery == \"undefined\")?0:1)+\"&system=magento";
16
+ }
17
+ }
app/code/community/Xrely/Autocomplete/Block/Sync.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ class Xrely_Autocomplete_Block_Sync extends Mage_Core_Block_Template
6
+ {
7
+
8
+ function __construct()
9
+ {
10
+ parent::__construct();
11
+ }
12
+ }
app/code/community/Xrely/Autocomplete/Helper/Data.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xrely_Autocomplete_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ const KEYWORD_DATA_API = "http://localhost/client/WebService/acceptPostKeyword";
7
+ const STORE_REGISTER_APT = 'http://localhost/client/WebService/register';
8
+ const KEY_SIGN_IN_SERVICE_URL = 'http://localhost/client/WebService/signInByAPIKey';
9
+ const DESIGN_SERVICE_URL = 'http://localhost/client/WebService/signInAndDesignAPIKey';
10
+ const UPGRADE_SERVICE_URL = 'http://localhost/client/WebService/signInAndUpgradeAPIKey/magento';
11
+ var $apiKey = null;
12
+
13
+ public function __construct()
14
+ {
15
+ $this->apiKey = Mage::getStoreConfig('xrely_autocomplete/config/api_key',Mage::app()->getStore());
16
+ }
17
+
18
+
19
+ public function registerStore($email, $user, $baseUrl)
20
+ {
21
+ return $this->callAPI(self::STORE_REGISTER_APT, 'post', array('email' => $email, 'userName' => $user, 'baseUrl' => $baseUrl,'client'=>'magento'));
22
+ }
23
+
24
+ public function sync($data)
25
+ {
26
+ $data["API_KEY"] = $this->apiKey;
27
+ return $this->callAPI(self::KEYWORD_DATA_API,'post',array("data"=> json_encode($data)));
28
+ }
29
+
30
+ private function callAPI($url, $type = 'post', $data)
31
+ {
32
+ $ch = curl_init();
33
+ curl_setopt($ch, CURLOPT_URL, $url);
34
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
35
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
36
+ if (strtolower($type) == 'post')
37
+ curl_setopt($ch, CURLOPT_POST, 1);
38
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
39
+ $result = curl_exec($ch);
40
+ curl_close($ch);
41
+ return $result;
42
+ }
43
+
44
+ public function productDetailChanged($product)
45
+ {
46
+ $catCollection = $product->getCategoryCollection()
47
+ ->addAttributeToSelect('name')
48
+ ->addAttributeToSelect('url')
49
+ ->addAttributeToSelect('is_active');
50
+ $catList = [];
51
+ foreach ($catCollection as $cat)
52
+ {
53
+ $catList[] = ['name' => $cat->getName(),
54
+ 'url' => $cat->getUrl()];
55
+ }
56
+ $imgUrl = "";
57
+ if($product->getThumbnail() != "" && $product->getThumbnail() != "no_selection")
58
+ $imgUrl = (String) Mage::helper('catalog/image')->init($product, 'thumbnail')->resize(32);
59
+ $pData = array();
60
+ $pData["client"] = "magento";
61
+ $pData["cmsName"] = "magento";
62
+ $pData["lastpage"] = false;
63
+ $pData["magentoData"]["items"] = [];
64
+ $pData["magentoData"]["items"][] = array(
65
+ 'xid' => $product->getId(),
66
+ 'keyword' => $product->getName(),
67
+ "metaData" => array(
68
+ 'url' => $product->getProductUrl(TRUE),
69
+ 'image' => $imgUrl,
70
+ 'categories' => $catList,
71
+ 'type' => 'product'
72
+ )
73
+ );
74
+ return $this->sync($pData);
75
+ }
76
+
77
+ public function getRedirectFormAction()
78
+ {
79
+ return self::KEY_SIGN_IN_SERVICE_URL;
80
+ }
81
+
82
+ public function getDesignRedirectFormAction()
83
+ {
84
+ return self::DESIGN_SERVICE_URL;
85
+ }
86
+
87
+ public function getUpgradeRedirectFormAction()
88
+ {
89
+ return self::UPGRADE_SERVICE_URL;
90
+ }
91
+
92
+ public function getAPIKey()
93
+ {
94
+ return $this->apiKey;
95
+ }
96
+
97
+ public function getFullProductUrl(Mage_Catalog_Model_Product $product = null){
98
+
99
+ // Force display deepest child category as request path.
100
+ $categories = $product->getCategoryCollection();
101
+ $deepCatId = 0;
102
+ $path = '';
103
+ $productPath = false;
104
+
105
+ foreach ($categories as $category) {
106
+ // Look for the deepest path and save.
107
+ if (substr_count($category->getData('path'), '/') > substr_count($path, '/')) {
108
+ $path = $category->getData('path');
109
+ $deepCatId = $category->getId();
110
+ }
111
+ }
112
+
113
+ // Load category.
114
+ $category = Mage::getModel('catalog/category')->load($deepCatId);
115
+
116
+ // Remove .html from category url_path.
117
+ $categoryPath = str_replace('.html', '', $category->getData('url_path'));
118
+
119
+ // Get product url path if set.
120
+ $productUrlPath = $product->getData('url_path');
121
+
122
+ // Get product request path if set.
123
+ $productRequestPath = $product->getData('request_path');
124
+
125
+ // If URL path is not found, try using the URL key.
126
+ if ($productUrlPath === null && $productRequestPath === null) {
127
+ $productUrlPath = $product->getData('url_key');
128
+ }
129
+
130
+ // Now grab only the product path including suffix (if any).
131
+ if ($productUrlPath) {
132
+ $path = explode('/', $productUrlPath);
133
+ $productPath = array_pop($path);
134
+ } elseif ($productRequestPath) {
135
+ $path = explode('/', $productRequestPath);
136
+ $productPath = array_pop($path);
137
+ }
138
+
139
+ // Now set product request path to be our full product url including deepest category url path.
140
+ if ($productPath !== false) {
141
+ if ($categoryPath) {
142
+ // Only use the category path is one is found.
143
+ $product->setData('request_path', $categoryPath . '/' . $productPath);
144
+ } else {
145
+ $product->setData('request_path', $productPath);
146
+ }
147
+ }
148
+
149
+ return $product->getProductUrl();
150
+ }
151
+ }
app/code/community/Xrely/Autocomplete/Helper/asas.sql ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ DELETE FROM `core_config_data` WHERE `path` LIKE '%xrely_autocomplete%';
2
+ DROP TABLE xrely_autocomplete_settings;
3
+ DELETE FROM `core_resource` WHERE `code` LIKE 'xrely_autocomplete_setup';
app/code/community/Xrely/Autocomplete/Model/Adminhtml/Thumb.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xrely_Autocomplete_Model_Adminhtml_Thumb
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ }
9
+
10
+ public function toOptionArray()
11
+ {
12
+ /*
13
+ * Fetch all the product attributes
14
+ */
15
+ $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
16
+ ->getItems();
17
+ $options = array();
18
+ foreach ($attributes as $attribute)
19
+ {
20
+ $label = $attribute->getFrontendLabel();
21
+ $code = $attribute->getAttributecode();
22
+ if ($code != "" && $label != "")
23
+ $options[$code] = $label;
24
+ }
25
+ return $options;
26
+ }
27
+
28
+ }
app/code/community/Xrely/Autocomplete/Model/Observer.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Xrely_Autocomplete_Model_Observer{
3
+
4
+ public function updateProductName(Varien_Event_Observer $observer){
5
+ $product = $observer->getData('product');
6
+ $helper = Mage::helper('xrely_autocomplete');
7
+ $helper->productDetailChanged($product);
8
+ }
9
+ }
app/code/community/Xrely/Autocomplete/Model/Resource/Settings.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xrely_Autocomplete_Model_Resource_Settings extends Mage_Core_Model_Resource_Db_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('xrely_autocomplete/settings', 'id');
8
+ }
9
+ }
app/code/community/Xrely/Autocomplete/Model/Resource/Settings/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xrely_Autocomplete_Model_Resource_Settings_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('xrely_autocomplete/settings');
8
+ }
9
+ }
app/code/community/Xrely/Autocomplete/Model/Settings.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xrely_Autocomplete_Model_Settings extends Mage_Core_Model_Abstract
4
+ {
5
+
6
+ const PRODUCT_PROCESSED = 1;
7
+ static $totalProduct = null;
8
+ protected function _construct()
9
+ {
10
+ $this->_init('xrely_autocomplete/settings');
11
+ }
12
+
13
+ public function markProduct($productId)
14
+ {
15
+ $data = array('id' => null,'eid' => $productId, 'key' => "p:$productId", 'value' => date('Y-m-d',time()), 'type' => self::PRODUCT_PROCESSED,'comment' => '');
16
+ $this->setData($data);
17
+ $id = $this->save()->getId();
18
+ $this->unsetData();
19
+ return $id;
20
+ }
21
+
22
+ public function totalProcessed()
23
+ {
24
+ return $this->getCollection()->addFieldToFilter('type', 1)->load()->getSize();
25
+ }
26
+
27
+ public function isProcessed($prodId)
28
+ {
29
+ $collection = $this->getCollection();
30
+ $collection->addFieldToFilter('type',1);
31
+ $collection->addFieldToFilter('eid',$prodId);
32
+ return $collection->count() > 0;
33
+ }
34
+ public static function getTotalProduct()
35
+ {
36
+ if(self::$totalProduct === null)
37
+ {
38
+ $collection = Mage::getResourceModel('reports/product_collection');
39
+ $collection->addStoreFilter();
40
+ return self::$totalProduct = $collection->getSize();
41
+ }
42
+ return self::$totalProduct;
43
+ }
44
+ }
app/code/community/Xrely/Autocomplete/controllers/Adminhtml/PublishController.php ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xrely_Autocomplete_Adminhtml_PublishController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+
6
+ const STATUS_IN_PROGRESS = 1;
7
+ const STATUS_DONE_NOW = 2;
8
+ const STATUS_DONE_IN_PAST = 3;
9
+ const STATUS_UPGRADE = 4;
10
+
11
+
12
+ public function urlAction()
13
+ {
14
+ $this->loadLayout();
15
+ $block = $this->getLayout()
16
+ ->createBlock('xrely_autocomplete/adminhtml_progress')
17
+ ->setTemplate('xrely_autocomplete/progress.phtml');
18
+ $this->_addContent($block);
19
+ $this->renderLayout();
20
+ }
21
+
22
+ public function prepareAction()
23
+ {
24
+ set_time_limit(0);
25
+ $helper = Mage::helper('xrely_autocomplete');
26
+ $collection = Mage::getResourceModel('reports/product_collection');
27
+ $collection->addStoreFilter();
28
+ $products = Mage::getModel('catalog/product')->getCollection();
29
+ $i = 0;
30
+ $pData = array();
31
+ $pData["client"] = "magento";
32
+ $pData["cmsName"] = "magento";
33
+ $pData["magentoData"]["items"] = [];
34
+ $model = Mage::getModel('xrely_autocomplete/settings');
35
+ $processed = $model->totalProcessed();
36
+ $totalProduct = $model->getTotalProduct();
37
+ if($processed >= $totalProduct)
38
+ {
39
+ Mage::getModel('core/config')->saveConfig('xrely_autocomplete/config/ini_sync', 1);
40
+ echo json_encode(
41
+ array(
42
+ 'status' => array(
43
+ 'code' => self::STATUS_DONE_IN_PAST,
44
+ 'current' => $model->totalProcessed(),
45
+ 'total' => $model->getTotalProduct()
46
+ )
47
+ )
48
+ );
49
+ die;
50
+ }
51
+ $markProd = array();
52
+ foreach ($products as $prod)
53
+ {
54
+ if ($model->isProcessed($prod->getId()))
55
+ continue;
56
+ $product = Mage::getModel('catalog/product')->load($prod->getId());
57
+ $catCollection = $product->getCategoryCollection()
58
+ ->addAttributeToSelect('name')
59
+ ->addAttributeToSelect('url')
60
+ ->addAttributeToSelect('is_active');
61
+ $catList = [];
62
+ foreach ($catCollection as $cat)
63
+ {
64
+ $catList[] =
65
+ [
66
+ 'name' => $cat->getName(),
67
+ 'url' => $cat->getUrl()
68
+ ];
69
+ }
70
+ $imgUrl = "";
71
+ if($product->getThumbnail() != "" && $product->getThumbnail() != "no_selection")
72
+ $imgUrl = (String) Mage::helper('catalog/image')->init($product, 'thumbnail')->resize(32);
73
+ $pData["magentoData"]["items"][] = array(
74
+ 'xid' => $product->getId(),
75
+ 'keyword' => $product->getName(),
76
+ "metaData" => array(
77
+ 'url' => $helper->getFullProductUrl($product),
78
+ 'image' => $imgUrl,
79
+ 'categories' => $catList
80
+ )
81
+ );
82
+ $markProd[] = $product->getId();
83
+
84
+
85
+ if (++$i % 5 == 0)
86
+ {
87
+ if ($i == $total_products_in_store)
88
+ $pData["lastpage"] = true;
89
+ else
90
+ $pData["lastpage"] = false;
91
+ /*
92
+ * Call to API
93
+ */
94
+
95
+ $resp = json_decode($helper->sync($pData),true);
96
+ if(!$resp['success'])
97
+ {
98
+ switch ($resp['action']) {
99
+ case 'upgrade':
100
+ echo json_encode(
101
+ array(
102
+ 'status' => array(
103
+ 'code' => self::STATUS_UPGRADE,
104
+ 'link' => Mage::helper("adminhtml")->getUrl("xrely_autocomplete/adminhtml_redirect/upgrade"),
105
+ 'text' => $resp['text'],
106
+ 'current' => $model->totalProcessed(),
107
+ 'total' => $model->getTotalProduct()
108
+ )
109
+ )
110
+ );
111
+ break;
112
+ default:
113
+ break;
114
+ }
115
+ die;
116
+ }
117
+ else
118
+ {
119
+ foreach ($markProd as $prodId) {
120
+ $model->markProduct($prodId);
121
+ }
122
+ $markProd = array();
123
+ }
124
+ echo json_encode(
125
+ array(
126
+ 'status' => array(
127
+ 'code' => self::STATUS_IN_PROGRESS,
128
+ 'current' => $model->totalProcessed(),
129
+ 'total' => $model->getTotalProduct()
130
+ )
131
+ )
132
+ );
133
+ $processed = $model->totalProcessed();
134
+ $totalProduct = $model->getTotalProduct();
135
+ if($processed >= $totalProduct)
136
+ Mage::getModel('core/config')->saveConfig('xrely_autocomplete/config/ini_sync', 1);
137
+ die;
138
+ $pData["magentoData"]["items"] = [];
139
+ }
140
+ }
141
+ if (count($pData["magentoData"]["items"] > 0))
142
+ {
143
+ /*
144
+ * Call to API
145
+ */
146
+ foreach ($markProd as $prodId) {
147
+ $model->markProduct($prodId);
148
+ }
149
+ $markProd = array();
150
+ echo json_encode(
151
+ array(
152
+ 'status' => array(
153
+ 'code' => self::STATUS_IN_PROGRESS,
154
+ 'current' => $model->totalProcessed(),
155
+ 'total' => $model->getTotalProduct()
156
+ )
157
+ )
158
+ );
159
+ $helper->sync($pData);
160
+ $processed = $model->totalProcessed();
161
+ $totalProduct = $model->getTotalProduct();
162
+ if($processed >= $totalProduct)
163
+ Mage::getModel('core/config')->saveConfig('xrely_autocomplete/config/ini_sync', 1);
164
+ die;
165
+ }
166
+ }
167
+
168
+ public function statusAction()
169
+ {
170
+ $model = Mage::getModel('xrely_autocomplete/settings');
171
+ $processed = $model->totalProcessed();
172
+ $totalProduct = $model->getTotalProduct();
173
+ if($processed >= $totalProduct)
174
+ Mage::getModel('core/config')->saveConfig('xrely_autocomplete/config/ini_sync', 1);
175
+ echo json_encode(
176
+ array(
177
+ 'status' => array(
178
+ 'current' => $processed,
179
+ 'total' => $totalProduct
180
+ )
181
+ )
182
+ );
183
+ die;
184
+ }
185
+ }
app/code/community/Xrely/Autocomplete/controllers/Adminhtml/RedirectController.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Xrely_Autocomplete_Adminhtml_RedirectController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function postAction()
5
+ {
6
+ $this->getResponse()->setBody($this->getLayout()->createBlock('xrely_autocomplete/adminhtml_redirect')->toHtml());
7
+ $this->getResponse()->sendResponse();
8
+ die;
9
+ }
10
+
11
+ public function designAction()
12
+ {
13
+ $this->getResponse()->setBody($this->getLayout()->createBlock('xrely_autocomplete/adminhtml_design')->toHtml());
14
+ $this->getResponse()->sendResponse();
15
+ die;
16
+ }
17
+
18
+ public function upgradeAction()
19
+ {
20
+ $this->getResponse()->setBody($this->getLayout()->createBlock('xrely_autocomplete/adminhtml_upgrade')->toHtml());
21
+ $this->getResponse()->sendResponse();
22
+ die;
23
+ }
24
+ }
app/code/community/Xrely/Autocomplete/controllers/ListenController.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Xrely_Autocomplete_ListenController extends Mage_Core_Controller_Front_Action
3
+ {
4
+
5
+ public function eventAction()
6
+ {
7
+ if($this->checkKey($_POST['API_KEY']))
8
+ {
9
+ switch ($_POST['type']) {
10
+ case 'notify':
11
+ Mage::getModel('core/config')->saveConfig('xrely_autocomplete/config/notify_msg', $_POST['msg']);
12
+ Mage::getModel('core/config')->saveConfig('xrely_autocomplete/config/notify', 1);
13
+ echo json_encode(array('sucess'=>true,'msg' => 'Notified'));
14
+ break;
15
+ default:
16
+ echo json_encode(array('sucess'=>false,'msg' => 'No Metdhod'));
17
+ break;
18
+ }
19
+ }
20
+ }
21
+
22
+ public function checkKey($key)
23
+ {
24
+ if($key != Mage::getStoreConfig('xrely_autocomplete/config/api_key',Mage::app()->getStore()))
25
+ {
26
+ die(json_encode(array('sucess' => false,'msg' => 'Unauthorized')));
27
+ }
28
+ else
29
+ {
30
+ return true;
31
+ }
32
+ }
33
+ }
app/code/community/Xrely/Autocomplete/data/xrely_autocomplete_setup/data-install-1.0.0.0.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $adminUserModel = Mage::getModel('admin/user');
4
+ $userCollection = $adminUserModel->getCollection()->load();
5
+ Mage::getModel('core/config')->saveConfig('xrely_autocomplete/config/admin_email', $userCollection->getData()[0]["email"]);
6
+ Mage::getModel('core/config')->saveConfig('xrely_autocomplete/config/ini_sync', 0);
7
+ $helper = Mage::helper('xrely_autocomplete');
8
+ $email = $userCollection->getData()[0]["email"];
9
+ $userName = $userCollection->getData()[0]["firstname"];
10
+
11
+ $details = json_decode($helper->registerStore($email, $userName, Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)), true);
12
+
13
+ Mage::getModel('core/config')->saveConfig('xrely_autocomplete/config/imagefield', 'thumbnail');
14
+ Mage::getModel('core/config')->saveConfig('xrely_autocomplete/config/enabled', '0');
15
+
16
+ if (isset($details["success"]) && $details["success"] == true)
17
+ {
18
+ if (isset($details["details"]["apiKey"]))
19
+ {
20
+ Mage::getModel('core/config')->saveConfig('xrely_autocomplete/config/api_key', $details["details"]["apiKey"]);
21
+ Mage::getModel('core/config')->saveConfig('xrely_autocomplete/config/notify', 0);
22
+ if(preg_match('/[0-9]+\.localhost/is', $details["details"]['host']))
23
+ {
24
+ Mage::getModel('core/config')->saveConfig('xrely_autocomplete/config/localhost_domain', $details["details"]["host"]);
25
+ }
26
+ Mage::getModel('core/config')->saveConfig('xrely_autocomplete/config/time', time());
27
+ }
28
+ }
app/code/community/Xrely/Autocomplete/etc/adminhtml.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <xrely_autocomplete translate="label" module="xrely_autocomplete">
12
+ <title>XreY Autocomplete</title>
13
+ </xrely_autocomplete>
14
+ </children>
15
+ </config>
16
+ </children>
17
+ </system>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ <menu>
23
+ <xrely_autocomplete translate="XrelY" module="xrely_autocomplete">
24
+ <title>XrelY</title>
25
+ <sort_order>999</sort_order>
26
+ <children>
27
+ <design translate="title" module="xrely_autocomplete">
28
+ <title>Design Autocomplete</title>
29
+ <sort_order>2</sort_order>
30
+ <action>xrely_autocomplete/adminhtml_redirect/design</action>
31
+ </design>
32
+ </children>
33
+ <children>
34
+ <dashboard translate="title" module="xrely_autocomplete">
35
+ <title>Dashboard</title>
36
+ <sort_order>1</sort_order>
37
+ <action>xrely_autocomplete/adminhtml_redirect/post</action>
38
+ </dashboard>
39
+ </children>
40
+ <children>
41
+ <configure translate="title" module="xrely_autocomplete">
42
+ <title>Configure</title>
43
+ <sort_order>1</sort_order>
44
+ <action>adminhtml/system_config/edit/section/xrely_autocomplete</action>
45
+ </configure>
46
+ </children>
47
+ </xrely_autocomplete>
48
+ </menu>
49
+ </config>
app/code/community/Xrely/Autocomplete/etc/config.xml ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Module configuration
5
+ *
6
+ * @author Magento
7
+ */
8
+ -->
9
+ <config>
10
+ <modules>
11
+ <Xrely_Autocomplete>
12
+ <version>1.0.0.0</version>
13
+ </Xrely_Autocomplete>
14
+ </modules>
15
+ <global>
16
+ <models>
17
+ <xrely_autocomplete>
18
+ <class>Xrely_Autocomplete_Model</class>
19
+ <resourceModel>xrely_resource</resourceModel>
20
+ </xrely_autocomplete>
21
+ <xrely_resource>
22
+ <class>Xrely_Autocomplete_Model_Resource</class>
23
+ <entities>
24
+ <settings>
25
+ <table>xrely_autocomplete_settings</table>
26
+ </settings>
27
+ </entities>
28
+ </xrely_resource>
29
+ </models>
30
+ <helpers>
31
+ <xrely_autocomplete>
32
+ <class>Xrely_Autocomplete_Helper</class>
33
+ </xrely_autocomplete>
34
+ </helpers>
35
+ <blocks>
36
+ <xrely_autocomplete>
37
+ <class>Xrely_Autocomplete_Block</class>
38
+ </xrely_autocomplete>
39
+ </blocks>
40
+ <resources>
41
+ <xrely_autocomplete_setup>
42
+ <setup>
43
+ <module>Xrely_Autocomplete</module>
44
+ <class>Mage_Core_Model_Resource_Setup</class>
45
+ </setup>
46
+ </xrely_autocomplete_setup>
47
+ </resources>
48
+ <events>
49
+ <before_news_item_display>
50
+ <observers>
51
+ <xrely_autocomplete>
52
+ <class>xrely_autocomplete/observer</class>
53
+ <method>beforeNewsDisplayed</method>
54
+ </xrely_autocomplete>
55
+ </observers>
56
+ </before_news_item_display>
57
+ <catalog_product_save_after>
58
+ <observers>
59
+ <Xrely_Autocomplete_Model_Observer>
60
+ <class>Xrely_Autocomplete_Model_Observer</class>
61
+ <method>updateProductName</method>
62
+ </Xrely_Autocomplete_Model_Observer>
63
+ </observers>
64
+ </catalog_product_save_after>
65
+ </events>
66
+ </global>
67
+ <frontend>
68
+ <routers>
69
+ <xrely_autocomplete>
70
+ <use>standard</use>
71
+ <args>
72
+ <module>Xrely_Autocomplete</module>
73
+ <frontName>xrely_autocomplete</frontName>
74
+ </args>
75
+ </xrely_autocomplete>
76
+ </routers>
77
+ <layout>
78
+ <updates>
79
+ <xrely_autocomplete>
80
+ <file>xrely_autocomplete.xml</file>
81
+ </xrely_autocomplete>
82
+ </updates>
83
+ </layout>
84
+ </frontend>
85
+ <admin>
86
+ <routers>
87
+ <adminhtml>
88
+ <args>
89
+ <modules>
90
+ <Xrely_Autocomplete before="Mage_Adminhtml">Xrely_Autocomplete_Adminhtml</Xrely_Autocomplete>
91
+ </modules>
92
+ </args>
93
+ </adminhtml>
94
+ <xrely_autocomplete>
95
+ <use>admin</use>
96
+ <args>
97
+ <module>Xrely_Autocomplete</module>
98
+ <frontName>xrely_autocomplete</frontName>
99
+ </args>
100
+ </xrely_autocomplete>
101
+ </routers>
102
+ </admin>
103
+ <adminhtml>
104
+ <layout>
105
+ <updates>
106
+ <xrely_autocomplete>
107
+ <file>xrely_autocomplete.xml</file>
108
+ </xrely_autocomplete>
109
+ </updates>
110
+ </layout>
111
+ </adminhtml>
112
+ <default>
113
+ <xrely>
114
+ <config>
115
+ <imagefield>thumbnail</imagefield>
116
+ <attributes>1</attributes>
117
+ <layered>0</layered>
118
+ </config>
119
+ </xrely>
120
+ </default>
121
+ </config>
app/code/community/Xrely/Autocomplete/etc/system.xml ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <xrely_autocomplete>
5
+ <label>
6
+ XrelY
7
+ </label>
8
+ </xrely_autocomplete>
9
+ </tabs>
10
+ <sections>
11
+ <xrely_autocomplete translate="label" module="xrely_autocomplete">
12
+ <label><![CDATA[ Configuration<span style='display:inline;margin:2px;color:red;padding-left:2px;'>*</span> ]]></label>
13
+ <tab>xrely_autocomplete</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>100</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <groups>
20
+ <config translate="label">
21
+ <label>General Settings</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>1</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <fields>
28
+ <enabled translate="label">
29
+ <label>Enable XrelY</label>
30
+ <frontend_type>select</frontend_type>
31
+ <source_model>adminhtml/system_config_source_yesno</source_model>
32
+ <sort_order>1</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ </enabled>
37
+ <imagefield translate="label">
38
+ <label>Magento field for product thumbnail image</label>
39
+ <frontend_type>select</frontend_type>
40
+ <source_model>xrely_autocomplete/adminhtml_thumb</source_model>
41
+ <sort_order>2</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ </imagefield>
46
+ <sync translate="label">
47
+ <label>Sync products details with XrelY</label>
48
+ <comment>Allow us to index product details</comment>
49
+ <frontend_model>xrely_autocomplete/adminhtml_syncbtn</frontend_model>
50
+ <frontend_type>button</frontend_type>
51
+ <sort_order>3</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ </sync>
56
+ </fields>
57
+ <comment>
58
+ <![CDATA[ <h4><a href="http://autocomplete.xrely.com">XRelY</a> provides vary fast and reliable autocomplete with autocorrection for your e-commerce shop to <b>empower your search.</b></h4>
59
+ <p>You can take your autocomplete suggestion to next level just follow <a href="http://autocomplete.xrely.com/Documentation"><b>this</b></a> link to gothrough our API documentation.</p>
60
+ <p>If you find any difficulty using this extension please contact us at <a href="mailto:support@xrely.com?Subject=Magento Extesion Support">support@xrely.com</a></p>
61
+ <hr style='margin:10px 0'>
62
+ ]]>
63
+ </comment>
64
+ </config>
65
+ </groups>
66
+ </xrely_autocomplete>
67
+ </sections>
68
+ </config>
app/code/community/Xrely/Autocomplete/sql/xrely_autocomplete_setup/install-1.0.0.0.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //var_dump($user = Mage::getSingleton('admin/session')->getUser());;die;
4
+ $installer = $this;
5
+
6
+ $installer->startSetup();
7
+
8
+ $table = $installer->getConnection()
9
+ ->newTable($installer->getTable('xrely_autocomplete/settings'))
10
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
11
+ 'identity' => true,
12
+ 'unsigned' => true,
13
+ 'nullable' => false,
14
+ 'primary' => true,
15
+ ), 'Id')
16
+ ->addColumn('type', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
17
+ 'unsigned' => true,
18
+ 'nullable' => false,
19
+ ), 'Id')
20
+ ->addColumn('eid', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
21
+ 'unsigned' => true,
22
+ 'nullable' => false,
23
+ ), 'EId')
24
+ ->addColumn('key', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
25
+ 'nullable' => false
26
+ ), 'Key')
27
+ ->addColumn('value', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
28
+ 'nullable' => false,
29
+ ), 'Value')
30
+ ->addColumn('comment', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
31
+ 'nullable' => true,
32
+ ), 'Comment');
33
+ $installer->getConnection()->createTable($table);
34
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/xrely_autocomplete.xml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <default>
4
+ <reference name="notifications">
5
+ <block type="xrely_autocomplete/adminhtml_notifications" name="xrely_autocomplete_notifications" template="xrely_autocomplete/notification.phtml"/>
6
+ </reference>
7
+ <reference name="head">
8
+ <action method="addJs"><script>xrely_autocomplete/admin.js</script></action>
9
+ </reference>
10
+ </default>
11
+ </layout>
app/design/adminhtml/default/default/template/xrely_autocomplete/notification.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php if ($message = $this->getMessage()) : ?>
2
+ <div class="notification-global"><?php echo $message ?></div>
3
+ <?php endif; ?>
app/design/adminhtml/default/default/template/xrely_autocomplete/progress.phtml ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <h3><?php echo Mage::helper('adminhtml')->__('Let\'s start...') ?></h3>
3
+ </div>
4
+ <style>
5
+ #xrely-progress{
6
+ width: 70%
7
+ }
8
+ #xrely-progress .progress{
9
+ width: 100%;
10
+ height: 8px;
11
+ border: 1px solid #eee2be;
12
+ background-color: rgb(255, 249, 233);
13
+ }
14
+ .sync-bar{
15
+ background-color: #eb5e00;
16
+ height: 100%;
17
+ width: 0%;
18
+ }
19
+ .sync-status{
20
+ margin-left: 0;
21
+ height: 16px;
22
+ border-left: 1px solid #eb5e00;
23
+ font-size: 10px;
24
+ }
25
+ .logger{
26
+ margin-top: 3px;
27
+ }
28
+ </style>
29
+ <div id="xrely-progress">
30
+ <div class="progress">
31
+ <div class="sync-bar"></div>
32
+ <div class="sync-status"><b style="margin-left: 2px;">0%</b></div>
33
+ </div>
34
+ </div>
35
+ <div class="console-log" style="margin-top:30px;">
36
+ <ul class="logger">
37
+
38
+ </ul>
39
+ </div>
40
+ <p><?php // echo Mage::helper('adminhtml')->__('We\'re in our typing table, coding away more features for Magento. Thank you for your patience.') ?></p>
41
+ <script>
42
+ var urls = <?php
43
+ echo json_encode(
44
+ array(
45
+ 'prepare' => array(
46
+ 'init' => Mage::helper('adminhtml')->getUrl('xrely_autocomplete/adminhtml_publish/prepare'),
47
+ 'status' => Mage::helper('adminhtml')->getUrl('xrely_autocomplete/adminhtml_publish/status')
48
+ ),
49
+ 'sync' => array(
50
+ 'status' => Mage::helper('adminhtml')->getUrl('xrely_autocomplete/adminhtml_publish/progress')
51
+ )
52
+ )
53
+ );
54
+ ?>;
55
+ Ajax.Responders.unregister(varienLoaderHandler.handler);
56
+ var currentTimeout;
57
+ var styler;
58
+ var logger = $$('ul.logger')[0];
59
+
60
+ if(typeof Element.morph == "function")
61
+ styler = Element.morph;
62
+ else
63
+ styler = Element.setStyle;
64
+
65
+ logger.insert("<li><strong>Starting Sync</strong></li>");
66
+ function start()
67
+ {
68
+ new Ajax.Request(urls.prepare.init, {
69
+ method: 'get',
70
+ onCreate : function ()
71
+ {
72
+ // ;
73
+ },
74
+ onComplete: function (transport) {
75
+ /*
76
+ * Sync Completes
77
+ */
78
+ data = JSON.parse(transport.responseText);
79
+ percentage = Math.ceil((data.status.current/data.status.total)*100);
80
+ styler.call(this,($$("div.sync-bar")[0]),{width:percentage + "%"});
81
+ styler.call(this,($$("div.sync-status")[0]),{marginLeft: percentage+"%"});
82
+ $$("div.sync-status b")[0].update(Math.ceil((data.status.current/data.status.total)*100)+"%");
83
+ if(data.status.code == 3)
84
+ {
85
+ logger.insert("<li><strong>Syncronization is done</strong></li><li><a href='JavaScript:window.close()'>close window</a></li>");
86
+ return;
87
+ }
88
+ if(data.status.code == 4)
89
+ {
90
+ logger.insert("<li><strong>"+data.status.text+" <a href='"+data.status.link+"'><b>upgrade</b></a></strong></li><li><a href='JavaScript:window.close()'>close window</a></li>");
91
+ return;
92
+ }
93
+ if(!$$("ul.logger li.productCount")[0])
94
+ {
95
+ $$("ul.logger")[0].insert("<li class='productCount'><strong><span>"+data.status.current+"/"+data.status.total+"</span> Product has been processes </strong></li>");
96
+ }
97
+ else
98
+ {
99
+ $$("ul.logger li.productCount span")[0].update(data.status.current+"/"+data.status.total);
100
+ }
101
+ if(data.status.current != data.status.total)
102
+ {
103
+ start();
104
+ }
105
+ else
106
+ {
107
+ logger.insert("<li><strong>Syncronization is done</strong></li><li><a href='JavaScript:window.close()'>close window</a></li>");
108
+ }
109
+ }
110
+ });
111
+ }
112
+ start();
113
+
114
+ </script>
app/design/frontend/base/default/layout/xrely_autocomplete.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento frontend layout
5
+ *
6
+ * @author Magento
7
+ */
8
+ -->
9
+ <layout version="0.1.0">
10
+ <default>
11
+ <reference name="head">
12
+ <block name="xrely_js" template="autocomplete/js.phtml" type="xrely_autocomplete/js"/>
13
+ </reference>
14
+ </default>
15
+ <xrely_autocomplete_listen_multiply>
16
+ <reference name="root">
17
+ <action method="setTemplate">
18
+ <template>page/1column.phtml</template>
19
+ </action>
20
+ </reference>
21
+ </xrely_autocomplete_listen_multiply>
22
+ </layout>
app/design/frontend/base/default/template/autocomplete/js.phtml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if(Mage::getStoreConfigFlag('xrely_autocomplete/config/enabled')){ ?>
3
+ <style>
4
+ .autocomplete-suggestions{
5
+ text-align: left;
6
+ background-color: whitesmoke;
7
+ cursor: default;
8
+ }
9
+ </style>
10
+ <script type="text/javascript">
11
+ function formatSuggestion(keyword,keywordData)
12
+ {
13
+ catHtml = "";
14
+ try{
15
+ for (var i = keywordData.data.categories.length - 1; i >= 0; i--) {
16
+
17
+ catHtml += "<div><small style='color:green'>in"+keywordData.data.categories[i].name+"</small></div>";
18
+ };
19
+
20
+ }catch(ex){
21
+
22
+ }
23
+ img = "";
24
+ height = "auto";
25
+ if(keywordData.data.image)
26
+ {
27
+ height = "42px";
28
+ img = "<img style='float:left;' src='"+keywordData.data.image+"' />";
29
+ }
30
+ return "<div style='height:"+height+"'>"+img+"<span><small>"+keywordData.value+"</small></span></div>"+catHtml;
31
+ }
32
+ function suggestionSelected(keyword,keywordData)
33
+ {
34
+ if(keywordData.data.url)
35
+ {
36
+ window.location.href= keywordData.data.url;
37
+ }
38
+ else
39
+ {
40
+ this.form.submit();
41
+ }
42
+ }
43
+ var xfindSelect = "#search";
44
+ (function() {
45
+ var s = document.createElement("script");
46
+ s.type = "text/javascript";
47
+ s.src = "<?php echo $this->getXrelyJsUrl(); ?>";
48
+ var x = document.getElementsByTagName("head")[0];
49
+ x.appendChild(s);
50
+ })();
51
+ </script>
52
+ <?php } ?>
app/design/frontend/base/default/template/autocomplete/post_redirect.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <form></form>
app/etc/modules/Xrely_Autocomplete.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Module initial config
5
+ *
6
+ * @author Magento
7
+ */
8
+ -->
9
+ <config>
10
+ <modules>
11
+ <Xrely_Autocomplete>
12
+ <active>true</active>
13
+ <codePool>community</codePool>
14
+ <!-- <depends>
15
+ <Mage_Adminhtml />
16
+ </depends>-->
17
+ </Xrely_Autocomplete>
18
+ </modules>
19
+ </config>
js/xrely_autocomplete/admin.js ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ document.observe("dom:loaded", function() {
2
+ var anchors = document.getElementsByTagName("a");
3
+ [].forEach.call(anchors , function (anchor) {
4
+ if (anchor.getAttribute("href").indexOf("xrely_autocomplete/adminhtml_redirect/") > -1)
5
+ {
6
+ anchor.setAttribute("target", "_blank");
7
+ }
8
+ });
9
+ });
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Xrely_Autocomplete</name>
4
+ <version>1.0.0</version>
5
+ <stability>beta</stability>
6
+ <license uri="http://opensource.org/licenses/mit-license.php">MITL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Xrely Autocomplete</summary>
10
+ <description>Xrely Autocomplete</description>
11
+ <notes>Initial release for basic features</notes>
12
+ <authors><author><name>Jugal</name><user>jugal4343</user><email>jugal@xrely.com</email></author></authors>
13
+ <date>2015-10-31</date>
14
+ <time>10:19:45</time>
15
+ <contents><target name="magecommunity"><dir name="Xrely"><dir name="Autocomplete"><dir name="Block"><dir name="Adminhtml"><file name="Design.php" hash="958be5829c6267e5132921a304c41cfa"/><file name="Notifications.php" hash="1dcbbd1610b3c510806a56f4d2c771f4"/><file name="Progress.php" hash="17f43ab2159894b64c192ca44b8ee749"/><file name="Redirect.php" hash="14bbb1d6d6fabed9758e22ee0b3eb498"/><file name="Syncbtn.php" hash="e02efc91a9e5d6e4fa688c3cbf19d991"/><file name="Thumb.php" hash="9fb6939e7299ed56253836c63054d0f7"/><file name="Upgrade.php" hash="cdc090fb56dc0a77776bfefad641b785"/></dir><file name="Js.php" hash="34eef2d142a53c3719ec4d04f7fd2fc6"/><file name="Sync.php" hash="63fef0ebe3312a69525d2908b48f70b9"/></dir><dir name="Helper"><file name="Data.php" hash="c8aa21a78eb6de96c8b69140aae9d66a"/><file name="asas.sql" hash="487e0d8ffb34cdefe3c2d80da1f01f05"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Thumb.php" hash="fe325ff721c9138d4afbe6d231d9347e"/></dir><file name="Observer.php" hash="c051fe823adcdc45cf0d4d39cf20f4ac"/><dir name="Resource"><dir name="Settings"><file name="Collection.php" hash="08356fd322c09e673bde0efcbb8ca9af"/></dir><file name="Settings.php" hash="03e4e14935ba8d81c324a4c2fbe9fc77"/></dir><file name="Settings.php" hash="ac39d6fb78a55068772154a1e82b5a94"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="PublishController.php" hash="7db654330fb7b4e97191b7e579bd275a"/><file name="RedirectController.php" hash="e2cfebffb4e1d776886b2dd165778c67"/></dir><file name="ListenController.php" hash="569e4420bd9f83cacdeb60ddbe8e4666"/></dir><dir name="data"><dir name="xrely_autocomplete_setup"><file name="data-install-1.0.0.0.php" hash="5b7152cfaca84e5f6d61f16340a8953a"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="6ede1531da8ecaf2be33fa2a56e3d1d4"/><file name="config.xml" hash="16a19107d044feade470ea55c4fbbb02"/><file name="system.xml" hash="0ab99a205e49e1ad0844d67a9c03b4e7"/></dir><dir name="sql"><dir name="xrely_autocomplete_setup"><file name="install-1.0.0.0.php" hash="496a2c7ee033e0642ffc7f09e3ccc32b"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="."><dir name="js"><dir name="xrely_autocomplete"><file name="admin.js" hash="635f3d1a915a6a5521db2992a20ac7ce"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Xrely_Autocomplete.xml" hash="c114c9109d18628e9afb8c04c1776ee1"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="xrely_autocomplete.xml" hash="9a34dc0c48f6d3e39888aebd72ab573c"/></dir><dir name="template"><dir name="xrely_autocomplete"><file name="notification.phtml" hash="849b047815142a22b5254467188a7462"/><file name="progress.phtml" hash="45bab2e25ae096479f9a4c5719bbddb8"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="xrely_autocomplete.xml" hash="95dd91d0e1f3a624e2cd00db890c1a8a"/></dir><dir name="template"><dir name="autocomplete"><file name="js.phtml" hash="9f45aa72565bfbaa0b48e6bceddba71d"/><file name="post_redirect.phtml" hash="da2a203dca5e777d2b2c2fc3553c3d2f"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>