PrestaShop Forum

The best place in the world to ask questions about PrestaShop and get advice from our passionate community!

PrestaShop Forum

Jump to content

 

Edit Features order list

64 replies to this topic
#1
minh

    PrestaShop Apprentice

  • Members
  • PipPip
  • 96 posts
Is it possible to edit the order in which the product Features appears in the Data Sheet?

Example: In Admin I have the follow Features availble (in this order):

Height
Width
Depth
Weight
Size
Diameter
Form
Length

When I put in values for Height, Size, Diameter and Form they appear in this order in the Shop:

Size
Height
Form
Diameter

Why? And is it possible to edit this? Btw, using 1.1 Final.

MINH DECOR

- proudly powered by PrestaShop

MINH BLOG

- proudly powered by Wordpress

#2
TropischBruin

    PrestaShop Fanatic

  • Moderators
  • 2198 posts
There is no Orderdeditor yet in PrestaShop.

I wish there was........ :down:
Norman in 't VeldtModeratorPrestaShopForums
Help PrestaShop, make a donation!

#3
minh

    PrestaShop Apprentice

  • Members
  • PipPip
  • 96 posts
By the look of it (from my example above), the order of appearance of Features in the Shop is just haphazard. That seems odd, doesn't it? Is there perhaps some way of controlling this by the order in which one introduces the features in Admin? But it doesn't look like that either...

MINH DECOR

- proudly powered by PrestaShop

MINH BLOG

- proudly powered by Wordpress

#4
michaeld

    PrestaShop Newbie

  • Members
  • Pip
  • 2 posts
This is a quick hack to organize your features(in de same way you organize your categories):

Edit file classes/Product.php

Replace:

/*
* Select all features for a given language
*
* @param $id_lang Language id
* @return array Array with feature's data
*/
static public function getFrontFeaturesStatic($id_lang, $id_product)
{
return Db::getInstance()->ExecuteS('
SELECT name, value, pf.id_feature
FROM '._DB_PREFIX_.'feature_product pf
LEFT JOIN '._DB_PREFIX_.'feature_lang fl ON (fl.id_feature = pf.id_feature AND fl.id_lang = '.intval($id_lang).')
LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).')
WHERE pf.id_product = '.intval($id_product));
}


With:

/*
* Select all features for a given language
*
* @param $id_lang Language id
* @return array Array with feature's data
*/
static public function getFrontFeaturesStatic($id_lang, $id_product)
{
$result = Db::getInstance()->ExecuteS('
SELECT name, value, pf.id_feature
FROM '._DB_PREFIX_.'feature_product pf
LEFT JOIN '._DB_PREFIX_.'feature_lang fl ON (fl.id_feature = pf.id_feature AND fl.id_lang = '.intval($id_lang).')
LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).')
WHERE pf.id_product = '.intval($id_product).'
ORDER BY `name` ASC');

/* Modify SQL result */
$resultsArray = array();
foreach ($result AS $row)
{
$row['name'] = preg_replace('/^[0-9]+\./', '', $row['name']);
$resultsArray[] = $row;
}
return $resultsArray;
}


Now your can organize your features by putting the position in front of it, followed by a dot

For example:

01.Feature1
02.Feature2

#5
belladict

    PrestaShop Apprentice

  • Members
  • PipPip
  • 58 posts
Michaeld, thanks so much, the hack works like a charm :)

#6
enigma32

    PrestaShop Apprentice

  • Members
  • PipPip
  • 141 posts
can someone help.. using this method in classes/product.php function getAttributesGroups to sort attributes and groups with '##.' prefixes, but unable to strip the numbers for display as im not familiar with this whole 'al.' syntax so i dont know what to change 'name' to to strip it

#7
enigma32

    PrestaShop Apprentice

  • Members
  • PipPip
  • 141 posts
nevermind.. 'attribute_name' if anybody else is trying to do this

#8
Benygh

    PrestaShop Apprentice

  • Members
  • PipPip
  • 43 posts

From 1266808397:

can someone help.. using this method in classes/product.php function getAttributesGroups to sort attributes and groups with '##.' prefixes, but unable to strip the numbers for display as im not familiar with this whole 'al.' syntax so i dont know what to change 'name' to to strip it


u can try this module ...

http://www.presto-ch...der.html#idTab5

it works fine ...




This way doesnt work for me ...

it works for the Categories but doesnt work in features ...

im using persian version of prestashop ...

i think the problem is caused by this but as i said i have no problem with sorting categories with this way ...

i tried english titles and persian both,

#9
Diemux

    PrestaShop Apprentice

  • Members
  • PipPip
  • 110 posts
This no longer works in latest version (1.3.x)

I use:


/*
* Select all features for a given language
*
* @param $id_lang Language id
* @return array Array with feature's data
*/
static public function getFrontFeaturesStatic($id_lang, $id_product)
{
return Db::getInstance()->ExecuteS('
SELECT name, value, pf.id_feature
FROM '._DB_PREFIX_.'feature_product pf
LEFT JOIN '._DB_PREFIX_.'feature_lang fl ON (fl.id_feature = pf.id_feature AND fl.id_lang = '.intval($id_lang).')
LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).')
WHERE pf.id_product = '.intval($id_product).' order by name');

$resultsArray = array();
foreach ($result AS $row)
{
$row['name'] = Product::hideFeaturePosition($row['name']);
$resultsArray[] = $row;
}
return $resultsArray;

}

static public function hideFeaturePosition($name)
{
return preg_replace('/^[0-9]+\./', '', $name);
}


But no luck. The numbers stay visible. Weird though as I checked with the categories and that is still using the same code (and does work ;) )

Any idea's?

#10
shopgirl

    PrestaShop Newbie

  • Members
  • Pip
  • 17 posts
Anyone? I too would like this working for version 1.3. Thanks.

#11
justweb

    PrestaShop Apprentice

  • Members
  • PipPip
  • 66 posts
Hello,

don't work for me. i use 1.3 version

The prefix appear and filter order doesn't work...

my code

static public function getFrontFeaturesStatic($id_lang, $id_product)
{
$result = Db::getInstance()->ExecuteS('
SELECT name, value, pf.id_feature
FROM '._DB_PREFIX_.'feature_product pf
LEFT JOIN '._DB_PREFIX_.'feature_lang fl ON (fl.id_feature = pf.id_feature AND fl.id_lang = '.intval($id_lang).')
LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).')
WHERE pf.id_product = '.intval($id_product).'
ORDER BY `name` ASC');

/* Modify SQL result */
$resultsArray = array();
foreach ($result AS $row)
{
$row['name'] = preg_replace('/^[0-9]+\./', '', $row['name']);
$resultsArray[] = $row;
}
return $resultsArray;
}



help me please...
thx

#12
Diemux

    PrestaShop Apprentice

  • Members
  • PipPip
  • 110 posts
Works now in 3.0.1.1!

#13
Benygh

    PrestaShop Apprentice

  • Members
  • PipPip
  • 43 posts
what code did u use ?

what file ?! can u explain ?

#14
neastea18

    PrestaShop Apprentice

  • Members
  • PipPip
  • 43 posts
I just found another discussion talking about the same problem
http://www.prestasho...aracteristiques

However, they had a better UI presentation
by using:
FRUIT.01.Appellation
FRUIT.02.Origine
FRUIT.03….
AUTO.01.Puissance fiscale
AUTO.02.Nombre de portes
AUTO.03….
into:
FRUIT
Origine
Appellation
[…]

AUTO
Puissance fiscale
Nb de portes
[…]

Can someone help? Please

#15
deniss

    PrestaShop Newbie

  • Members
  • Pip
  • 8 posts
Here is the code for the 1.3 version, copy the code and replace the old one if you don't want to make mistake (don't forget to back up the old code if something goes wrong)

http://www.prestasho...racteristiques/
ChiniStore, la boutique de Produit High Tech et Gadgets de marque Chinoise (Tablette PC, MP4...)
ChiniTech, l'actualité Geek et High Tech venue de Chine

#16
mohsart

    PrestaShop Addict

  • Members
  • PipPipPip
  • 507 posts

From 1272017876:

This no longer works in latest version (1.3.x)

I use:


/*
* Select all features for a given language
*
* @param $id_lang Language id
* @return array Array with feature's data
*/
static public function getFrontFeaturesStatic($id_lang, $id_product)
{
return Db::getInstance()->ExecuteS('
SELECT name, value, pf.id_feature
FROM '._DB_PREFIX_.'feature_product pf
LEFT JOIN '._DB_PREFIX_.'feature_lang fl ON (fl.id_feature = pf.id_feature AND fl.id_lang = '.intval($id_lang).')
LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).')
WHERE pf.id_product = '.intval($id_product).' order by name');

$resultsArray = array();
foreach ($result AS $row)
{
$row['name'] = Product::hideFeaturePosition($row['name']);
$resultsArray[] = $row;
}
return $resultsArray;

}

static public function hideFeaturePosition($name)
{
return preg_replace('/^[0-9]+\./', '', $name);
}


But no luck. The numbers stay visible. Weird though as I checked with the categories and that is still using the same code (and does work ;) )

Any idea's?


You didn't change all the code
return Db::getInstance()->ExecuteS('
is still there

/Mats
I'm on 1.4.3 if nothing else is stated. My blog about using PrestaShop http://mohsart-prest...p.blogspot.com/ (I'm a n00b myself, so much is very basic)

NOTE! When I say "change xxx" I usually mean what is described here

My shop: http://mohsart.se

#17
cartcreative

    PrestaShop Apprentice

  • Members
  • PipPip
  • 29 posts
Has anybody been able to get this to work on 1.3.2.3 or 1.3.3?

I've tried the code from this thread, as well as the code over on the French thread, and its not stripping out the numbers.

I really don't even need to have the features listed in a custom order, just listed in the order I entered them in!

Can anyone help please?

#18
5ummer5

    PrestaShop Apprentice

  • Members
  • PipPip
  • 86 posts
Hi,

Im using v.1.3.3 and it worked fine for me.

It is just on my localhost at the moment so I hope it doesnt change when I upload it to my main server.
Check out my gig on fiverr. A detailed SEO report. I will analyse your site and provide a detailed report for you to follow to improve your ranking and traffic.

http://fiverr.com/in...of-your-website

#19
cartcreative

    PrestaShop Apprentice

  • Members
  • PipPip
  • 29 posts
I've managed to get this working on the front end. Has anyone managed to get the ordering to work in the BO? If so, can you share your code, please?

#20
5ummer5

    PrestaShop Apprentice

  • Members
  • PipPip
  • 86 posts
Hi,

I think this code will only order the front end and not it the BO. Although im not 100% on that so someone correct me if im wrong!
Check out my gig on fiverr. A detailed SEO report. I will analyse your site and provide a detailed report for you to follow to improve your ranking and traffic.

http://fiverr.com/in...of-your-website