At Options > select from Attribute Gr. the CODE instead of NAME

Designer
Fra Romania
Medlem siden

When Editing a new product At Options, when selecting from Attribute Groups (Options > Add Predefined Option Groups) , by clicking the --select-- button you can select a value from the already created attribute groups.
Here the list is coming from Catalog > Attribute Group - Name field.

What I'd like is that when the dropdown is clicked instead of the Name field , to show me the Code filed from Catalog > Attribute Group, - only here in admin .

Why?

I have many filters and I want to populate them somehow and when making a selection when editing a product by seeing the Code names it will be easier to scroll and find the filter

At Catalog > Attribute Group
I can group the Attributes by giving logical names for the Code column/fields.
Example:
CODE

  • Car - color
  • Car - type
  • Car - brand etc.
  • Bicycle - color
  • Bicycle - type
  • Bicycle - brand etc.
    (in this way the attributes are populated by product category simply from A-Z)

And for the Name column/fields:

  • Name
  • Color
  • Type
  • Brand etc.
    .. as these will appear on the front when selection options when placing the order.

What would be the right way achieving the above by following Litecart's coding guide?


(This will do the trick for me, but for a long term solution having Attributes categories, subcategories, and subsubcategories where attributes are organised would be nice)

LiteCart Fan
Fra Netherlands
Medlem siden

https://github.com/litecart/litecart/blob/dev/public_html/includes/functions/func_form.inc.php#L906

function form_draw_attribute_groups_list($name, $input=true, $multiple=false, $parameters='') {

    $query = database::query(
      "select ag.id, agi.name from ". DB_TABLE_PREFIX ."attribute_groups ag
      left join ". DB_TABLE_PREFIX ."attribute_groups_info agi on (agi.group_id = ag.id and agi.language_code = '". database::input(language::$selected['code']) ."')
      order by name;"
    );

    $options = [];

    if (empty($multiple)) $options[] = ['-- '. language::translate('title_select', 'Select') . ' --', ''];

    while ($row = database::fetch($query)) {
      $options[] = [$row['name'], $row['id']];
    }
    ...

Add code to the function:

  function form_draw_attribute_groups_list($name, $input=true, $multiple=false, $parameters='') {

    $query = database::query(
      "select ag.id, ag.code, agi.name from ". DB_TABLE_PREFIX ."attribute_groups ag                  /*add ag.code */
      left join ". DB_TABLE_PREFIX ."attribute_groups_info agi on (agi.group_id = ag.id and agi.language_code = '". database::input(language::$selected['code']) ."')
      order by name;"
    );

    $options = [];

    if (empty($multiple)) $options[] = ['-- '. language::translate('title_select', 'Select') . ' --', ''];

    while ($row = database::fetch($query)) {
      $options[] = [$row['code'], $row['id']];                  /*$row['code'] instead of $row['name]*/
    }
    ...
Designer
Fra Romania
Medlem siden

Hi @jackmaessen - works ok thank you.

A bit of a change needed so it work ok, please, if you could help i would greatly appreciate it:


1 - in Dashboard / Catalog / Attribute Groups page
at the moment the entries / lines are organised A-Z by the NAME column
I'd like the entries / lines to be organised A-Z by the CODE column


2 - In Dashboard / Catalog / Edit Product: (product name) at the OPTIONS tab:
the <h2> option title </h2> is the Attribute name
I'd like this to be also be the Attribute Code


(The rest remains the same.. the ftont page to still show the Attribute Name as you changed that with the above code)

Designer
Fra Romania
Medlem siden

Ive messaged you directly.
Thanks for your help.

Du
This website uses no cookies and no third party tracking technology. We think we can do better than others and really think about your privacy.