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

Commit

Permalink
Slugify in features and variations
Browse files Browse the repository at this point in the history
  • Loading branch information
ecoslado committed Feb 2, 2016
1 parent c1227f4 commit 7e2e372
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
Binary file modified dist/doofinder-p1.5-latest.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion 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.14";
const VERSION = "2.0.15";

const YES = 1;
const NO = 0;
Expand Down
30 changes: 28 additions & 2 deletions feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,32 @@
require_once(dirname(__FILE__) . '/../../init.php');
require_once(dirname(__FILE__) . '/doofinder.php');

function slugify($text)
{
// replace non letter or digits by -
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);

// trim
$text = trim($text, '-');

// transliterate
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);

// lowercase
$text = strtolower($text);

// remove unwanted characters
$text = preg_replace('~[^-\w]+~', '', $text);

if (empty($text))
{
return 'n-a';
}

return $text;
}


$context = Context::getContext();

$shop = new Shop((int) $context->shop->id);
Expand Down Expand Up @@ -105,7 +131,7 @@
$header[] = 'variation_reference';
$attribute_keys = dfTools::getAttributeKeysForShopAndLang($shop->id, $lang->id);
foreach($attribute_keys as $key){
$header[] = $key;
$header[] = slugify($key);
}
}

Expand All @@ -118,7 +144,7 @@
$feature_keys = $all_feature_keys;

foreach($feature_keys as $key){
$header[] = $key;
$header[] = slugify($key);
}
}

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.14",
"version": "2.0.15",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.5.0",
Expand Down

0 comments on commit 7e2e372

Please sign in to comment.