Jump to content

Prestashop 1.5.3.1 - Product-list.tpl error, product image not showing


Recommended Posts

In product list the product image don't show for new inserted products

 

 

With default products

$product.link_rewrite returns per example 5-7

 

but with new products inserted

$product.link_rewrite returns en-default

 

So the image link returned with

$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')

 

is

"img/p/en-default-home_default.jpg"

 

 

Can you please tell me what the problem is?

 

Thanks

Link to comment
Share on other sites

  • 1 month later...
  • 6 months later...

Yes vekia, actually i have done a script that import products from an XML.

 

It's working but the only thing is thoses images

 

I think that there is some thing missing here ;

 

function AddImages($images){
global $product;
echo $product->id;
        if(!is_array($images) OR count($images)==0)
            return;
            
        $_warnings = array();
        $_errors = array();
        $productHasImages = (bool)Image::getImages(1, (int)($product->id));
        if ($productHasImages){ $product->deleteImages(); }
        foreach ($images AS $key => $url)
        {
            if (!empty($url))
            {
                
                $image = new Image();
                $image->id_product = (int)($product->id);
                $image->position = 1;
                $image->cover = true;
                $image->legend = createMultiLangField($product->name[1]);
                //print_r($image);
                if (($field_error = $image->validateFields(UNFRIENDLY_ERROR, true)) === true &&
                                ($lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $image->add())
                {
                    $image->associateTo($product->id_shop_list);
                    if (!copyImg($product->id, $image->id, $url)){
                        $image->delete();
                        $_warnings[] = Tools::displayError('Error copying image: ').$url;
                    }
                }
                else
                {
                    $_warnings[] = $image->legend[$defaultLanguageId].(isset($image->id_product) ? ' ('.$image->id_product.')' : '').' '.Tools::displayError('cannot be saved');
                    $_errors[] = ($fieldError !== true ? $fieldError : '').($langFieldError !== true ? $langFieldError : '').mysql_error();
                }
                
                //$image->updatePosition(Tools::getValue('imgDirection'), Tools::getValue('imgPosition'));
            }
        }
}
 

Link to comment
Share on other sites

×
×
  • Create New...