Skip to content

Conversation

Copy link

Copilot AI commented Jan 7, 2026

When a variant's stores are explicitly cleared (all removed), Pimcore's inheritance incorrectly pulls stores from the parent product. This happens because null (not set) and [] (explicitly empty) were treated identically.

Changes

  • Multiselect::preGetData: Removed auto-conversion of null[], preserving inheritance semantics
  • Multiselect::isEmpty: Added override returning true only for null, not []
  • Callers: Added ?? [] to 3 call sites (ProductController, CategoryController, ProductContext)

Semantics

// Before: Both null and [] triggered inheritance
$variant->setStores([]);  // Cleared → inherits from parent ❌

// After: Only null triggers inheritance  
$variant->setStores([]);  // Cleared → stays empty ✓
$variant->setStores(null); // Not set → inherits from parent ✓

Applies to all Multiselect-based fields (Stores, Countries, Currencies, Carriers, PaymentProviders).

Original prompt

This section details on the original issue you should resolve

<issue_title>Differentiate between "empty" and "null" for "Stores" field</issue_title>
<issue_description>Hello,

as discussed per mail a few weeks ago:

For the "Stores" field, it would be nice to differentiate between "empty" and "null".

Right now, we have the following problem: If a variant has only one store assigned and that store gets removed, Pimcores inheritance kicks in and the variant inherits all stores from the parent product which is probably not the desired behavior in most cases.</issue_description>

Comments on the Issue (you are @copilot in this section)

@dpfaffenbauer but how? pimcore's inheritance works like that @dpfaffenbauer @YannicBoida Just trying to challenge ;)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 7, 2026 12:22
- Modified Multiselect::preGetData to preserve null values
- Added isEmpty method to treat null as empty but not []
- Updated all callers to handle null with ?? [] operator

Co-authored-by: dpfaffenbauer <5981845+dpfaffenbauer@users.noreply.github.com>
- Improve isEmpty docstring to specify array|null type
- Remove redundant double sprintf in CategoryController

Co-authored-by: dpfaffenbauer <5981845+dpfaffenbauer@users.noreply.github.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 7, 2026

Copilot AI changed the title [WIP] Implement differentiation between empty and null for Stores field Differentiate between null and empty array for Stores field to prevent unwanted inheritance Jan 7, 2026
Copilot AI requested a review from dpfaffenbauer January 7, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Differentiate between "empty" and "null" for "Stores" field

2 participants