Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions Doofinder/Feed/Helper/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Magento\UrlRewrite\Model\UrlFinderInterface;
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable;
use Magento\Catalog\Model\ResourceModel\Product as ProductResourceModel;

/**
* Product helper
Expand Down Expand Up @@ -78,6 +79,11 @@ class Product extends AbstractHelper
*/
protected $configurable;

/**
* @var ProductResourceModel
*/
private $productResource;

/**
* @see /Doofinder/Feed/Observer/Product/AbstractChangedProductObserver.php
*
Expand All @@ -96,6 +102,7 @@ class Product extends AbstractHelper
* @param EavConfig $eavConfig
* @param Configurable $configurable
* @param InventoryHelper $inventoryHelper
* @param ProductResourceModel $productResource
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand All @@ -108,7 +115,8 @@ public function __construct(
UrlFinderInterface $urlFinder,
EavConfig $eavConfig,
Configurable $configurable,
InventoryHelper $inventoryHelper
InventoryHelper $inventoryHelper,
ProductResourceModel $productResource
) {
$this->categoryCollectionFactory = $categoryCollectionFactory;
$this->imageHelper = $imageHelper;
Expand All @@ -119,6 +127,7 @@ public function __construct(
$this->eavConfig = $eavConfig;
$this->configurable = $configurable;
$this->inventoryHelper = $inventoryHelper;
$this->productResource = $productResource;
$this->visibilityAllowed = [Visibility::VISIBILITY_IN_SEARCH, Visibility::VISIBILITY_BOTH];
parent::__construct($context);
}
Expand Down Expand Up @@ -173,10 +182,17 @@ public function getProductUrl(ProductModel $product): string
$routeParams['_direct'] = $requestPath;
} else {
$routePath = 'catalog/product/view';
// In case the product is a variant we need the ID of the configurable
// In case the product is a variant we need the ID and url_key of the configurable
if ($useParentUrl) {
$routeParams['id'] = $parents[0];
$routeParams['s'] = $product->getUrlKey();
$parentUrlKey = $this->productResource->getAttributeRawValue(
$parents[0],
'url_key',
$storeId
);
if (!empty($parentUrlKey)) {
$routeParams['s'] = $parentUrlKey;
}
} else {
$routeParams['id'] = $product->getId();
$routeParams['s'] = $product->getUrlKey();
Expand Down
2 changes: 1 addition & 1 deletion Doofinder/Feed/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "doofinder/doofinder-magento2",
"version": "1.7.6",
"version": "1.7.7",
"description": "Doofinder module for Magento 2",
"type": "magento2-module",
"require": {
Expand Down
2 changes: 1 addition & 1 deletion Doofinder/Feed/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Doofinder_Feed" setup_version="1.7.6">
<module name="Doofinder_Feed" setup_version="1.7.7">
<sequence>
<module name="Magento_Integration" />
</sequence>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "doofinder/doofinder-magento2",
"version": "1.7.6",
"version": "1.7.7",
"description": "Doofinder module for Magento 2",
"type": "magento2-module",
"require": {
Expand Down