Jump to content

Custom Text Translation in Prestashop 1.7.7.1


Recommended Posts

I found the solution. Here is what it is.

These methods only work if you are working on a theme with a name that is not “classic”. If you’re tweaking the Classic theme and you’ve kept the “/classic” folder, your new strings won’t be detected. PrestaShop is only looking for new strings in theme folders other than “/classic”.

Link to comment
Share on other sites

On 11/29/2021 at 12:26 AM, yasir517 said:

If you’re tweaking the Classic theme and you’ve kept the “/classic” folder,

Don't do this! Any later Prestashop upgrade will mess it up. Please check out the child-theme feature and do any theme adjustments there.

Link to comment
Share on other sites

  • 1 year later...

To simplify the custom features value availability in different languages , you can change the below script inside Classes/Product.php

Once you add new customized features in main language, those inputs will be available in other languages too. You will not have to copy paste everytime.

Find

-------------
public function addFeaturesCustomToDB($id_value, $lang, $cust)
    {
        $row = ['id_feature_value' => (int) $id_value, 'id_lang' => (int) $lang, 'value' => pSQL($cust)];

        return Db::getInstance()->insert('feature_value_lang', $row);
    }
----------------

and Change to

    public function addFeaturesCustomToDB($id_value, $lang, $cust)
   {

     if (trim($cust)=='') {

       $sql = 'SELECT f.`value`'
           .' FROM `'. _DB_PREFIX_.'feature_value_lang` f '
           .' WHERE f.id_feature_value = '.$id_value.' and id_lang<>'.$lang;
       $cust=  Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
     }

       $row = array('id_feature_value' => (int) $id_value, 'id_lang' => (int) $lang, 'value' => pSQL($cust));

       return Db::getInstance()->insert('feature_value_lang', $row);
   }
 

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...