• Bilal Malik

Change product image placeholder based on product – Magento 2

We need to override the below two functions in vendor/magento/module-catalog/Helper/Image.php

Below function change the placeholder image in the home page, category page, product page.

public function getPlaceholder($placeholder = null)
{
	$product = $this->getProduct();
	if($product->getName() == "Test Name") // here your condition
	{
		// logic to retrieve new url
		return $new_palceholder_url;
	}
        ...............//remining magento core codes
}

Below function change the placeholder image in cart page.

public function getUrl()
{
	$product = $this->getProduct();
	if($product->getName() == "Test Name") // here your condition
	{
		// logic to retrieve new url
		return $new_palceholder_url;
	}
        ...............//remining magento core codes
}

I hope it helps. Thanks.

#customization #magento2 #placeholderimage

Recent Posts

See All

What is requireJS AMD in Magento2

Simply we can say, below format is the AMD module. define(['jquery'] , function ($) { return function () {}; }); Module Vs AMD module 1. Javascript Module Pattern (function () { this.myGlobal =

©2020 by Bilal Usean. Proudly created with Wix.com