I have this block at the bottom of cms pages that are created by bluefoot and when you click on the image it takes you to a long URL like if it was being searched for but if you click on "add to cart" it takes you directly to the PDP page. I would like to figure out how I can get the same results (go to PDP page) by clicking on the image. Not sure if this is a bug with bluefoot in 2.2.6 because I noticed on 2.3.1 it doesn't function like this, I believe the problem is because it's on a different store. But like I said on the newer versions (page builder) the link issue has been resolved.

enter image description here

On the bottom of the image, you can see the URL which is a long URL but it ends up going to a search results page and that particular product doesn't even populate. If they click on the image I would like to take them directly to the PDP. The add to cart button does just that.

I believe i have to edit one of these two files:


 <?php // Product Image ?>
                        <a href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>" class="product photo product-item-photo" tabindex="-1">
                            <?php echo $productImage->toHtml(); ?>
                        <div class="product details product-item-details">
                            $_productNameStripped = $block->stripTags($_product->getName(), null, true);
                            <strong class="product name product-item-name">
                                <a class="product-item-link"
                                   href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>">
                                    <?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
                            <?php echo $block->getReviewsSummaryHtml($_product, $templateType); ?>
                            <?php /* @escapeNotVerified */ echo $block->getProductPrice($_product) ?>
                            <?php echo $block->getProductDetailsHtml($_product); ?>


 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See LICENSE.txt for license details.

namespace Gene\BlueFoot\Block\Entity\PageBuilder\Block\Catalog;

 * Class Gene\BlueFoot\Block\Entity\PageBuilder\Block\Catalog\Single
class Single extends AbstractCatalogBlock
     * Stop \Magento\Catalog\Block\Product\ListProduct::_beforeToHtml() running as
     * this is used for product listings/collections
     * @return null
    protected function _beforeToHtml()
        return null;

     * Return the product
     * @return bool|\Magento\Catalog\Api\Data\ProductInterface|null
    public function getProduct()
        /* @var $dataModel \Gene\BlueFoot\Model\Attribute\Data\Widget\Product */
        $dataModel = $this->getEntity()->getResource()->getAttribute('product_id')->getDataModel($this->getEntity());
        if ($dataModel instanceof \Gene\BlueFoot\Model\Attribute\Data\Widget\Product && method_exists($dataModel, 'getProduct')) {
            return $dataModel->getProduct();
        return false;

Lastly, I realize I should probably do a proper override but at this point, I'm just trying to get the link/image to go directly to the PDP. I've tried changing $_product->getProductUrl() to a variety of different things.. can someone tell me what I need to change the getProductURL to or if I need to change the getProduct method in the second file. Thanks in advance.

1 Answer 1


Is the issue that what is returned from $_product->getProductUrl() is different to the add to cart action?

e.g you are getting http://your-site/catalog/product/view/id/123 (or something similar) rather than http://your-site/nice-url.html?

If this is the case I'd try one of 2 things.

  1. Are friendly URLs enabled for your store? I believe this is store->config->general->web->seo->URLs

  2. After a little Google I've found this function $product->getUrlModel()->getUrl($product);. You could give this a go. I've not tried this myself.

One thing to note is that if you are an enterprise client and you are using 2.3.1 you should switch to PageBuilder and this is Magento's new 'BlueFoot'.

I hope that helps you debug your issue.


  • Hi @Hob, thank you very much for responding. Yes, that is the issue. I don't want the long url.. i just want them to go directly to the Product detail page when they click on the image, same behavior like when they click on "add to cart" which works correctly. I'll test out these two things. =] Jul 2, 2019 at 17:45
  • Were you saying to add $product->getUrlModel()->getUrl($product); instead of >>>> echo $_product->getProductUrl() Jul 2, 2019 at 22:39
  • Hey, I'd give that a go. Fingers crossed it helps
    – Hob Adams
    Jul 4, 2019 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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