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.
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:
vendor/gene/bluefoot/view/frontend/templates/pagebuilder/blocks/core/ecommerce/single.phtml
<?php // Product Image ?>
<a href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>" class="product photo product-item-photo" tabindex="-1">
<?php echo $productImage->toHtml(); ?>
</a>
<div class="product details product-item-details">
<?php
$_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'); ?>
</a>
</strong>
<?php echo $block->getReviewsSummaryHtml($_product, $templateType); ?>
<?php /* @escapeNotVerified */ echo $block->getProductPrice($_product) ?>
<?php echo $block->getProductDetailsHtml($_product); ?>
vendor/gene/bluefoot/Block/Entity/PageBuilder/Block/Catalog/Single.php
<?php
/**
* 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.