Version Notes
Choice AI plugin
Download this release
Release Info
Developer | MineWhat Inc. |
Extension | choiceai |
Version | 1.0.11 |
Comparing to | |
See all releases |
Code changes from version 1.0.10 to 1.0.11
- app/code/community/ChoiceAI/Personalisation/controllers/ApiController.php +3 -0
- app/code/local/ChoiceAI/Search/Model/Resource/Engine/Choiceaisearch.php +6 -2
- app/design/frontend/base/default/template/choiceai/personalisation/base/script.phtml +1 -0
- app/design/frontend/default/default/template/choiceai/personalisation/base/script.phtml +1 -5
- lib/ChoiceAI/Service.php +7 -40
- package.xml +5 -5
app/code/community/ChoiceAI/Personalisation/controllers/ApiController.php
CHANGED
@@ -619,6 +619,8 @@ class ChoiceAI_Personalisation_ApiController extends Mage_Core_Controller_Front_
|
|
619 |
|
620 |
if(!$updateStatus)
|
621 |
throw new Exception("Couldn't update");
|
|
|
|
|
622 |
|
623 |
$this->getResponse()
|
624 |
->setBody(json_encode(array("status"=>"ok", 'version' => self::API_VERSION)))
|
@@ -737,6 +739,7 @@ class ChoiceAI_Personalisation_ApiController extends Mage_Core_Controller_Front_
|
|
737 |
|
738 |
$model->save();
|
739 |
|
|
|
740 |
Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG));
|
741 |
|
742 |
$this->getResponse()
|
619 |
|
620 |
if(!$updateStatus)
|
621 |
throw new Exception("Couldn't update");
|
622 |
+
else
|
623 |
+
Mage::app()->getCache()->save(null, "sysFacets", array("facets"));
|
624 |
|
625 |
$this->getResponse()
|
626 |
->setBody(json_encode(array("status"=>"ok", 'version' => self::API_VERSION)))
|
739 |
|
740 |
$model->save();
|
741 |
|
742 |
+
Mage::app()->getCache()->save(null, "sysFacets", array("facets"));
|
743 |
Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG));
|
744 |
|
745 |
$this->getResponse()
|
app/code/local/ChoiceAI/Search/Model/Resource/Engine/Choiceaisearch.php
CHANGED
@@ -231,9 +231,13 @@ class ChoiceAI_Search_Model_Resource_Engine_ChoiceAIsearch extends ChoiceAI_Sear
|
|
231 |
if(isset($_SERVER['HTTP_REFERER']))
|
232 |
$getParamsToSend['r'] = $_SERVER['HTTP_REFERER'];
|
233 |
|
234 |
-
if(isset($_COOKIE['caicookie']))
|
235 |
$getParamsToSend['u'] = $_COOKIE['caicookie'];
|
236 |
-
|
|
|
|
|
|
|
|
|
237 |
|
238 |
// Calls Client.php in lib
|
239 |
$data = $this->client
|
231 |
if(isset($_SERVER['HTTP_REFERER']))
|
232 |
$getParamsToSend['r'] = $_SERVER['HTTP_REFERER'];
|
233 |
|
234 |
+
if(isset($_COOKIE['caicookie'])) {
|
235 |
$getParamsToSend['u'] = $_COOKIE['caicookie'];
|
236 |
+
}
|
237 |
+
else
|
238 |
+
{
|
239 |
+
$getParamsToSend['isnew'] = true;
|
240 |
+
}
|
241 |
|
242 |
// Calls Client.php in lib
|
243 |
$data = $this->client
|
app/design/frontend/base/default/template/choiceai/personalisation/base/script.phtml
CHANGED
@@ -33,6 +33,7 @@ foreach ($cart->getAllVisibleItems() as $item) {
|
|
33 |
|
34 |
<script type="text/javascript">
|
35 |
//<![CDATA[
|
|
|
36 |
window.CAI_CART_ITEMS = <?php echo json_encode($cart_items); ?>;
|
37 |
window.CAI_MAGENTO_ADDTOCART_FORM_KEY = '<?php echo Mage::getSingleton('core/session')->getFormKey()?>';
|
38 |
//]]>
|
33 |
|
34 |
<script type="text/javascript">
|
35 |
//<![CDATA[
|
36 |
+
window._mwuserid = '<?php echo Mage::registry("caiuid")?>';
|
37 |
window.CAI_CART_ITEMS = <?php echo json_encode($cart_items); ?>;
|
38 |
window.CAI_MAGENTO_ADDTOCART_FORM_KEY = '<?php echo Mage::getSingleton('core/session')->getFormKey()?>';
|
39 |
//]]>
|
app/design/frontend/default/default/template/choiceai/personalisation/base/script.phtml
CHANGED
@@ -34,10 +34,6 @@ foreach ($cart->getAllVisibleItems() as $item) {
|
|
34 |
<script type="text/javascript">
|
35 |
//<![CDATA[
|
36 |
window.CAI_CART_ITEMS = <?php echo json_encode($cart_items); ?>;
|
37 |
-
window.
|
38 |
-
var form_key = '<?php echo Mage::getSingleton('core/session')->getFormKey()?>';
|
39 |
-
var url = '<?php echo Mage::getUrl('checkout/cart/add');?>'+'product/'+id+'/qty/'+qty+'/form_key/'+form_key;
|
40 |
-
window.location.assign(url);
|
41 |
-
}
|
42 |
//]]>
|
43 |
</script>
|
34 |
<script type="text/javascript">
|
35 |
//<![CDATA[
|
36 |
window.CAI_CART_ITEMS = <?php echo json_encode($cart_items); ?>;
|
37 |
+
window.CAI_MAGENTO_ADDTOCART_FORM_KEY = '<?php echo Mage::getSingleton('core/session')->getFormKey()?>';
|
|
|
|
|
|
|
|
|
38 |
//]]>
|
39 |
</script>
|
lib/ChoiceAI/Service.php
CHANGED
@@ -35,36 +35,10 @@ class ChoiceAI_Service
|
|
35 |
if (is_null($sorts) || !isset($sorts) || !is_array($sorts) || !sizeof($sorts) > 0) {
|
36 |
return '';
|
37 |
}
|
38 |
-
|
39 |
foreach ($sorts as $sortKey => $sortValue) {
|
40 |
-
|
41 |
-
|
42 |
-
// }
|
43 |
-
// $startFlag = true;
|
44 |
-
// if($sort_value == 1) {
|
45 |
-
// $sortString=$sortString.rawurlencode($sort_key." asc");
|
46 |
-
// } else {
|
47 |
-
// $sortString=$sortString.rawurlencode($sort_key." desc");
|
48 |
-
// }
|
49 |
-
switch ($sortKey) {
|
50 |
-
case $sortKey == "price_high_to_low":
|
51 |
-
$sortString .= "&sortBy=price&sortOrder=desc";
|
52 |
-
break;
|
53 |
-
|
54 |
-
case $sortKey == "price_low_to_high":
|
55 |
-
$sortString .= "&sortBy=price&sortOrder=asc";
|
56 |
-
break;
|
57 |
-
|
58 |
-
case $sortKey == "newest":
|
59 |
-
$sortString .= "&rmodel=newest";
|
60 |
-
break;
|
61 |
-
|
62 |
-
case $sortKey == "bestsellers":
|
63 |
-
$sortString .= "&rmodel=bestsellers";
|
64 |
-
break;
|
65 |
-
}
|
66 |
}
|
67 |
-
|
68 |
return $sortString;
|
69 |
}
|
70 |
|
@@ -145,11 +119,14 @@ class ChoiceAI_Service
|
|
145 |
$context = stream_context_create($opts);
|
146 |
$response = file_get_contents($url, false, $context);
|
147 |
|
148 |
-
Mage::getSingleton('core/cookie')->set("api_url", $url);
|
149 |
-
|
150 |
$choiceaiResponse = null;
|
151 |
if (isset($response)) {
|
152 |
$response = Mage::helper('core')->jsonDecode($response);
|
|
|
|
|
|
|
|
|
|
|
153 |
|
154 |
$data = $response['data'];
|
155 |
|
@@ -195,16 +172,6 @@ class ChoiceAI_Service
|
|
195 |
|
196 |
$choiceaiResponse = new ChoiceAI_ResultSet($data);
|
197 |
|
198 |
-
// Not required, spellcheck will be done server-side automagically
|
199 |
-
// if($spellcheck) {
|
200 |
-
// $choiceaiResponse->setSpellCheckQuery($params['query']);
|
201 |
-
// }
|
202 |
-
|
203 |
-
// if((!is_null($choiceaiResponse) && !$spellcheck && $choiceaiResponse->getTotalHits()==0 && !is_null($spellSuggest=$choiceaiResponse->getSpellSuggestion())) ||
|
204 |
-
// (!$spellcheck && $choiceaiResponse->getSpellcheckFrequency()>20 && !is_null($spellSuggest=$choiceaiResponse->getSpellSuggestion()))){
|
205 |
-
// $params['query'] = $spellSuggest;
|
206 |
-
// return $this->search($params, $address, true);
|
207 |
-
// }
|
208 |
}
|
209 |
|
210 |
return $choiceaiResponse;
|
35 |
if (is_null($sorts) || !isset($sorts) || !is_array($sorts) || !sizeof($sorts) > 0) {
|
36 |
return '';
|
37 |
}
|
|
|
38 |
foreach ($sorts as $sortKey => $sortValue) {
|
39 |
+
if($sortKey)
|
40 |
+
$sortString = "&caiSortBy=".$sortKey;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
}
|
|
|
42 |
return $sortString;
|
43 |
}
|
44 |
|
119 |
$context = stream_context_create($opts);
|
120 |
$response = file_get_contents($url, false, $context);
|
121 |
|
|
|
|
|
122 |
$choiceaiResponse = null;
|
123 |
if (isset($response)) {
|
124 |
$response = Mage::helper('core')->jsonDecode($response);
|
125 |
+
$uidData = $response['uid'];
|
126 |
+
if (isset($uidData)) {
|
127 |
+
$uid = explode( ',', $uidData );
|
128 |
+
Mage::register("caiuid",$uid[0],true);
|
129 |
+
}
|
130 |
|
131 |
$data = $response['data'];
|
132 |
|
172 |
|
173 |
$choiceaiResponse = new ChoiceAI_ResultSet($data);
|
174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
}
|
176 |
|
177 |
return $choiceaiResponse;
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>choiceai</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">osl</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Choice AI</summary>
|
10 |
<description>Choice AI</description>
|
11 |
-
<notes>
|
12 |
<authors><author><name>MineWhat Inc.</name><user>rahulb14</user><email>rahulb14@gmail.com</email></author><author><name>MineWhat Inc.</name><user>harkirat</user><email>harkirat1892@gmail.com</email></author></authors>
|
13 |
-
<date>2017-07-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="ChoiceAI"><dir name="Personalisation"><dir name="Block"><dir name="Base"><file name="Script.php" hash="af614113dea10a0a6d88281f615f1929"/></dir><dir name="Event"><dir name="Analytics"><file name="Listpage.php" hash="ebffb194cccf7fab9d6db59028bc7551"/><file name="Search.php" hash="6276c882a46630f77870a262cc158dfd"/></dir><dir name="Catalog"><dir name="Product"><file name="View.php" hash="233ac45484c22ecdf7063071406f71e2"/></dir></dir><dir name="Checkout"><dir name="Cart"><file name="Index.php" hash="e3bc31a08a994d72223d78ebde8a74f0"/></dir><dir name="Onepage"><file name="Success.php" hash="cc242d118e6b06bb3817d95b2322167c"/></dir></dir></dir><dir name="Searchpage"><file name="Addparam.php" hash="895157cf5ac87c294ab18c7b52412082"/></dir></dir><dir name="Helper"><file name="Data.php" hash="8ab9069ffe5aa66ef085124b8ff613d6"/></dir><dir name="Model"><file name="Observer.php" hash="3abfad9965e29886992d6c2e29bd5533"/></dir><dir name="controllers"><file name="ApiController.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.5</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>choiceai</name>
|
4 |
+
<version>1.0.11</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">osl</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Choice AI</summary>
|
10 |
<description>Choice AI</description>
|
11 |
+
<notes>Choice AI plugin</notes>
|
12 |
<authors><author><name>MineWhat Inc.</name><user>rahulb14</user><email>rahulb14@gmail.com</email></author><author><name>MineWhat Inc.</name><user>harkirat</user><email>harkirat1892@gmail.com</email></author></authors>
|
13 |
+
<date>2017-07-12</date>
|
14 |
+
<time>10:45:08</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="ChoiceAI"><dir name="Personalisation"><dir name="Block"><dir name="Base"><file name="Script.php" hash="af614113dea10a0a6d88281f615f1929"/></dir><dir name="Event"><dir name="Analytics"><file name="Listpage.php" hash="ebffb194cccf7fab9d6db59028bc7551"/><file name="Search.php" hash="6276c882a46630f77870a262cc158dfd"/></dir><dir name="Catalog"><dir name="Product"><file name="View.php" hash="233ac45484c22ecdf7063071406f71e2"/></dir></dir><dir name="Checkout"><dir name="Cart"><file name="Index.php" hash="e3bc31a08a994d72223d78ebde8a74f0"/></dir><dir name="Onepage"><file name="Success.php" hash="cc242d118e6b06bb3817d95b2322167c"/></dir></dir></dir><dir name="Searchpage"><file name="Addparam.php" hash="895157cf5ac87c294ab18c7b52412082"/></dir></dir><dir name="Helper"><file name="Data.php" hash="8ab9069ffe5aa66ef085124b8ff613d6"/></dir><dir name="Model"><file name="Observer.php" hash="3abfad9965e29886992d6c2e29bd5533"/></dir><dir name="controllers"><file name="ApiController.php" hash="3ad0f7703052cc8a7f306ab615e4de87"/></dir><dir name="etc"><file name="adminhtml.xml" hash="2fc12bb0874c8f39963f1593b3954d2e"/><file name="config.xml" hash="f743d8ead3776891503ff368ad7e7330"/><file name="system.xml" hash="6f4674088b4c392cc06f5a70f383fd54"/></dir></dir></dir></target><target name="magelocal"><dir name="ChoiceAI"><dir name="Search"><dir name="Block"><dir name="Catalog"><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="7920f693a41c71120640e58e425774c4"/><file name="Boolean.php" hash="b4725e9e63c54a5f06e226b2ba07423c"/><file name="Category.php" hash="f9add3a866fd08695fb8541292e345b5"/><file name="Decimal.php" hash="90b1f1b0e78c9fb8192affd726306939"/><file name="Price.php" hash="8a5219290c7773300725e99931dd265e"/></dir><file name="View.php" hash="e6698a73b03ab006859d4788fd770f66"/></dir><dir name="Product"><dir name="List"><file name="Toolbar.php" hash="04fba36c5a57f409b56659a2ba8fb645"/></dir><file name="List.php" hash="3e0b59fca7f65b0d3f6a130eefb801b8"/></dir></dir><dir name="Catalogsearch"><dir name="Enterprise"><file name="Layer.php" hash="76d2e136cfd2bdb8336bebc3e949035b"/></dir><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="5d8377049114d7114468d083a06ae574"/></dir></dir><file name="Layer.php" hash="5cff5c396d96294cea2291b0f5f1b9d1"/><file name="Result.php" hash="28d419708e65be095a3905e0cdcdd56d"/></dir></dir><dir name="Helper"><file name="Choiceaisearch.php" hash="052795ea39da743fb0bf77f848b3123a"/><file name="Data.php" hash="1e1d8143831abc6ab7db8363ec34ed02"/><file name="Productimg.php" hash="7def046ff081389229b33285d2dbe6a5"/></dir><dir name="Model"><dir name="Catalog"><file name="Category.php" hash="d2898da3c579c4a8c6aba8ffa9f92e5c"/><file name="Config.php" hash="29bd684be415dfb46a562c4a18ebf93f"/><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="67b32680a7471e7a5d2ea210b6c9d612"/><file name="Boolean.php" hash="4de1790d8a6355c512b0a1aee663b8aa"/><file name="Category.php" hash="597c8b4fc8c5ca892456a799302a09a4"/><file name="Decimal.php" hash="fe9ae194e4540352fc7953d6988b09bb"/><file name="Price.php" hash="3c1e0e58d4b6995c3ca66ba6ed9c5987"/></dir></dir><file name="Layer.php" hash="21673a913e8510804df7906f881d7054"/><dir name="Product"><file name="Url.php" hash="13545877391be6a0fbd1b624d43b80f5"/></dir></dir><dir name="Catalogsearch"><dir name="Layer"><dir name="Filter"><file name="Attribute.php" hash="0c08443cd3a964853e2eea7eab7ee550"/></dir></dir><file name="Layer.php" hash="7eb444d700b64d9655d9f5228c995688"/></dir><dir name="Resource"><dir name="Catalog"><dir name="Product"><file name="Collection.php" hash="1976dd848282e00158cabd6d7cf1528f"/></dir></dir><dir name="Engine"><file name="Abstract.php" hash="73c32a6e987875060d1d89692a34444b"/><dir name="Choiceaisearch"><file name="Client.php" hash="384c7d4597140b49912cc6633c4b3a8e"/></dir><file name="Choiceaisearch.php" hash="62c8e4d17fb6870ca3db292761663f13"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="67c129e2fe2159ee911991bba6e0d83f"/></dir></dir><dir name="Searchcore"><dir name="Helper"><file name="Constants.php" hash="aa53ac5d6cdc26e297d36c685cf1217c"/><file name="Data.php" hash="9df2c1f96a67c708bb039dbaf8f9b4d8"/></dir><dir name="etc"><file name="config.xml" hash="5a625a66e36ad56ea606100a2eb29908"/></dir></dir></dir></target><target name="magelib"><dir name="ChoiceAI"><file name="Client.php" hash="e6dfb5d68108d30dea6cf2055337f782"/><file name="Result.php" hash="b95b62cd11facae7f8318ad9e433cb42"/><file name="ResultSet.php" hash="228a8f2bca65527e3c3c68e49357339d"/><file name="Service.php" hash="d043d08a48f8adc760e0306a3c000ebf"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="choiceai_personalisation.xml" hash="3f4490bde0510aa3752a51c602451d6c"/></dir><dir name="template"><dir name="choiceai"><dir name="personalisation"><dir name="analytics"><file name="listpage.phtml" hash="ac19a29e9ffb58f5056e1a7a968a626d"/><file name="search.phtml" hash="c7bc6540408024d048c6531d45d4807b"/></dir><dir name="base"><file name="addparam.phtml" hash="e9b7447c5ae2983796ab28c622d3684e"/><file name="script.phtml" hash="96c9deb93d5cbe8ba6a1c0266d928579"/></dir><dir name="event"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="9513eaaa0bda55931dacb6d90b698f31"/></dir></dir><dir name="checkout"><dir name="cart"><file name="index.phtml" hash="6a27ac509cc1c8c78515b025479f135b"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="default"><dir name="default"><dir name="layout"><file name="choiceai_personalisation.xml" hash="95d72912f3b13c5a399e3b2e5b89dba9"/></dir><dir name="template"><dir name="choiceai"><dir name="personalisation"><dir name="base"><file name="script.phtml" hash="60b414f870c4b5bd761bfa2466d73707"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ChoiceAI_Personalisation.xml" hash="4bca20179604835e2e0e08298142c8bb"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.5</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|