LOCALHOST
Version de PrestaShop : 1.7.8.3
PHP : 7.4.28
MYSQL : 10.6.7-MariaDB
Hello,
Problem solves
THank you
LOCALHOST
Version de PrestaShop : 1.7.8.3
PHP : 7.4.28
MYSQL : 10.6.7-MariaDB
Hello,
Problem solves
THank you
LOCALHOST
Version de PrestaShop : 1.7.8.3
PHP : 7.4.28
MYSQL : 10.6.7-MariaDB
Hello,
I have problems, my module, that I created, display array list but in the same time, it display the word "Array" (see picture)
This is the code php/tpl/smarty :
content.tpl
<h3 style="color:seagreen;">{l s='Descriptif de votre piscine' mod='everpsquotation'}</h3> <p> {foreach from=$details item=pool} {assign var='cats' value=Product::getProductCategories($pool.product_id)} {$cats|escape:'htmlall':'UTF-8'} {if in_array('35', $cats) || in_array('34', $cats) || in_array('36', $cats)} {foreach from=$details item=product} {assign var='razlebols' value=Product::getFeaturesStatic($product.product_id)} {foreach from=$razlebols item=razlebol} {assign var='feature_lang' value=Feature::getFeatureLang($razlebol.id_feature)} - {$feature_lang.name} {assign var='features' value=Feature::getFeaturesName($razlebol.id_feature_value)} {$features.value}<br> {/foreach} {/foreach} {/if} {/foreach} </p>
classes/Product.php
/** * getProductCategories return an array of categories which this product belongs to. * * @param int|string $id_product Product identifier * * @return array Category identifiers */ public static function getProductCategories($id_product = '') { $cache_id = 'Product::getProductCategories_' . (int) $id_product; if (!Cache::isStored($cache_id)) { $ret = []; $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( ' SELECT `id_category` FROM `' . _DB_PREFIX_ . 'category_product` WHERE `id_product` = ' . (int) $id_product ); if ($row) { foreach ($row as $val) { $ret[] = $val['id_category']; } } Cache::store($cache_id, $ret); return $ret; } return Cache::retrieve($cache_id); }
classes/Product.php
/**
* @param int $id_product Product identifier
*
* @return array
*/
public static function getFeaturesStatic($id_product)
{
if (!Feature::isFeatureActive()) {
return [];
}
if (!array_key_exists($id_product, self::$_cacheFeatures)) {
self::$_cacheFeatures[$id_product] = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
'
SELECT fp.id_feature, fp.id_product, fp.id_feature_value, custom
FROM `' . _DB_PREFIX_ . 'feature_product` fp
LEFT JOIN `' . _DB_PREFIX_ . 'feature_value` fv ON (fp.id_feature_value = fv.id_feature_value)
WHERE `id_product` = ' . (int) $id_product
);
}
return self::$_cacheFeatures[$id_product];
}
classes/Product.php
public static function getFeaturesName($id_feature_value) { return Db::getInstance()->getRow( ' SELECT * FROM `' . _DB_PREFIX_ . 'feature_value_lang` WHERE `id_feature_value` = ' . (int)$id_feature_value ); } public static function getFeatureLang($id_feature_value) { return Db::getInstance()->getRow( ' SELECT * FROM `' . _DB_PREFIX_ . 'feature_lang` WHERE `id_feature` = ' . (int)$id_feature_value ); }
Thanks in advance for your help
Sincerelly
Futamiya
FRENCH :
J'ai des problèmes, mon module, que j'ai créé, affiche la liste des tableaux mais en même temps, il affiche le mot "Array" (voir image) C'est le code smarty/php (revoir juste en haut)
Merci d'avance pour votre aide
Cordialement
LOCALHOST
Version de PrestaShop : 1.7.8.3
PHP : 7.4.28
MYSQL : 10.6.7-MariaDB
Hello,
I have problems, my module, that I created, display array list but in the same time, it display the word "Array" (see picture)
This is the code php/tpl/smarty :
content.tpl
<h3 style="color:seagreen;">{l s='Descriptif de votre piscine' mod='everpsquotation'}</h3> <p> {foreach from=$details item=pool} {assign var='cats' value=Product::getProductCategories($pool.product_id)} {$cats|escape:'htmlall':'UTF-8'} {if in_array('35', $cats) || in_array('34', $cats) || in_array('36', $cats)} {foreach from=$details item=product} {assign var='razlebols' value=Product::getFeaturesStatic($product.product_id)} {foreach from=$razlebols item=razlebol} {assign var='feature_lang' value=Feature::getFeatureLang($razlebol.id_feature)} - {$feature_lang.name} {assign var='features' value=Feature::getFeaturesName($razlebol.id_feature_value)} {$features.value}<br> {/foreach} {/foreach} {/if} {/foreach} </p>
classes/Product.php
/** * getProductCategories return an array of categories which this product belongs to. * * @param int|string $id_product Product identifier * * @return array Category identifiers */ public static function getProductCategories($id_product = '') { $cache_id = 'Product::getProductCategories_' . (int) $id_product; if (!Cache::isStored($cache_id)) { $ret = []; $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( ' SELECT `id_category` FROM `' . _DB_PREFIX_ . 'category_product` WHERE `id_product` = ' . (int) $id_product ); if ($row) { foreach ($row as $val) { $ret[] = $val['id_category']; } } Cache::store($cache_id, $ret); return $ret; } return Cache::retrieve($cache_id); }
classes/Product.php
/**
* @param int $id_product Product identifier
*
* @return array
*/
public static function getFeaturesStatic($id_product)
{
if (!Feature::isFeatureActive()) {
return [];
}
if (!array_key_exists($id_product, self::$_cacheFeatures)) {
self::$_cacheFeatures[$id_product] = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
'
SELECT fp.id_feature, fp.id_product, fp.id_feature_value, custom
FROM `' . _DB_PREFIX_ . 'feature_product` fp
LEFT JOIN `' . _DB_PREFIX_ . 'feature_value` fv ON (fp.id_feature_value = fv.id_feature_value)
WHERE `id_product` = ' . (int) $id_product
);
}
return self::$_cacheFeatures[$id_product];
}
classes/Product.php
public static function getFeaturesName($id_feature_value) { return Db::getInstance()->getRow( ' SELECT * FROM `' . _DB_PREFIX_ . 'feature_value_lang` WHERE `id_feature_value` = ' . (int)$id_feature_value ); } public static function getFeatureLang($id_feature_value) { return Db::getInstance()->getRow( ' SELECT * FROM `' . _DB_PREFIX_ . 'feature_lang` WHERE `id_feature` = ' . (int)$id_feature_value ); }
Thanks in advance for your help
Sincerelly
Futamiya
FRENCH :
J'ai des problèmes, mon module, que j'ai créé, affiche la liste des tableaux mais en même temps, il affiche le mot "Array" (voir image) C'est le code smarty/php (revoir juste en haut)
Merci d'avance pour votre aide
Cordialement