wiser_search - Version 1.0.1

Version Notes

First public release

Download this release

Release Info

Developer Niels - Rejuni
Extension wiser_search
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

app/code/community/Wiser/Search/Helper/ProductData.php CHANGED
@@ -5,6 +5,7 @@ class Wiser_Search_Helper_ProductData
5
  public static function _getProductData($ProductInput, $storeId)
6
  {
7
  $Product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($ProductInput);
 
8
  $Cats = self::_getCategories($Product, $storeId);
9
  $Data = array();
10
  $Data['id']=$ProductInput;
@@ -22,7 +23,24 @@ class Wiser_Search_Helper_ProductData
22
  if($Data['brand'] == "No") {
23
  $Data['brand'] = "";
24
  }
25
- $Data['availability']='yes';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  //$Data['shippingcost'] = $Config->general->shippingcost;
27
  //$Data['shippingtime'] = $Config->general->shippingtime;
28
 
5
  public static function _getProductData($ProductInput, $storeId)
6
  {
7
  $Product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($ProductInput);
8
+
9
  $Cats = self::_getCategories($Product, $storeId);
10
  $Data = array();
11
  $Data['id']=$ProductInput;
23
  if($Data['brand'] == "No") {
24
  $Data['brand'] = "";
25
  }
26
+
27
+ if( in_array(Mage::getModel('core/store')->load($storeId)->getWebsiteId(), $Product->getWebsiteIds() ) && $Product->getStatus() == 1 && $Product->getVisibility() > 2 ) {
28
+
29
+ $default = Mage::getStoreConfig('cataloginventory/item_options/manage_stock', Mage::app()->getStore($storeId));
30
+
31
+ if( ($Product->getStockItem()->getData("use_config_manage_stock") == 1 && $default =='0' )
32
+ || ($Product->getStockItem()->getData("use_config_manage_stock") == 1 && $default =='1' && $Product->getIsInStock())
33
+ || ($Product->getStockItem()->getData("use_config_manage_stock") == 0 && $Product->getStockItem()->getData("manage_stock") == '0' )
34
+ || ($Product->getStockItem()->getData("use_config_manage_stock") == 0 && $Product->getStockItem()->getData("manage_stock") == '1' && $Product->getIsInStock() ) ) {
35
+
36
+ $Data['availability'] = 'yes';
37
+ } else {
38
+ $Data['availability'] = 'no';
39
+ }
40
+ } else {
41
+ $Data['availability'] = 'no';
42
+ }
43
+
44
  //$Data['shippingcost'] = $Config->general->shippingcost;
45
  //$Data['shippingtime'] = $Config->general->shippingtime;
46
 
app/code/community/Wiser/Search/Model/Observer.php CHANGED
@@ -41,21 +41,21 @@ class Wiser_Search_Model_Observer
41
 
42
  public function productAfterSave($observer){
43
  $product = $observer->getProduct();
44
-
45
- $stores = Mage::app()->getStores();
46
- $Feed = new Wiser_Search_Helper_XmlFeed();
47
- $_Products = array();
48
- $_Configuration = array();
49
-
50
- foreach ($stores as $store)
51
- {
52
- array_push($_Products, Wiser_Search_Helper_ProductData::_getProductData($product->getId(), $store->getStoreId()));
53
- }
54
-
55
- $xmlFeed = $Feed->build_xml($_Products, $_Configuration);
56
-
57
- // API Call to push XML to Webhook
58
- $this->webhookUpdateProduct($xmlFeed, "POST");
59
  }
60
 
61
  public function productAfterDelete($observer) {
@@ -113,13 +113,18 @@ class Wiser_Search_Model_Observer
113
  if( $status == 200) {
114
  $data = json_decode($result);
115
 
116
- Mage::getModel('core/config')->saveConfig('wiser_search/wiser_search_group/api_key', $data->api_key);
117
- Mage::getModel('core/config')->saveConfig('wiser_search/wiser_search_group/script', $data->script);
118
- Mage::getModel('core/config')->saveConfig('wiser_search/wiser_search_group/webhook', $data->webhook);
119
-
120
- Mage::getModel('core/config')->saveConfig('wiser_search/wiser_search_group/installed', 1);
121
-
122
- Mage::app()->getStore()->resetConfig();
 
 
 
 
 
123
  }
124
  }
125
 
41
 
42
  public function productAfterSave($observer){
43
  $product = $observer->getProduct();
44
+
45
+ $stores = Mage::app()->getStores();
46
+ $Feed = new Wiser_Search_Helper_XmlFeed();
47
+ $_Products = array();
48
+ $_Configuration = array();
49
+
50
+ foreach ($stores as $store)
51
+ {
52
+ array_push($_Products, Wiser_Search_Helper_ProductData::_getProductData($product->getId(), $store->getStoreId()));
53
+ }
54
+
55
+ $xmlFeed = $Feed->build_xml($_Products, $_Configuration);
56
+
57
+ // API Call to push XML to Webhook
58
+ $this->webhookUpdateProduct($xmlFeed, "POST");
59
  }
60
 
61
  public function productAfterDelete($observer) {
113
  if( $status == 200) {
114
  $data = json_decode($result);
115
 
116
+ if( $data !== NULL ) {
117
+ Mage::getModel('core/config')->saveConfig('wiser_search/wiser_search_group/api_key', $data->api_key);
118
+ Mage::getModel('core/config')->saveConfig('wiser_search/wiser_search_group/script', $data->script);
119
+ Mage::getModel('core/config')->saveConfig('wiser_search/wiser_search_group/webhook', $data->webhook);
120
+
121
+ Mage::getModel('core/config')->saveConfig('wiser_search/wiser_search_group/installed', 1);
122
+
123
+ $stores = Mage::app()->getStores();
124
+ foreach ($stores as $store) {
125
+ $store->resetConfig();
126
+ }
127
+ }
128
  }
129
  }
130
 
app/code/community/Wiser/Search/controllers/IndexController.php CHANGED
@@ -116,7 +116,7 @@ class Wiser_Search_IndexController extends Mage_Core_Controller_Front_Action {
116
 
117
  private function _buildProductsArray($storeId)
118
  {
119
- $this->_Products = Mage::getModel('catalog/product')->setStoreId($storeId)->getCollection();
120
  $this->_Products->addAttributeToFilter('status', 1);//enabled
121
  $this->_Products->addAttributeToFilter('visibility', array('gt' => 2));// search only OR catalog, search
122
  $this->_Products->addAttributeToSelect('*');
116
 
117
  private function _buildProductsArray($storeId)
118
  {
119
+ $this->_Products = Mage::getModel('catalog/product')->getCollection()->setStoreId($storeId)->addWebsiteFilter(Mage::getModel('core/store')->load($storeId)->getWebsiteId());
120
  $this->_Products->addAttributeToFilter('status', 1);//enabled
121
  $this->_Products->addAttributeToFilter('visibility', array('gt' => 2));// search only OR catalog, search
122
  $this->_Products->addAttributeToSelect('*');
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>wiser_search</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/gpl-license.php">GPL</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>Show search results to your customers while typing, indexes both products and pages. Allows the webshop administrator to view advanced search statistics.</description>
11
  <notes>First public release</notes>
12
  <authors><author><name>Niels - Rejuni</name><user>niels</user><email>niels@rejuni.nl</email></author><author><name>Remco - Rejuni</name><user>remco</user><email>remco@rejuni.nl</email></author></authors>
13
- <date>2016-01-23</date>
14
- <time>12:34:40</time>
15
- <contents><target name="magecommunity"><dir name="Wiser"><dir name="Search"><dir name="Helper"><file name="Data.php" hash="d127ac82b4dd20580f24d1bdc0eb9349"/><file name="ProductData.php" hash="ca0faf66410e862ec458ab305af84822"/><file name="SimpleXml.php" hash="ee3906507dd83a9b540e5fb2afaf767e"/><file name="XmlFeed.php" hash="431fab80f1db76b0594f9a7daab9d9c5"/></dir><dir name="Model"><file name="Observer.php" hash="c8f5624ddc0eff63d1aaae38d4931e10"/></dir><dir name="controllers"><file name="IndexController.php" hash="5b62b72046219455d4be798c3e36e6d8"/></dir><dir name="etc"><file name="config.xml" hash="882ea88ebe19af202f3c56ea23397dad"/><file name="system.xml" hash="89c471d8aa5eeeb294f9c2b272f5ac56"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Wiser_Search.xml" hash="4a518f78635b9e09b5b907a096b1ae91"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="wiser_search.xml" hash="f66cf33d0e88676e86bba6f0c561e485"/></dir><dir name="template"><dir name="wiser_search"><file name="conversion.phtml" hash="a5538d15d4f43989a2513b3449258dec"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
- <dependencies><required><php><min>5.4.0</min><max>7.0.2.</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>wiser_search</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/gpl-license.php">GPL</license>
7
  <channel>community</channel>
10
  <description>Show search results to your customers while typing, indexes both products and pages. Allows the webshop administrator to view advanced search statistics.</description>
11
  <notes>First public release</notes>
12
  <authors><author><name>Niels - Rejuni</name><user>niels</user><email>niels@rejuni.nl</email></author><author><name>Remco - Rejuni</name><user>remco</user><email>remco@rejuni.nl</email></author></authors>
13
+ <date>2016-01-28</date>
14
+ <time>20:03:56</time>
15
+ <contents><target name="magecommunity"><dir name="Wiser"><dir name="Search"><dir name="Helper"><file name="Data.php" hash="d127ac82b4dd20580f24d1bdc0eb9349"/><file name="ProductData.php" hash="0b8ea9b331da3519c00a94456b2a282e"/><file name="SimpleXml.php" hash="ee3906507dd83a9b540e5fb2afaf767e"/><file name="XmlFeed.php" hash="431fab80f1db76b0594f9a7daab9d9c5"/></dir><dir name="Model"><file name="Observer.php" hash="d2186e3c03b3495cf6dd7d0b326a5bcb"/></dir><dir name="controllers"><file name="IndexController.php" hash="ddeb352e71549813d5aa2c3de183524a"/></dir><dir name="etc"><file name="config.xml" hash="882ea88ebe19af202f3c56ea23397dad"/><file name="system.xml" hash="89c471d8aa5eeeb294f9c2b272f5ac56"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Wiser_Search.xml" hash="4a518f78635b9e09b5b907a096b1ae91"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="wiser_search.xml" hash="f66cf33d0e88676e86bba6f0c561e485"/></dir><dir name="template"><dir name="wiser_search"><file name="conversion.phtml" hash="a5538d15d4f43989a2513b3449258dec"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.4.0.</min><max>7.0.2.</max></php></required></dependencies>
18
  </package>