Jump to content

Edit History

4presta

4presta

Hi.

There are several solutions.
One of the simplest is to create an override of Product.php and add your own static function + to that, insert a static function call into your product.tpl template.

Another option is to program a mini module and connect it to hooks. On the product page, you could use the displayReassurance hook (before the product tabs) or the displayFooterProduct hook (at the end of the product detail page), or create your own hook in the module and insert it into the product tpl template.

 

Override Product.php and override product.tpl:

Product.php + static function (sample)

public static function getProductCategoryDescription($idProduct, $idLang, $idShop = '1')
    {
        $db = Db::getInstance();
        $product = new Product((int)$idProduct);
        $context = Context::getContext();
        $idCategoryDefault = $product->id_category_default;
        $getDecription = $db->getValue('SELECT description FROM '._DB_PREFIX_.'category_lang WHERE id_category = '.$idCategoryDefault.' AND id_lang = '.$idLang.' AND id_shop = '.$idShop);
        return $getDecription;
    }

 

product.tpl (sample ./themes/classic/templates/catalog/product.tpl)

 {block name='display_category_description'}
              {if Product::getProductCategoryDescription($product.id, $language.id) != ''}
                <div id="category-description" class="text-muted">{Product::getProductCategoryDescription($product.id, $language.id) nofilter}</div>
              {/if}
            {/block}

image.thumb.png.312420312b9f025f7da1a7845aadee5b.png

4presta

4presta

Hi.

There are several solutions.
One of the simplest is to create an override of Product.php and add your own static function + to that, insert a static function call into your product.tpl template.

Another option is to program a mini module and connect it to hooks. On the product page, you could use the displayReassurance hook (before the product tabs) or the displayFooterProduct hook (at the end of the product detail page).

 

Override Product.php and override product.tpl:

Product.php + static function (sample)

public static function getProductCategoryDescription($idProduct, $idLang, $idShop = '1')
    {
        $db = Db::getInstance();
        $product = new Product((int)$idProduct);
        $context = Context::getContext();
        $idCategoryDefault = $product->id_category_default;
        $getDecription = $db->getValue('SELECT description FROM '._DB_PREFIX_.'category_lang WHERE id_category = '.$idCategoryDefault.' AND id_lang = '.$idLang.' AND id_shop = '.$idShop);
        return $getDecription;
    }

 

product.tpl (sample ./themes/classic/templates/catalog/product.tpl)

 {block name='display_category_description'}
              {if Product::getProductCategoryDescription($product.id, $language.id) != ''}
                <div id="category-description" class="text-muted">{Product::getProductCategoryDescription($product.id, $language.id) nofilter}</div>
              {/if}
            {/block}

image.thumb.png.312420312b9f025f7da1a7845aadee5b.png

4presta

4presta

Hi.

There are several solutions.
One of the simplest is to create an override of Product.php and add your own static function + to that, insert a static function call into your product.tpl template.

Product.php + static function (sample)

public static function getProductCategoryDescription($idProduct, $idLang, $idShop = '1')
    {
        $db = Db::getInstance();
        $product = new Product((int)$idProduct);
        $context = Context::getContext();
        $idCategoryDefault = $product->id_category_default;
        $getDecription = $db->getValue('SELECT description FROM '._DB_PREFIX_.'category_lang WHERE id_category = '.$idCategoryDefault.' AND id_lang = '.$idLang.' AND id_shop = '.$idShop);
        return $getDecription;
    }

 

product.tpl (sample ./themes/classic/templates/catalog/product.tpl)

 {block name='display_category_description'}
              {if Product::getProductCategoryDescription($product.id, $language.id) != ''}
                <div id="category-description" class="text-muted">{Product::getProductCategoryDescription($product.id, $language.id) nofilter}</div>
              {/if}
            {/block}

image.thumb.png.312420312b9f025f7da1a7845aadee5b.png

×
×
  • Create New...