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

Commit

Permalink
Corrects searchOnApi query and product features are added as "embedde…
Browse files Browse the repository at this point in the history
…d attributes"
  • Loading branch information
ecoslado committed Sep 5, 2016
1 parent 85bf9d4 commit d0dc322
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
11 changes: 2 additions & 9 deletions dfTools.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,19 +307,12 @@ public static function getFeaturesForProduct($id_product, $id_lang, $feature_key

$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);

if(count($feature_keys) > 0){
$features = array_fill(0, count($feature_keys), array());
}
else {
$features = array();
}

$features = array_fill(0, count($feature_keys), array());
$features = array();


foreach($result as $elem){
if (in_array($elem['name'], $feature_keys))
array_push($features[array_search($elem['name'], $feature_keys)], $elem['value']);
$features[$elem['name']] = $elem['value'];
}

return $features;
Expand Down
Binary file modified dist/doofinder-p1.5-latest.zip
Binary file not shown.
8 changes: 4 additions & 4 deletions doofinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -774,8 +774,9 @@ function cb($entry){
$db = Db::getInstance(_PS_USE_SQL_SLAVE_);
$id_lang = $context->language->id;
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity,
pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`,
IF(pai.`id_image` IS NULL OR pai.`id_image` = 0, MAX(image_shop.`id_image`),pai.`id_image`) id_image, il.`legend`, m.`name` manufacturer_name '.(Combination::isFeatureActive() ? ', MAX(product_attribute_shop.`id_product_attribute`) id_product_attribute' : '').',
pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`,'.
(($show_variations)?'IF(pai.`id_image` IS NULL OR pai.`id_image` = 0, MAX(image_shop.`id_image`),pai.`id_image`) id_image, il.`legend`, m.`name` manufacturer_name '.(Combination::isFeatureActive() ? ', MAX(product_attribute_shop.`id_product_attribute`) id_product_attribute' : ''):'image_shop.`id_image` id_image, il.`legend`, m.`name` manufacturer_name '.(Combination::isFeatureActive() ? ', MAX(product_attribute_shop.`id_product_attribute`) id_product_attribute' : '')).
',
DATEDIFF(
p.`date_add`,
DATE_SUB(
Expand All @@ -793,8 +794,7 @@ function cb($entry){
'.Shop::addSqlAssociation('product_attribute', 'pa', false, '').'
'.Product::sqlStock('p', 'product_attribute_shop', false, $context->shop) : Product::sqlStock('p', 'product', false, Context::getContext()->shop)).'
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'product_attribute_image` pai ON (pai.`id_product_attribute` = product_attribute_shop.`id_product_attribute`) '.
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`) '.
Shop::addSqlAssociation('image', 'i', false, '').'
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
WHERE p.`id_product` IN ('.$product_pool.') '.
Expand Down
10 changes: 6 additions & 4 deletions feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ function slugify($text)
else
$feature_keys = $all_feature_keys;

foreach($feature_keys as $key){
/*foreach($feature_keys as $key){
$header[] = slugify($key);
}
} */
$header[] = "attributes";
}

if (!$limit || ($offset !== false && intval($offset) === 0))
Expand Down Expand Up @@ -316,8 +317,9 @@ function slugify($text)
}

if ($cfg_product_features){
foreach(dfTools::getFeaturesForProduct($row['id_product'], $lang->id, $feature_keys) as $features){
echo TXT_SEPARATOR.dfTools::cleanString(implode(' ', $features));
echo TXT_SEPARATOR;
foreach(dfTools::getFeaturesForProduct($row['id_product'], $lang->id, $feature_keys) as $key => $value){
echo slugify($key)."=$value/";
}

}
Expand Down

0 comments on commit d0dc322

Please sign in to comment.