Skip to content

Commit

Permalink
[TASK] Use DetailPageLinkFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
rintisch committed Jun 24, 2024
1 parent a495b19 commit bd2ac06
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Classes/EventListener/Create/CreateCartProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
* LICENSE file that was distributed with this source code.
*/

use Extcode\Cart\Domain\Model\Cart\DetailPageLinkFactoryInterface;
use Extcode\Cart\Domain\Model\Cart\Product;
use Extcode\CartProducts\Event\RetrieveProductsFromRequestEvent;

class CreateCartProduct
{
public function __construct(protected DetailPageLinkFactoryInterface $detailPageLinkFactory)
{}
public function __invoke(RetrieveProductsFromRequestEvent $event): void
{
$request = $event->getRequest();
Expand Down Expand Up @@ -53,10 +56,16 @@ public function __invoke(RetrieveProductsFromRequestEvent $event): void
$cartProduct->setIsVirtualProduct(true);
}

$cartProduct->addDetailPageParameter('pageUid', $request->getArgument('detailPageUid'));
$cartProduct->addDetailPageParameter('extensionName', 'cartproducts');
$cartProduct->addDetailPageParameter('pluginName', 'products');
$cartProduct->addDetailPageParameter('controller', 'product');
if($request->getArgument('detailPageUid')){
$detailPageLink = $this->detailPageLinkFactory->getDetailPageLink(
(int)$request->getArgument('detailPageUid'),
'cartproducts',
'products',
'product'
);
$cartProduct->setDetailPageLink($detailPageLink);
}


$event->setCartProduct($cartProduct);
}
Expand Down

0 comments on commit bd2ac06

Please sign in to comment.