Jump to content

Edit History

ps8modules

ps8modules

Hi.

It's easier than it seems.

Every time you change the combination, the reference changes as well.

1. a function needs to be added to ./classes/Combination.php

public static function getReferenceById($idProductAttribute)
    {
        if (empty($idProductAttribute)) {
            return;
        }

        $query = new DbQuery();
        $query->select('pa.reference');
        $query->from('product_attribute', 'pa');
        $query->where('pa.id_product_attribute = \'' . pSQL($idProductAttribute) . '\'');

        return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
    }

2. in your template product-variants.tpl you insert the code at the beginning

I intentionally left the attribute ID there before the reference to make it understandable for others.

Ref: {$product.id_product_attribute} - {Combination::getReferenceById($product.id_product_attribute)}

obrazek.thumb.png.2bc5d7aa397c6efeb53453ba475c1c0e.png

 

3.  result

obrazek.png.19183df728985699552547b06c069a08.png

ps8modules

ps8modules

Hi.

It's easier than it seems.

1. a function needs to be added to ./classes/Combination.php

public static function getReferenceById($idProductAttribute)
    {
        if (empty($idProductAttribute)) {
            return;
        }

        $query = new DbQuery();
        $query->select('pa.reference');
        $query->from('product_attribute', 'pa');
        $query->where('pa.id_product_attribute = \'' . pSQL($idProductAttribute) . '\'');

        return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
    }

2. in your template product-variants.tpl you insert the code at the beginning

I intentionally left the attribute ID there before the reference to make it understandable for others.

Ref: {$product.id_product_attribute} - {Combination::getReferenceById($product.id_product_attribute)}

obrazek.thumb.png.2bc5d7aa397c6efeb53453ba475c1c0e.png

 

3.  result

obrazek.png.19183df728985699552547b06c069a08.png

ps8modules

ps8modules

Hi.

It's easier than it seems.

1. a function needs to be added to ./classes/Combination.php

public static function getReferenceById($idProductAttribute)
    {
        if (empty($idProductAttribute)) {
            return;
        }

        $query = new DbQuery();
        $query->select('pa.reference');
        $query->from('product_attribute', 'pa');
        $query->where('pa.id_product_attribute = \'' . pSQL($idProductAttribute) . '\'');

        return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
    }

2. in your template product-variants.tpl you insert the code at the beginning

Ref: {$product.id_product_attribute} - {Combination::getReferenceById($product.id_product_attribute)}

obrazek.thumb.png.2bc5d7aa397c6efeb53453ba475c1c0e.png

 

3.  result

obrazek.png.19183df728985699552547b06c069a08.png

×
×
  • Create New...