Skip to content

Commit ca0d33c

Browse files
Version 1.0.0
1 parent a5f0fcc commit ca0d33c

File tree

7 files changed

+100
-3
lines changed

7 files changed

+100
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

AreanetAlohaThemeExtended/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
All notable changes to this plugin will be documented in this file
33

4+
## [1.1.0]
5+
6+
- Variantenoptionen als Eigenschaften auf der Produktdetailseite aufführen
7+
8+
49
## [1.0.0] - 30.01.2025
510

611
- CMS Page unter Warenkorbbutton

AreanetAlohaThemeExtended/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "areanet/aloha-theme-extended",
33
"description": "Extension Plugin for Aloha App Theme",
44
"type": "shopware-platform-plugin",
5-
"version": "1.0.0",
5+
"version": "1.1.0",
66
"license": "MIT",
77
"require": {
88
"shopware/core": "~6.6.0"

AreanetAlohaThemeExtended/src/Resources/config/config.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,10 @@
2020
<label>After main footer</label>
2121
<label lang="de-DE">Nach Hauptfooter</label>
2222
</component>
23+
<input-field type="bool">
24+
<name>mergeOptionsAndProperties</name>
25+
<label>List variant options on the detail page as properties</label>
26+
<label lang="de-DE">Variantenoptionen auf der Detailseie als Eigenschaften aufführen</label>
27+
</input-field>
2328
</card>
2429
</config>

AreanetAlohaThemeExtended/src/Resources/config/services.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,14 @@
1212

1313
<tag name="twig.extension"/>
1414
</service>
15+
16+
17+
<service id="AreanetAlohaThemeExtended\Subscriber\ProductSubscriber">
18+
<argument type="service" id="Shopware\Core\Content\Product\ProductVariationBuilder"/>
19+
<argument type="service" id="Shopware\Core\Content\Product\SalesChannel\Price\ProductPriceCalculator"/>
20+
<argument type="service" id="Shopware\Core\Content\Product\AbstractPropertyGroupSorter"/>
21+
<argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService" />
22+
<tag name="kernel.event_subscriber"/>
23+
</service>
1524
</services>
1625
</container>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace AreanetAlohaThemeExtended\Subscriber;
4+
5+
use Shopware\Core\Content\Product\AbstractIsNewDetector;
6+
use Shopware\Core\Content\Product\AbstractProductMaxPurchaseCalculator;
7+
use Shopware\Core\Content\Product\AbstractProductVariationBuilder;
8+
use Shopware\Core\Content\Product\AbstractPropertyGroupSorter;
9+
use Shopware\Core\Content\Product\DataAbstractionLayer\CheapestPrice\CheapestPriceContainer;
10+
use Shopware\Core\Content\Product\ProductDefinition;
11+
use Shopware\Core\Content\Product\ProductEvents;
12+
use Shopware\Core\Content\Product\SalesChannel\Price\AbstractProductPriceCalculator;
13+
use Shopware\Core\Framework\DataAbstractionLayer\Entity;
14+
use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
15+
use Shopware\Core\Framework\Log\Package;
16+
use Shopware\Core\System\SalesChannel\Entity\SalesChannelEntityLoadedEvent;
17+
use Shopware\Core\System\SystemConfig\SystemConfigService;
18+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
19+
20+
/**
21+
* @internal
22+
*/
23+
#[Package('inventory')]
24+
class ProductSubscriber implements EventSubscriberInterface
25+
{
26+
/**
27+
* @internal
28+
*/
29+
public function __construct(
30+
private readonly AbstractProductVariationBuilder $productVariationBuilder,
31+
private readonly AbstractProductPriceCalculator $calculator,
32+
private readonly AbstractPropertyGroupSorter $propertyGroupSorter,
33+
private readonly SystemConfigService $systemConfigService
34+
)
35+
{
36+
}
37+
38+
public static function getSubscribedEvents(): array
39+
{
40+
return [
41+
'sales_channel.' . ProductEvents::PRODUCT_LOADED_EVENT => 'salesChannelLoaded',
42+
'sales_channel.product.partial_loaded' => 'salesChannelLoaded',
43+
];
44+
}
45+
46+
public function salesChannelLoaded(SalesChannelEntityLoadedEvent $event): void
47+
{
48+
49+
$salesChannelContext = $event->getSalesChannelContext();
50+
$isEnabled = $this->systemConfigService->get('AreanetAlohaThemeExtended.config.mergeOptionsAndProperties', $salesChannelContext->getSalesChannelId());
51+
52+
if (!$isEnabled) {
53+
return;
54+
}
55+
56+
foreach ($event->getEntities() as $product) {
57+
58+
$assigns = [];
59+
60+
$properties = $product->get('properties') ? $product->get('properties') : null;
61+
$options = $product->get('properties') ? $product->get('options') : null;
62+
if ($properties) {
63+
if($options) $properties->merge($options);
64+
$assigns['sortedProperties'] = $this->propertyGroupSorter->sort($properties);
65+
}elseif ($options){
66+
$assigns['sortedProperties'] = $this->propertyGroupSorter->sort($options);
67+
}
68+
69+
$product->assign($assigns);
70+
71+
$this->productVariationBuilder->build($product);
72+
}
73+
74+
$this->calculator->calculate($event->getEntities(), $event->getSalesChannelContext());
75+
}
76+
77+
}

AreanetAlohaThemeExtended/src/Twig/CmsPageLoaderExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public function getFunctions()
2727
];
2828
}
2929

30-
public function loadCmsPage(array $context, string $cmsPageId)
30+
public function loadCmsPage(array $context, string $cmsPageId = null)
3131
{
32-
if (empty($context['context'])) {
32+
if (empty($context['context']) or empty($cmsPageId)) {
3333
return;
3434
}
3535

0 commit comments

Comments
 (0)