I have been added Callback button and "Contact Number" to products by overriding the price template. While displaying the price of a product, how to check whether that particular product is going to be displayed under upsell list or not?

(Don't want to display the callback button for Upsell products. Only the contact number should be displayed)


You can check if the product is upsell or not using following way:

protected $_product;

public function __construct(
    \Magento\Catalog\Model\Product $product
) {
    $this->_product = $product;

public function isUpsellProduct($sku) {
    $collection = $this->_product->getUpSellProductCollection();
    $collection->addAttributeToFilter('sku', ['eq' => 'NewArrivals-5']);

    if (!empty($collection->getData())) {
        return true;
    else {
        return false;

Hope it may help you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.