Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Only shows a product datatype in search page.
Browse files Browse the repository at this point in the history
  • Loading branch information
ecoslado committed Oct 12, 2015
1 parent 3f4e292 commit a8eccac
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
Binary file modified dist/doofinder-p1.5-latest.zip
Binary file not shown.
40 changes: 21 additions & 19 deletions doofinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Doofinder extends Module

const GS_SHORT_DESCRIPTION = 1;
const GS_LONG_DESCRIPTION = 2;
const VERSION = "2.0.2";
const VERSION = "2.0.3";

const YES = 1;
const NO = 0;
Expand Down Expand Up @@ -592,28 +592,30 @@ public function searchOnApi($string,$page=1,$page_size=12,$timeout=8000){
if(!$dfResults->isOk())
return false;

$dfResultsArray = $dfResults->getResults();

$dfResultsArray = $dfResults->getResults();
global $product_pool_attributes;
$product_pool_attributes = array();
$product_pool = implode(', ', array_map(function ($entry) {
global $product_pool_attributes;
$customexplodeattr = Configuration::get('DF_CUSTOMEXPLODEATTR', null);
if(!empty($customexplodeattr) && strpos($entry['id'],$customexplodeattr)!==false){
$id_products = explode($customexplodeattr, $entry['id']);
$product_pool_attributes[] = $id_products[1];
return $id_products[0];
}
if(strpos($entry['id'],'VAR-')===false){
return $entry['id'];
}else{
$id_product_attribute = str_replace('VAR-','',$entry['id']);
if(!in_array($id_product_attribute, $product_pool_attributes)){
$product_pool_attributes[] = $id_product_attribute;
}
$id_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT id_product FROM ps_product_attribute WHERE id_product_attribute = '.$id_product_attribute);
return ((!empty($id_product)) ? $id_product : 0 );
if($entry['type'] == 'product'){
global $product_pool_attributes;
$customexplodeattr = Configuration::get('DF_CUSTOMEXPLODEATTR', null);
if(!empty($customexplodeattr) && strpos($entry['id'],$customexplodeattr)!==false){
$id_products = explode($customexplodeattr, $entry['id']);
$product_pool_attributes[] = $id_products[1];
return $id_products[0];
}
if(strpos($entry['id'],'VAR-')===false){
return $entry['id'];
}else{
$id_product_attribute = str_replace('VAR-','',$entry['id']);
if(!in_array($id_product_attribute, $product_pool_attributes)){
$product_pool_attributes[] = $id_product_attribute;
}
$id_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT id_product FROM ps_product_attribute WHERE id_product_attribute = '.$id_product_attribute);
return ((!empty($id_product)) ? $id_product : 0 );
}
}

}, $dfResultsArray));
// To avoid SQL errors.
if($product_pool == ""){
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "doofinder-for-prestashop",
"version": "2.0.2",
"version": "2.0.3",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.5.0",
Expand Down

0 comments on commit a8eccac

Please sign in to comment.