Skip to content
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/CoreShop/Behat/Context/Setup/ProductContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function theSiteHasAProductPricedAt(string $productName, int $price = 100
*/
public function theProductIsPriced(ProductInterface $product, int $price, StoreInterface $store): void
{
$product->setStores(array_merge($product->getStores(), [$store->getId()]));
$product->setStores(array_merge($product->getStores() ?? [], [$store->getId()]));
$product->setStoreValuesOfType('price', $price, $store);

$this->saveProduct($product);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ protected function validateCategory(Request $request, CategoryInterface $categor
throw new NotFoundHttpException('category not found');
}

if (!in_array($this->getContext()->getStore()->getId(), array_values($category->getStores()))) {
if (!in_array($this->getContext()->getStore()->getId(), array_values($category->getStores() ?? []))) {
throw new NotFoundHttpException(
sprintf(sprintf('store (id %s) not available in category', $this->getContext()->getStore()->getId())),
sprintf('store (id %s) not available in category', $this->getContext()->getStore()->getId()),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected function validateProduct(Request $request, ProductInterface $product):
throw new NotFoundHttpException('product not found');
}

if (!in_array($this->container->get(StoreContextInterface::class)->getStore()->getId(), $product->getStores())) {
if (!in_array($this->container->get(StoreContextInterface::class)->getStore()->getId(), $product->getStores() ?? [])) {
throw new NotFoundHttpException('product not found');
}
}
Expand Down
22 changes: 18 additions & 4 deletions src/CoreShop/Bundle/ResourceBundle/CoreExtension/Multiselect.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,24 @@ public function preGetData($object, $params = [])

$data = $object->getObjectVar($this->getName());

if (null === $data) {
$data = [];
}

// Don't convert null to empty array to allow Pimcore's inheritance to work
// null means "not set" and will inherit from parent
// empty array means "explicitly set to no values" and won't inherit
return $data;
}

/**
* Checks if data is empty. Returns true only for null, not for empty arrays.
* This allows differentiating between "not set" (null) and "explicitly empty" ([]).
*
* @param array|null $data
*
* @return bool
*/
public function isEmpty($data): bool
{
// Only null is considered empty (will inherit from parent)
// Empty array [] is NOT empty (explicitly set to no values, won't inherit)
return null === $data;
}
}