Jump to content

Missing Index ERROR - Undefined index: languages


Recommended Posts

I recently (finally) upgraded from Prestashop 1.4.10 to Prestashop 1.6.0.9, all is tweaked fine and running well except for one error that keeps showing up on the error_log everytime after I edit a product.
 

PHP Notice:  Undefined index: languages in /var/www/vhosts/DOMAIN.TLD/httpdocs/prestashop/cache/smarty/compile/d2/83/84/d28384ab6b1742618843bc582a07f28f04a39f8e.file.features.tpl.php on line 242, referer: https://www.DOMAIN.TLD/admin-CONFIDENTIAL/index.php?controller=AdminProducts&id_product=7777&updateproduct&token=TOKEN
 
PHP Notice:  Trying to get property of non-object in /var/www/vhosts/DOMAIN.TLD/httpdocs/prestashop/cache/smarty/compile/d2/83/84/d28384ab6b1742618843bc582a07f28f04a39f8e.file.features.tpl.php on line 242, referer: https://www.DOMAIN.TLD/admin-CONFIDENTIAL/index.php?controller=AdminProducts&id_product=7777&updateproduct&token=TOKEN
 
PHP Notice:  Undefined index: languages in /var/www/vhosts/DOMAIN.TLD/httpdocs/prestashop/cache/smarty/compile/d2/83/84/d28384ab6b1742618843bc582a07f28f04a39f8e.file.features.tpl.php on line 262, referer: https://www.DOMAIN.TLD/admin-CONFIDENTIAL/index.php?controller=AdminProducts&id_product=7777&updateproduct&token=TOKEN
 
PHP Notice:  Trying to get property of non-object in /var/www/vhosts/DOMAIN.TLD/httpdocs/prestashop/cache/smarty/compile/d2/83/84/d28384ab6b1742618843bc582a07f28f04a39f8e.file.features.tpl.php on line 262, referer: https://www.DOMAIN.TLD/admin-CONFIDENTIAL/index.php?controller=AdminProducts&id_product=7777&updateproduct&token=TOKEN
 
The database engine was still MyIsam and I changed to InnoDB this morning but the error persists.


FILE INFO
d28384ab6b1742618843bc582a07f28f04a39f8e.file.features.tpl.php

Line 242:
 $_from = $_smarty_tpl->tpl_vars['languages']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}

Line 262:
 $_from = $_smarty_tpl->tpl_vars['languages']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
 


Any ideias?


 
Edited by Funny-Cat WebShop (see edit history)
Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

I have no idea why this bug happend, because at first we could add products with no problem then after a while when creating a new product we got the same undefined index error.

 

I have solved it this way in case it helpes someone else:

 

Opened: /<admin-folder>/themes/default/template/controllers/products/features.tpl

 

You will see at the beginning there's a check for product ID:

{if isset($product->id)}

That ends before some javascript code:

 

{/if}


<script type="text/javascript">
hideOtherLanguage({$default_form_language});
{literal}
$(".textarea-autosize").autosize();


function all_languages(pos)
{
{/literal}
{foreach from=$languages key=k item=language}
 
The solution is to move the {/if} that is before the javascript code to the end of the file:
 
</script>
{/literal}


{/if}
Or better said, to include the javascript code inside the condition that checks if there's a product id.
Link to comment
Share on other sites

×
×
  • Create New...