Jump to content

Use product's specific feature in module


Recommended Posts

If there is only one value, it's simple.

$idlang = 1;
$idFeature = 14;
$idProduct = 222;

$getFeatureValue = Db::getInstance()->getValue('
	SELECT a.value FROM '._DB_PREFIX_.'feature_value_lang a 
	LEFT JOIN '._DB_PREFIX_.'feature_product b ON (a.id_feature_value = b.id_feature_value)
    WHERE b.id_feature = '.$idFeature.' AND b.id_product = '.$idProduct.' AND a.id_lang = '.$idLang);

Result one value:

obrazek.png.3586de99326ea52c54dd2a274e3ea47a.png

Edited by ps8moduly.cz (see edit history)
  • Like 1
Link to comment
Share on other sites

If you want to get more information, you use, for example:

$idlang = 1;
$idFeature = 14;
$idProduct = 222;

$getFeatureInfo = Db::getInstance()->getRow('
	SELECT a.id_feature_value, a.value as feature_value_name, c.name as feature_name FROM '._DB_PREFIX_.'feature_value_lang a 
	LEFT JOIN '._DB_PREFIX_.'feature_product b ON (a.id_feature_value = b.id_feature_value)
    LEFT JOIN '._DB_PREFIX_.'feature_lang c ON (c.id_feature = b.id_feature)
    WHERE b.id_feature = '.$idFeature.' AND b.id_product = '.$idProduct.' AND a.id_lang = '.$idLang.' AND c.id_lang = '.$idlang);

$featureName = $getFeatureInfo['feature_name'];
$featureValueName = $getFeatureInfo['feature_value_name'];
$featureValueId = $getFeatureInfo['id_feature_value'];

 

result:

obrazek.png.c27ba0a205078695041c50e8f39f0d5f.png

 

And you can play endlessly like this 😄

 

Edited by ps8moduly.cz (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...