barrelstrength / sprout

Sprout Marketing Suite modules for Craft CMS applications
https://sprout.barrelstrengthdesign.com
Other
2 stars 9 forks source link

Error when a loaded Condition does not specify an element type #329

Open elivz opened 2 months ago

elivz commented 2 months ago

Description

I ran into this issue when running Sprout Data Studio and Craft Commerce, but I don't believe it is specific to Commerce. An element condition is not required to specify an element type (using getElementType(), but the logic in your ConditionalHelper class assumes that that attribute will always be present.

A simple fix for this is to change line 13 of that file to:

$elementType = $event->sender?->elementType ?? null;

How to reproduce

Install Data Studio alongside Craft Commerce. Visit any Order detail page. You should receive error:

Getting unknown property: craft\commerce\elements\conditions\purchasables\CatalogPricingCondition::elementType

Sprout Version

5.0.1

Craft Version

5.3.6

Database Type Version

MySQL 8

anthonyjharrison commented 1 month ago

Adding another voice to this issue. It also impacts the front end website when querying and displaying products. Thank you @elivz for the workaround but hoping @BenParizek can roll out a core fix ASAP??