Skip to content

Commit

Permalink
Merge pull request #16 from LouisEiermann/compatibility-shopware6.5
Browse files Browse the repository at this point in the history
Compatibility shopware6.5
  • Loading branch information
vienthuong authored Feb 21, 2024
2 parents b529a1e + 06fc35e commit ca4a4a7
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 24 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vienthuong/recently-viewed-products",
"description": "Recently viewed products plugin",
"type": "shopware-platform-plugin",
"version": "1.2.0",
"version": "3.0.0",
"license": "MIT",
"authors": [
{
Expand All @@ -16,8 +16,8 @@
}
},
"require": {
"shopware/core": "^6.4.10.1",
"shopware/storefront": "^6.4.10.1"
"shopware/core": "^6.5.0.0",
"shopware/storefront": "^6.5.0.0"
},
"extra": {
"shopware-plugin-class": "RecentlyViewedProduct\\RecentlyViewedProduct",
Expand Down
13 changes: 6 additions & 7 deletions src/Controller/RecentProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
namespace RecentlyViewedProduct\Controller;

use RecentlyViewedProduct\Service\RecentlyViewedProductService;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\Routing\Annotation\RouteScope;
use Shopware\Core\Framework\Uuid\Uuid;
use Shopware\Core\System\SalesChannel\NoContentResponse;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
Expand All @@ -15,21 +14,21 @@
use Symfony\Component\Routing\Annotation\Route;

/**
* @RouteScope(scopes={"storefront"})
* @Route(defaults={"_routeScope"={"storefront"}})
*/
class RecentProductController extends StorefrontController
{
/**
* @var EntityRepositoryInterface
* @var EntityRepository
*/
private $cmsSlotRepo;
private EntityRepository $cmsSlotRepo;
/**
* @var RecentlyViewedProductService
*/
private $recentlyViewedProductService;
private RecentlyViewedProductService $recentlyViewedProductService;

public function __construct(
EntityRepositoryInterface $cmsSlotRepo,
EntityRepository $cmsSlotRepo,
RecentlyViewedProductService $recentlyViewedProductService
) {
$this->cmsSlotRepo = $cmsSlotRepo;
Expand Down
2 changes: 1 addition & 1 deletion src/DAL/FieldSerializer/RecentProductFieldSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function encode(
/**
* {@inheritdoc}
*/
public function decode(Field $field, $value)
public function decode(Field $field, $value): RecentProductCollection | null
{
if ($value === null) {
return null;
Expand Down
4 changes: 2 additions & 2 deletions src/RecentlyViewedProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Doctrine\DBAL\Connection;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Plugin;
Expand All @@ -24,7 +24,7 @@ public function uninstall(UninstallContext $uninstallContext): void
return;
}

/** @var EntityRepositoryInterface $cmsBlockRepo */
/** @var EntityRepository $cmsBlockRepo */
$cmsBlockRepo = $this->container->get('cms_block.repository');

$context = Context::createDefaultContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class RecentProductSliderPlugin extends Plugin {
ElementLoadingIndicatorUtil.remove(this.el);

if (!response || response.trim().length === 0) {
const hrBar = this.el.closest('.product-detail').querySelector('.recently-viewed-product-bar');
const hrBar = this.el.closest('.product-detail')?.querySelector('.recently-viewed-product-bar');

if (hrBar) {
hrBar.remove();
Expand Down
7 changes: 5 additions & 2 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<services>
<!-- Field Serializer -->
<service id="RecentlyViewedProduct\DAL\FieldSerializer\RecentProductFieldSerializer">
<argument type="service" id="Shopware\Core\Framework\DataAbstractionLayer\DefinitionInstanceRegistry"/>
<argument type="service" id="validator"/>
<argument type="service" id="Shopware\Core\Framework\DataAbstractionLayer\DefinitionInstanceRegistry"/>

<tag name="shopware.field_serializer"/>
</service>
Expand All @@ -20,14 +20,17 @@
<call method="setContainer">
<argument type="service" id="service_container"/>
</call>
<call method="setTwig">
<argument type="service" id="twig"/>
</call>
</service>

<!-- Entity Definitions-->
<service id="RecentlyViewedProduct\DAL\RecentlyViewedProductDefinition">
<tag name="shopware.entity.definition" entity="recently_viewed_product"/>
</service>

<service id="RecentlyViewedProduct\Service\RecentlyViewedProductService">
<service id="RecentlyViewedProduct\Service\RecentlyViewedProductService" public="true">
<argument type="service" id="recently_viewed_product.repository"/>
<argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
<argument type="service" id="sales_channel.product.repository"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{% sw_extends '@Storefront/storefront/base.html.twig' %}
{% sw_extends '@Storefront/storefront/layout/meta.html.twig' %}

{% block base_script_router %}
{% block layout_head_javascript_router %}
{{ parent() }}

<script>
window.router['frontend.recent-product-slider.content'] = '{{ path('frontend.recent-product-slider.content') }}';
</script>
Expand Down
12 changes: 6 additions & 6 deletions src/Service/RecentlyViewedProductService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
use Shopware\Core\Content\Cms\DataResolver\FieldConfigCollection;
use Shopware\Core\Content\Cms\SalesChannel\Struct\ProductSliderStruct;
use Shopware\Core\Content\Product\ProductCollection;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\EntitySearchResult;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\MultiFilter;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\RangeFilter;
use Shopware\Core\Framework\Uuid\Uuid;
use Shopware\Core\System\SalesChannel\Entity\SalesChannelRepositoryInterface;
use Shopware\Core\System\SalesChannel\Entity\SalesChannelRepository;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Shopware\Core\System\SystemConfig\SystemConfigService;

class RecentlyViewedProductService
{
/**
* @var EntityRepositoryInterface
* @var EntityRepository
*/
private $rpvRepository;

Expand All @@ -43,14 +43,14 @@ class RecentlyViewedProductService
private $productEntities;

/**
* @var SalesChannelRepositoryInterface
* @var SalesChannelRepository
*/
private $salesChannelProductRepository;

public function __construct(
EntityRepositoryInterface $rpvRepository,
EntityRepository $rpvRepository,
SystemConfigService $systemConfigService,
SalesChannelRepositoryInterface $salesChannelProductRepository
SalesChannelRepository $salesChannelProductRepository
) {
$this->rpvRepository = $rpvRepository;
$this->systemConfigService = $systemConfigService;
Expand Down

0 comments on commit ca4a4a7

Please sign in to comment.