Jump to content

Related products do not display icons


aquaanimation

Recommended Posts

 

The related product images are working fine on my PrestaShop v1.7.1.0 Beta test site. I see URLs like http://localhost/prestashop17/7-home_default/blouse.jpg
 
What are the broken URLs you're getting?

 

The urls I am seeing on the inspector are like this https://www.mydomain.com/28-home_default/.jpg

 

 

Do you think from the stable 1.7.0.5 I should update to the beta??

 

If you think that you can help I can PM you credentials. It is still in development stages.

Edited by aquaanimation (see edit history)
Link to comment
Share on other sites

No, it's better to try to fix the cause. From the URL you've given, it seems the friendly URL is missing for the product. Make sure the friendly URL is filled in on the SEO tab. If you're unable to save it, try manually editing the ps_product_lang table in the database and setting the link_rewrite field for the product.

Link to comment
Share on other sites

I don't understand why it's working fine on my test site, but not your site. Perhaps you have an override causing the wrong links to be generated? You can check if override/class/Link.php exists. Otherwise, you can try installing PrestaShop v1.7.1.0 Beta in a separate directory and see if it has the same problem. It's better not to upgrade your existing site, since it's a beta and your problem may persist in the upgrade.

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...
  • 1 month later...
  • 9 months later...

This is something to do with not using the language with id 1.

We have a store that uses lang 3 as the default, and lang 1 is disabled - this is causing broken images on the Related Products in admin, and is fixed if I add the link_rewrite for lang 1 of that product in the DB table ps_product_lang.

Looks as though something is hardcoded to id_lang = 1 somewhere.

Link to comment
Share on other sites

  • 3 weeks later...

Same issue here. 

I solved it with:

  1. Two languages installed in: BO/International/Localization/Languages
  2. Backup your installation.
  3. Delete language with id: 1 (it should be English language)
  4. Related Products will work now.
  5. If you need English language, add it through: BO/International/Translations/"Add / Update a language"
  6. Keep in mind, that when you switch to the English language in BO/Your Profile (top right corner)/Language
    When you will be adding product through "Related Products" field, the problem partially will be still here: Product image in search dropdown will be not displayed
    However, page refresh after adding the related product - solves the issue.

Hope this will help for the people looking for the solution.

This is the Core bug.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

I solved it with:

1. add function getLanguageId to CategoryDataProvider class /src/Adapter/Category/CategoryDataProvider.php

public function getLanguageId()
{
    return $this->languageId;
 }



2. edit switch default: in function buildView in /src/PrestaShopBundle/Form/Admin/Type/TypeaheadProductCollectionType.php
change:
           

 default:
                        $product = $this->productAdapter->getProduct($id);
                        $collection[] = [
                            'id' => $id,
                            'name' => reset($product->name) . ' (ref:' . $product->reference . ')',
                            'image' => $product->image,
                        ];

                        break;

to:
           

default:
                        $id_lang=$this->categoryAdapter->getLanguageId();
                        $product = $this->productAdapter->getProduct($id,false,$id_lang);
                        $collection[] = [
                            'id' => $id,
                            'name' => ($product->name) . ' (ref:' . $product->reference . ')',
                            'image' => $product->image,
                        ];

                        break;

 

Edited by devHeaven (see edit history)
  • Thanks 2
Link to comment
Share on other sites

  • 1 year later...
On 7/6/2022 at 2:57 PM, devHeaven said:

I solved it with:

1. add function getLanguageId to CategoryDataProvider class /src/Adapter/Category/CategoryDataProvider.php

public function getLanguageId()
{
    return $this->languageId;
 }



2. edit switch default: in function buildView in /src/PrestaShopBundle/Form/Admin/Type/TypeaheadProductCollectionType.php
change:
           

 default:
                        $product = $this->productAdapter->getProduct($id);
                        $collection[] = [
                            'id' => $id,
                            'name' => reset($product->name) . ' (ref:' . $product->reference . ')',
                            'image' => $product->image,
                        ];

                        break;

to:
           

default:
                        $id_lang=$this->categoryAdapter->getLanguageId();
                        $product = $this->productAdapter->getProduct($id,false,$id_lang);
                        $collection[] = [
                            'id' => $id,
                            'name' => ($product->name) . ' (ref:' . $product->reference . ')',
                            'image' => $product->image,
                        ];

                        break;

 

Hi,

I have this problem on both my own shops and lots of client's shops. I overlooked your step 1 and couldn't get it to work. So just for others:

Step 1 should be added just after this code: 

class CategoryDataProvider
{

in /src/Adapter/Category/CategoryDataProvider.php

Works for me now 🙂

 

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