Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from romanWienicke/master
Browse files Browse the repository at this point in the history
Added Properties for WishList
  • Loading branch information
MelvinAchterhuis authored Mar 10, 2022
2 parents c836282 + 9eef7a3 commit ab167e1
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [1.1.1] - 2022-03-10
### Added
- Support for wishlist page

## [1.1.0] - 2022-03-09
### Added
- Support for product search result page
Expand Down
5 changes: 5 additions & 0 deletions src/Resources/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@
<name>showSuggest</name>
<label>Show properties in search suggest</label>
</input-field>

<input-field type="bool">
<name>showWishList</name>
<label>Show properties in wishlist</label>
</input-field>
</card>
</config>
5 changes: 5 additions & 0 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
<tag name="kernel.event_subscriber"/>
</service>

<service id="Melv\PropertiesProductbox\Storefront\Subscriber\WishList">
<argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
<tag name="kernel.event_subscriber"/>
</service>

<!-- Resolvers !-->
<service id="Melv\PropertiesProductbox\Storefront\Resolver\SliderResolver">
<tag name="shopware.cms.data_resolver"/>
Expand Down
39 changes: 39 additions & 0 deletions src/Storefront/Subscriber/WishList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Melv\PropertiesProductbox\Storefront\Subscriber;

use Shopware\Core\System\SystemConfig\SystemConfigService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Storefront\Page\Wishlist\WishListPageProductCriteriaEvent;


class WishList implements EventSubscriberInterface
{
/**
* @var SystemConfigService
*/
public function __construct(
SystemConfigService $systemConfigService)
{
$this->systemConfigService = $systemConfigService;
}

public static function getSubscribedEvents()
{
return [
WishListPageProductCriteriaEvent::class => "handleRequest"
];
}

public function handleRequest(WishListPageProductCriteriaEvent $event): void
{
$salesChannelId = $event->getSalesChannelContext()->getSalesChannel()->getId();
$active = $this->systemConfigService->get('MelvPropertiesProductbox.config.showWishList', $salesChannelId);

if(!$active) {
return;
}

$event->getCriteria()->addAssociation('properties.group');
}
}

0 comments on commit ab167e1

Please sign in to comment.