Jump to content

How to override pictures


Recommended Posts

Hello !

We need to display a default "No Picture" image when a variant has no image on its own instead of displaying ALL the product images.

In order to achieve this we needed to change the behavior of the ImageRetriever class.


return (0 === count($filteredImages)) ? $images : $filteredImages;


return (0 === count($filteredImages)) ? [
        ] : $filteredImages;

As we do not want to modify Core code base, we had to

  1. Extends the ImageRetriever class
  2. Override the ProductPresenterFactoryCode class in order to instantiate our ImageRetriever class instead of the core one.

It is working as intended for us.


No modification of the Core classes


A lot of overridden code.
Even if we extends the core classes (ProductPresenterFactoryCore and ImageRetriever),  we had to override every properties and methods as they are not intended to be extended (private property, ...).

In my opinion this is really bad. We should be able to alter core behavior without relying on so much code override.

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