Skip to content
Open
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
13 changes: 7 additions & 6 deletions Classes/Controller/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected function initializeAction(): void
}
}

$this->settings['addToCartByAjax'] = isset($this->settings['addToCartByAjax']) ? (int)$this->settings['addToCartByAjax'] : 0;
$this->settings['addToCartByAjax'] = (int)($this->settings['addToCartByAjax'] ?? 0);
}

/**
Expand All @@ -80,7 +80,7 @@ protected function createDemandObjectFromSettings(array $settings): ProductDeman
if (!empty($this->searchArguments['title'])) {
$demand->setTitle($this->searchArguments['title']);
}
if ($settings['orderBy']) {
if ($settings['orderBy'] ?? false) {
if (
!isset($settings['orderDirection'])
&& $settings['orderDirection'] !== 'DESC'
Expand All @@ -97,7 +97,7 @@ protected function createDemandObjectFromSettings(array $settings): ProductDeman

protected function addCategoriesToDemandObjectFromSettings(ProductDemand $demand): void
{
if ($this->settings['categoriesList']) {
if ($this->settings['categoriesList'] ?? false) {
$selectedCategories = GeneralUtility::intExplode(
',',
$this->settings['categoriesList'],
Expand All @@ -106,7 +106,7 @@ protected function addCategoriesToDemandObjectFromSettings(ProductDemand $demand

$categories = [];

if ($this->settings['listSubcategories']) {
if ($this->settings['listSubcategories'] ?? false) {
foreach ($selectedCategories as $selectedCategory) {
$category = $this->categoryRepository->findByUid($selectedCategory);
$categories = array_merge(
Expand Down Expand Up @@ -333,14 +333,15 @@ protected function addCacheTags(iterable $products): void

protected function restoreSession(): void
{
$cart = $this->sessionHandler->restoreCart($this->cartConfiguration['settings']['cart']['pid']);
$pid = (int)($this->cartConfiguration['settings']['cart']['pid'] ?? 0);
$cart = $this->sessionHandler->restoreCart($pid);

if ($cart instanceof Cart) {
$this->cart = $cart;
return;
}

$this->cart = $this->cartUtility->getNewCart($this->cartConfiguration);
$this->sessionHandler->writeCart($this->cartConfiguration['settings']['cart']['pid'], $this->cart);
$this->sessionHandler->writeCart($pid, $this->cart);
}
}