Version Notes
First public release
Download this release
Release Info
Developer | Niels - Rejuni |
Extension | wiser_search |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Wiser/Search/Helper/Data.php +7 -0
- app/code/community/Wiser/Search/Helper/ProductData.php +98 -0
- app/code/community/Wiser/Search/Helper/SimpleXml.php +22 -0
- app/code/community/Wiser/Search/Helper/XmlFeed.php +41 -0
- app/code/community/Wiser/Search/Model/Observer.php +158 -0
- app/code/community/Wiser/Search/controllers/IndexController.php +130 -0
- app/code/community/Wiser/Search/etc/config.xml +96 -0
- app/code/community/Wiser/Search/etc/system.xml +75 -0
- app/design/frontend/base/default/layout/wiser_search.xml +12 -0
- app/design/frontend/base/default/template/wiser_search/conversion.phtml +1 -0
- app/etc/modules/Wiser_Search.xml +9 -0
- package.xml +18 -0
app/code/community/Wiser/Search/Helper/Data.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Wiser_Search_Helper_Data extends Mage_Core_Helper_Abstract {
|
4 |
+
|
5 |
+
}
|
6 |
+
|
7 |
+
?>
|
app/code/community/Wiser/Search/Helper/ProductData.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Wiser_Search_Helper_ProductData
|
3 |
+
{
|
4 |
+
|
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;
|
11 |
+
$Data['storeid'] = $storeId;
|
12 |
+
$Data['title']=$Product->getName();
|
13 |
+
$Data['description']=strip_tags($Product->getDescription());
|
14 |
+
$Data['price']=$Product->getPrice();
|
15 |
+
$Data['special_price']=$Product->getSpecialPrice();
|
16 |
+
$Data['link']=$Product->getProductUrl();
|
17 |
+
$Data['image_link']= $Product->getImage() == "no_selection" ? "" : Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$Product->getImage();
|
18 |
+
$Data['image_link_medium']= $Product->getImage() == "no_selection" ? "" : (string) Mage::helper('catalog/image')->init( $Product, 'image')->resize(320, 320);
|
19 |
+
$Data['category'] = $Cats['main'];
|
20 |
+
$Data['subcategory'] = $Cats['sub'];
|
21 |
+
$Data['brand']=$Product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($Product);
|
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 |
+
|
29 |
+
$attributes = $Product->getAttributes();
|
30 |
+
|
31 |
+
foreach ($attributes as $attribute)
|
32 |
+
{
|
33 |
+
//if ($attribute->getIsFilterable())
|
34 |
+
//{
|
35 |
+
if ($attribute->getFrontend()->getConfigField('input')=='multiselect') {
|
36 |
+
$value = $attribute->getFrontend()->getOption($Product->getData($attribute->getAttributeCode()));
|
37 |
+
if (is_array($value)) {
|
38 |
+
$value = implode('~', $value);
|
39 |
+
}
|
40 |
+
$Data[$attribute->getAttributeCode()] = $value;
|
41 |
+
} else {
|
42 |
+
$Data[$attribute->getAttributeCode()] = $attribute->getFrontend()->getValue($Product);
|
43 |
+
}
|
44 |
+
//}
|
45 |
+
}
|
46 |
+
|
47 |
+
if($Data['special_price'] == '')
|
48 |
+
{
|
49 |
+
$Data['special_price'] = $Data['price'];
|
50 |
+
}
|
51 |
+
|
52 |
+
return $Data;
|
53 |
+
}
|
54 |
+
|
55 |
+
public static function _getCategories($Product, $storeId)
|
56 |
+
{
|
57 |
+
$Ids = $Product->getCategoryIds();
|
58 |
+
|
59 |
+
$Categories = array();
|
60 |
+
|
61 |
+
$main = array();
|
62 |
+
$sub = array();
|
63 |
+
|
64 |
+
foreach($Ids as $Category)
|
65 |
+
{
|
66 |
+
$CategoryModel = Mage::getModel('catalog/category')->setStoreId($storeId)->load($Category);
|
67 |
+
/*if ($CategoryModel->getLevel() != '3' && $CategoryModel->getLevel() != '4')
|
68 |
+
{
|
69 |
+
continue;
|
70 |
+
}
|
71 |
+
*/
|
72 |
+
$catnames = array();
|
73 |
+
|
74 |
+
foreach ($CategoryModel->getParentCategories() as $parent) {
|
75 |
+
$catnames[] = $parent->getName();
|
76 |
+
}
|
77 |
+
|
78 |
+
if(count($catnames) > 0 ){
|
79 |
+
array_push($main, $catnames[0]);
|
80 |
+
} else {
|
81 |
+
array_push($main, "");
|
82 |
+
}
|
83 |
+
if(count($catnames) > 1 ){
|
84 |
+
array_push($sub, $catnames[1]);
|
85 |
+
} else {
|
86 |
+
array_push($sub, "");
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
$Categories['main'] = implode("~", $main);
|
91 |
+
$Categories['sub'] = implode("~", $sub);
|
92 |
+
|
93 |
+
|
94 |
+
return $Categories;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
?>
|
app/code/community/Wiser/Search/Helper/SimpleXml.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Wiser_Search_Helper_SimpleXml extends SimpleXMLElement
|
4 |
+
{
|
5 |
+
|
6 |
+
public function add_cdata( $cdata_text )
|
7 |
+
{
|
8 |
+
$node = dom_import_simplexml( $this );
|
9 |
+
$no = $node->ownerDocument;
|
10 |
+
$node->appendChild( $no->createCDATASection( $cdata_text ) );
|
11 |
+
}
|
12 |
+
|
13 |
+
public function as_formated_xml()
|
14 |
+
{
|
15 |
+
$xml_string = $this->asXML();
|
16 |
+
$dom = new DOMDocument( '1.0', 'UTF-8' );
|
17 |
+
$dom->loadXML( $xml_string );
|
18 |
+
$dom->preserveWhiteSpace = FALSE;
|
19 |
+
$dom->formatOutput = TRUE;
|
20 |
+
return $dom->saveXML();
|
21 |
+
}
|
22 |
+
}
|
app/code/community/Wiser/Search/Helper/XmlFeed.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Wiser_Search_Helper_XmlFeed
|
3 |
+
{
|
4 |
+
|
5 |
+
public function build_xml(array $products, array $configuration, $products_name = "product")
|
6 |
+
{
|
7 |
+
$xml_feed = new Wiser_Search_Helper_SimpleXml('<?xml version="1.0" encoding="UTF-8"?><data></data>');
|
8 |
+
$configurationXML = $xml_feed->addChild('configuration');
|
9 |
+
|
10 |
+
$this->_add_product_fields($configurationXML, $configuration);
|
11 |
+
|
12 |
+
$productsXML = $xml_feed->addChild($products_name . "s");
|
13 |
+
foreach ($products as $product)
|
14 |
+
{
|
15 |
+
$xml_product = $productsXML->addChild($products_name);
|
16 |
+
$xml_product = $this->_add_product_fields($xml_product, $product);
|
17 |
+
}
|
18 |
+
|
19 |
+
return $xml_feed->as_formated_xml();
|
20 |
+
}
|
21 |
+
|
22 |
+
private function _add_product_fields($xml_product, $product_fields)
|
23 |
+
{
|
24 |
+
foreach($product_fields as $field_name => $field_value)
|
25 |
+
{
|
26 |
+
$field_value = $this->_clean_string($field_value);
|
27 |
+
$product = $xml_product->addChild($field_name, NULL);
|
28 |
+
$product->add_cdata($field_value);
|
29 |
+
}
|
30 |
+
|
31 |
+
return $xml_product;
|
32 |
+
}
|
33 |
+
|
34 |
+
private function _clean_string($string)
|
35 |
+
{
|
36 |
+
$string = strip_tags($string);
|
37 |
+
$string = str_replace(array('"',"\r\n","\n","\r","\t"), array(""," "," "," ",""), $string);
|
38 |
+
return $string;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
?>
|
app/code/community/Wiser/Search/Model/Observer.php
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Wiser_Search_Model_Observer
|
3 |
+
{
|
4 |
+
private $_Products;
|
5 |
+
private $_ProductIds;
|
6 |
+
|
7 |
+
public function cacheRefreshType($observer) {
|
8 |
+
$stores = Mage::app()->getStores();
|
9 |
+
|
10 |
+
foreach ($stores as $store)
|
11 |
+
{
|
12 |
+
$storeId = $store->getStoreId();
|
13 |
+
$Feed = new Wiser_Search_Helper_XmlFeed();
|
14 |
+
$_Products = array();
|
15 |
+
$_Configuration = array();
|
16 |
+
|
17 |
+
// Product feed
|
18 |
+
$this->_buildProductsArray($storeId);
|
19 |
+
|
20 |
+
foreach($this->_ProductIds as $iProduct)
|
21 |
+
{
|
22 |
+
array_push($_Products, Wiser_Search_Helper_ProductData::_getProductData($iProduct, $storeId));
|
23 |
+
}
|
24 |
+
|
25 |
+
$xmlFeed = $Feed->build_xml($_Products, $_Configuration);
|
26 |
+
|
27 |
+
// API Call to push XML to Webhook
|
28 |
+
$this->webhookUpdateProduct($xmlFeed, "POST");
|
29 |
+
}
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
private function _buildProductsArray($storeId)
|
34 |
+
{
|
35 |
+
$this->_Products = Mage::getModel('catalog/product')->setStoreId($storeId)->getCollection();
|
36 |
+
$this->_Products->addAttributeToFilter('status', 1);//enabled
|
37 |
+
$this->_Products->addAttributeToFilter('visibility', array('gt' => 2));// search only OR catalog, search
|
38 |
+
$this->_Products->addAttributeToSelect('*');
|
39 |
+
$this->_ProductIds = $this->_Products->getAllIds();
|
40 |
+
}
|
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) {
|
62 |
+
$product = $observer->getProduct();
|
63 |
+
|
64 |
+
$Feed = new Wiser_Search_Helper_XmlFeed();
|
65 |
+
$_Products = array(array("id" => $product->getId()));
|
66 |
+
$_Configuration = array();
|
67 |
+
|
68 |
+
$xmlFeed = $Feed->build_xml($_Products, $_Configuration);
|
69 |
+
|
70 |
+
// API Call to push XML to Webhook
|
71 |
+
$this->webhookUpdateProduct($xmlFeed, "DELETE");
|
72 |
+
}
|
73 |
+
|
74 |
+
public function validateConfiguration($observer) {
|
75 |
+
// Not yet installed, and login to backend
|
76 |
+
if( Mage::getSingleton('admin/session')->getUser() !== NULL && Mage::getStoreConfig('wiser_search/wiser_search_group/installed') !== "1") {
|
77 |
+
//
|
78 |
+
$this->callInstallUrl();
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
private function callInstallUrl(){
|
83 |
+
$target_url = "http://search.wiser.nl/wisersearch_webhook.aspx";
|
84 |
+
|
85 |
+
$user = Mage::getSingleton('admin/session')->getUser();
|
86 |
+
|
87 |
+
$post = array(
|
88 |
+
'firstname' => $user->getFirstname(),
|
89 |
+
'lastname' => $user->getLastname(),
|
90 |
+
'email' => $user->getEmail(),
|
91 |
+
'domain' => Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB),
|
92 |
+
'feed_url' => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK) . "wiser_search/"
|
93 |
+
);
|
94 |
+
|
95 |
+
$header = array(
|
96 |
+
// "Authorization: Basic " . base64_encode( $apikey . ":" ),
|
97 |
+
);
|
98 |
+
|
99 |
+
$ch = curl_init();
|
100 |
+
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
|
101 |
+
curl_setopt($ch, CURLOPT_URL,$target_url);
|
102 |
+
curl_setopt($ch, CURLOPT_POST,1);
|
103 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
104 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
105 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
|
106 |
+
|
107 |
+
$result=curl_exec ($ch);
|
108 |
+
|
109 |
+
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
110 |
+
|
111 |
+
curl_close ($ch);
|
112 |
+
|
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 |
+
|
126 |
+
private function webhookUpdateProduct( $feed, $type ) {
|
127 |
+
$target_url = Mage::getStoreConfig('wiser_search/wiser_search_group/webhook');
|
128 |
+
|
129 |
+
$header = array(
|
130 |
+
"Authorization: Basic " . base64_encode( Mage::getStoreConfig('wiser_search/wiser_search_group/api_key') . ":" ),
|
131 |
+
"Content-type: text/plain"
|
132 |
+
);
|
133 |
+
|
134 |
+
$ch = curl_init();
|
135 |
+
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
|
136 |
+
curl_setopt($ch, CURLOPT_URL,$target_url);
|
137 |
+
if( $type == "DELETE" ) {
|
138 |
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
|
139 |
+
} else {
|
140 |
+
curl_setopt($ch, CURLOPT_POST,1);
|
141 |
+
}
|
142 |
+
|
143 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
144 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $feed);
|
145 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
|
146 |
+
|
147 |
+
$result=curl_exec ($ch);
|
148 |
+
|
149 |
+
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
150 |
+
|
151 |
+
curl_close ($ch);
|
152 |
+
|
153 |
+
if( $status == 200) {
|
154 |
+
}
|
155 |
+
|
156 |
+
}
|
157 |
+
}
|
158 |
+
?>
|
app/code/community/Wiser/Search/controllers/IndexController.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Wiser_Search_IndexController extends Mage_Core_Controller_Front_Action {
|
3 |
+
private $_Products;
|
4 |
+
private $_ProductIds;
|
5 |
+
|
6 |
+
public function indexAction()
|
7 |
+
{
|
8 |
+
set_time_limit(3600);
|
9 |
+
|
10 |
+
$auth = $this -> getRequest() -> getHeader('Authorization');
|
11 |
+
|
12 |
+
if( $auth !== false) {
|
13 |
+
$authData = explode(" ", $auth);
|
14 |
+
$user = explode(":", base64_decode($authData[1]));
|
15 |
+
|
16 |
+
if( $user[0] == Mage::getStoreConfig('wiser_search/wiser_search_group/api_key')) {
|
17 |
+
$Feed = new Wiser_Search_Helper_XmlFeed();
|
18 |
+
$_Products = array();
|
19 |
+
$_Configuration = array();
|
20 |
+
|
21 |
+
if( isset($_GET['store'] )) {
|
22 |
+
$storeId = (int)$_GET['store'];
|
23 |
+
|
24 |
+
if( isset($_GET['mode']) && $_GET['mode'] == 'content' ) {
|
25 |
+
// Content / blog feed
|
26 |
+
|
27 |
+
$helper = Mage::helper('cms');
|
28 |
+
$processor = $helper->getPageTemplateProcessor();
|
29 |
+
|
30 |
+
foreach( Mage::getModel('cms/page')->setStoreId($storeId)->getCollection() as $iPage ){
|
31 |
+
$_Page = array();
|
32 |
+
|
33 |
+
$_Page['id'] = $iPage->getId();
|
34 |
+
|
35 |
+
$_Page['created_at'] = $iPage->getCreationTime();
|
36 |
+
$_Page['updated_at'] = $iPage->getUpdateTime();
|
37 |
+
$_Page['active'] = $iPage->getIsActive();
|
38 |
+
$_Page['sort'] = $iPage->getSortOrder();
|
39 |
+
|
40 |
+
$_Page['title'] = $iPage->getTitle();
|
41 |
+
$_Page['description'] = $iPage->getMetaDescription();
|
42 |
+
$_Page['keywords'] = $iPage->getMetaKeywords();
|
43 |
+
|
44 |
+
$_Page['content'] = $processor->filter($iPage->getContent());
|
45 |
+
//$iPage->getIdentifier()
|
46 |
+
$_Page['url'] = Mage::helper('cms/page')->getPageUrl($iPage->getId());
|
47 |
+
|
48 |
+
array_push($_Products,$_Page);
|
49 |
+
}
|
50 |
+
$xmlFeed = $Feed->build_xml($_Products, $_Configuration, "page");
|
51 |
+
} else {
|
52 |
+
// Product feed
|
53 |
+
$this->_buildProductsArray($storeId);
|
54 |
+
|
55 |
+
foreach($this->_ProductIds as $iProduct)
|
56 |
+
{
|
57 |
+
array_push($_Products, Wiser_Search_Helper_ProductData::_getProductData($iProduct, $storeId));
|
58 |
+
}
|
59 |
+
|
60 |
+
//$store = Mage::getModel('core/store')->load($storeId);
|
61 |
+
|
62 |
+
$xmlFeed = $Feed->build_xml($_Products, $_Configuration);
|
63 |
+
}
|
64 |
+
|
65 |
+
} else {
|
66 |
+
// Store feed
|
67 |
+
$stores = Mage::app()->getStores();
|
68 |
+
foreach ($stores as $store)
|
69 |
+
{
|
70 |
+
$_Store = array();
|
71 |
+
|
72 |
+
// Gets the current store's id
|
73 |
+
$_Store['id'] = $store->getStoreId();
|
74 |
+
|
75 |
+
// Gets the current store's code
|
76 |
+
$_Store['code'] = $store->getCode();
|
77 |
+
|
78 |
+
// Gets the current website's id
|
79 |
+
$_Store['websiteid'] = $store->getWebsiteId();
|
80 |
+
|
81 |
+
// Gets the current store's group id
|
82 |
+
$_Store['groupid'] = $store->getGroupId();
|
83 |
+
|
84 |
+
// Gets the current store's name
|
85 |
+
$_Store['name'] = $store->getFrontendName();
|
86 |
+
|
87 |
+
// Gets the current store's sort order
|
88 |
+
$_Store['sort'] = $store->getSortOrder();
|
89 |
+
|
90 |
+
// Gets the current store's status
|
91 |
+
$_Store['active'] = $store->getIsActive();
|
92 |
+
|
93 |
+
// Gets the current store's locale
|
94 |
+
$_Store['locale'] = substr(Mage::getStoreConfig('general/locale/code', $store->getId()),0,2);
|
95 |
+
|
96 |
+
// Gets the current store's home url
|
97 |
+
$_Store['productfeed'] = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK) . "wiser_search/?store=" . $store->getStoreId();
|
98 |
+
$_Store['contentfeed'] = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK) . "wiser_search/?store=" . $store->getStoreId() ."&mode=content";
|
99 |
+
|
100 |
+
$_Store['currency'] = $store->getCurrentCurrencyCode();
|
101 |
+
|
102 |
+
array_push($_Products, $_Store);
|
103 |
+
}
|
104 |
+
|
105 |
+
$xmlFeed = $Feed->build_xml($_Products, $_Configuration, "shop");
|
106 |
+
}
|
107 |
+
|
108 |
+
$this->_sendHeader();
|
109 |
+
echo $xmlFeed;
|
110 |
+
exit();
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
$this->getResponse()->setHttpResponseCode(401);
|
115 |
+
}
|
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('*');
|
123 |
+
$this->_ProductIds = $this->_Products->getAllIds();
|
124 |
+
}
|
125 |
+
|
126 |
+
private function _sendHeader()
|
127 |
+
{
|
128 |
+
header('Content-type: text/xml');
|
129 |
+
}
|
130 |
+
}
|
app/code/community/Wiser/Search/etc/config.xml
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Wiser_Search>
|
5 |
+
<version>0.1.1</version>
|
6 |
+
</Wiser_Search>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<helpers>
|
10 |
+
<wiser_search>
|
11 |
+
<class>Wiser_Search_Helper</class>
|
12 |
+
</wiser_search>
|
13 |
+
</helpers>
|
14 |
+
<events>
|
15 |
+
<controller_action_layout_render_before>
|
16 |
+
<observers>
|
17 |
+
<search>
|
18 |
+
<type>singleton</type>
|
19 |
+
<class>Wiser_Search_Model_Observer</class>
|
20 |
+
<method>validateConfiguration</method>
|
21 |
+
</search>
|
22 |
+
</observers>
|
23 |
+
</controller_action_layout_render_before>
|
24 |
+
<catalog_product_save_commit_after>
|
25 |
+
<observers>
|
26 |
+
<search>
|
27 |
+
<type>singleton</type>
|
28 |
+
<class>Wiser_Search_Model_Observer</class>
|
29 |
+
<method>productAfterSave</method>
|
30 |
+
</search>
|
31 |
+
</observers>
|
32 |
+
</catalog_product_save_commit_after>
|
33 |
+
<catalog_product_delete_after>
|
34 |
+
<observers>
|
35 |
+
<search>
|
36 |
+
<type>singleton</type>
|
37 |
+
<class>Wiser_Search_Model_Observer</class>
|
38 |
+
<method>productAfterDelete</method>
|
39 |
+
</search>
|
40 |
+
</observers>
|
41 |
+
</catalog_product_delete_after>
|
42 |
+
|
43 |
+
<clean_catalog_images_cache_after>
|
44 |
+
<observers>
|
45 |
+
<search>
|
46 |
+
<type>singleton</type>
|
47 |
+
<class>Wiser_Search_Model_Observer</class>
|
48 |
+
<method>cacheRefreshType</method>
|
49 |
+
</search>
|
50 |
+
</observers>
|
51 |
+
</clean_catalog_images_cache_after>
|
52 |
+
</events>
|
53 |
+
</global>
|
54 |
+
<frontend>
|
55 |
+
<routers>
|
56 |
+
<wiser_search>
|
57 |
+
<use>standard</use>
|
58 |
+
<args>
|
59 |
+
<module>Wiser_Search</module>
|
60 |
+
<frontName>wiser_search</frontName><!-- url name /{frontname}/ -->
|
61 |
+
</args>
|
62 |
+
</wiser_search>
|
63 |
+
</routers>
|
64 |
+
<layout>
|
65 |
+
<updates>
|
66 |
+
<wiser_search> <!--module="Wiser_Search" -->
|
67 |
+
<file>wiser_search.xml</file>
|
68 |
+
</wiser_search>
|
69 |
+
</updates>
|
70 |
+
</layout>
|
71 |
+
</frontend>
|
72 |
+
<adminhtml>
|
73 |
+
<acl>
|
74 |
+
<resources>
|
75 |
+
<all>
|
76 |
+
<title>Allow Everything</title>
|
77 |
+
</all>
|
78 |
+
<admin>
|
79 |
+
<children>
|
80 |
+
<system>
|
81 |
+
<children>
|
82 |
+
<config>
|
83 |
+
<children>
|
84 |
+
<wiser_search>
|
85 |
+
<title>Wiser All</title>
|
86 |
+
</wiser_search>
|
87 |
+
</children>
|
88 |
+
</config>
|
89 |
+
</children>
|
90 |
+
</system>
|
91 |
+
</children>
|
92 |
+
</admin>
|
93 |
+
</resources>
|
94 |
+
</acl>
|
95 |
+
</adminhtml>
|
96 |
+
</config>
|
app/code/community/Wiser/Search/etc/system.xml
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<wiser>
|
5 |
+
<label>Wiser</label>
|
6 |
+
<sort_order>100</sort_order>
|
7 |
+
</wiser>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<wiser_search>
|
11 |
+
<label>Wiser Search</label>
|
12 |
+
<tab>wiser</tab>
|
13 |
+
<sort_order>10</sort_order>
|
14 |
+
<show_in_default>1</show_in_default>
|
15 |
+
<show_in_website>1</show_in_website>
|
16 |
+
<show_in_store>1</show_in_store>
|
17 |
+
<groups>
|
18 |
+
<wiser_search_group translate="label" module="wiser_search">
|
19 |
+
<label>General</label>
|
20 |
+
<sort_order>100</sort_order>
|
21 |
+
<show_in_default>1</show_in_default>
|
22 |
+
<show_in_website>1</show_in_website>
|
23 |
+
<show_in_store>1</show_in_store>
|
24 |
+
<fields>
|
25 |
+
<customer_key translate="label">
|
26 |
+
<label>Customer Key</label>
|
27 |
+
<frontend_type>text</frontend_type>
|
28 |
+
<comment><![CDATA[ The key from Wiser Search ]]></comment>
|
29 |
+
<sort_order>0</sort_order>
|
30 |
+
<show_in_default>0</show_in_default>
|
31 |
+
<show_in_website>0</show_in_website>
|
32 |
+
<show_in_store>0</show_in_store>
|
33 |
+
</customer_key>
|
34 |
+
<api_key translate="label">
|
35 |
+
<label>API Key</label>
|
36 |
+
<frontend_type>text</frontend_type>
|
37 |
+
<comment><![CDATA[ ]]></comment>
|
38 |
+
<sort_order>0</sort_order>
|
39 |
+
<show_in_default>0</show_in_default>
|
40 |
+
<show_in_website>0</show_in_website>
|
41 |
+
<show_in_store>0</show_in_store>
|
42 |
+
</api_key>
|
43 |
+
<script translate="label">
|
44 |
+
<label>script</label>
|
45 |
+
<frontend_type>text</frontend_type>
|
46 |
+
<comment><![CDATA[ ]]></comment>
|
47 |
+
<sort_order>0</sort_order>
|
48 |
+
<show_in_default>0</show_in_default>
|
49 |
+
<show_in_website>0</show_in_website>
|
50 |
+
<show_in_store>0</show_in_store>
|
51 |
+
</script>
|
52 |
+
<webhook translate="label">
|
53 |
+
<label>webhook</label>
|
54 |
+
<frontend_type>text</frontend_type>
|
55 |
+
<comment><![CDATA[ ]]></comment>
|
56 |
+
<sort_order>0</sort_order>
|
57 |
+
<show_in_default>0</show_in_default>
|
58 |
+
<show_in_website>0</show_in_website>
|
59 |
+
<show_in_store>0</show_in_store>
|
60 |
+
</webhook>
|
61 |
+
<installed translate="label">
|
62 |
+
<label>Installed</label>
|
63 |
+
<frontend_type>text</frontend_type>
|
64 |
+
<comment><![CDATA[]]></comment>
|
65 |
+
<sort_order>0</sort_order>
|
66 |
+
<show_in_default>0</show_in_default>
|
67 |
+
<show_in_website>0</show_in_website>
|
68 |
+
<show_in_store>0</show_in_store>
|
69 |
+
</installed>
|
70 |
+
</fields>
|
71 |
+
</wiser_search_group>
|
72 |
+
</groups>
|
73 |
+
</wiser_search>
|
74 |
+
</sections>
|
75 |
+
</config>
|
app/design/frontend/base/default/layout/wiser_search.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<layout>
|
3 |
+
<default>
|
4 |
+
<reference name="before_body_end">
|
5 |
+
<block type="core/template"
|
6 |
+
name="wiser_search_conversion"
|
7 |
+
template="wiser_search/conversion.phtml">
|
8 |
+
<action method="setCacheLifetime"><s>0</s></action>
|
9 |
+
</block>
|
10 |
+
</reference>
|
11 |
+
</default>
|
12 |
+
</layout>
|
app/design/frontend/base/default/template/wiser_search/conversion.phtml
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<script><?php echo str_replace("{languageid}", Mage::app()->getStore()->getStoreId(), Mage::getStoreConfig('wiser_search/wiser_search_group/script')); ?></script>
|
app/etc/modules/Wiser_Search.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Wiser_Search>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Wiser_Search>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>
|
8 |
+
<extends/>
|
9 |
+
<summary>Quickly have your search results on screen while typing, advanced statistics and advanced layered navigation</summary>
|
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>
|