Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the display of main products in the category listing #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
value="{{ option.id }}"
class="sas-product-configurator-option-input{% if isCombinableCls %} {{ isCombinableCls }}{% endif %}"
title="{{ optionIdentifier }}"
data-url="{{ url('sas.frontend.variant.switch', {'productId': product.parentId}) }}"
data-url="{{ url('sas.frontend.variant.switch', {'productId': product.parentId ?? product.id}) }}"
id="{{ optionIdentifier }}"
{% if isActive %}checked="checked"{% endif %}>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% endblock %}
</label>
{% block component_product_box_configurator_select %}
<select data-name="{{ group.id }}" data-url="{{ url('sas.frontend.variant.switch', {'productId': product.parentId}) }}" name="{{ groupIdentifier }}" id="{{ group.id }}" class="custom-select sas-product-configurator-select-input">
<select data-name="{{ group.id }}" data-url="{{ url('sas.frontend.variant.switch', {'productId': product.parentId ?? product.id }) }}" name="{{ groupIdentifier }}" id="{{ group.id }}" class="custom-select sas-product-configurator-select-input">
{% for option in group.options %}

{% set selected = false %}
Expand Down
27 changes: 14 additions & 13 deletions src/Storefront/Page/ProductListingConfigurationLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ public function loadListing(ProductCollection $products, SalesChannelContext $co
/** @var SalesChannelProductEntity $product */
foreach ($products as $product) {
$productSettings = $this->loadSettings(clone $settings);
$parentId = $product->getParentId() ?? $product->getId();

if ($product->getConfiguratorSettings() !== null || !$product->getParentId() || empty($productSettings[$product->getParentId()])) {
$product->addExtension('groups', new PropertyGroupCollection());
if ($product->getConfiguratorSettings() !== null || empty($productSettings[$parentId])) {

$product->addExtension('groups', new PropertyGroupCollection());
continue;
}

$productSetting = $productSettings[$product->getParentId()];

$productSetting = $productSettings[$parentId];
$groups = $this->sortSettings($productSetting, $product);

if (!array_key_exists($product->getParentId(), $allCombinations)) {
if (!array_key_exists($parentId, $allCombinations)) {
continue;
}

$combinations = $allCombinations[$product->getParentId()];
$combinations = $allCombinations[$parentId];

$current = $this->buildCurrentOptions($product, $groups);

Expand Down Expand Up @@ -330,15 +330,16 @@ private function buildCurrentOptions(SalesChannelProductEntity $product, Propert
$keyMap = $groups->getOptionIdMap();

$current = [];
foreach ($product->getOptionIds() as $optionId) {
$groupId = $keyMap[$optionId] ?? null;
if ($groupId === null) {
continue;
}
if (null !== $optionIds = $product->getOptionIds()) {
foreach ($optionIds as $optionId) {
$groupId = $keyMap[$optionId] ?? null;
if ($groupId === null) {
continue;
}

$current[$groupId] = $optionId;
$current[$groupId] = $optionId;
}
}

return $current;
}
}