Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Craft 5 / Commerce 5 broken by Redirects #334

Open
99ster opened this issue Oct 15, 2024 · 0 comments
Open

Craft 5 / Commerce 5 broken by Redirects #334

99ster opened this issue Oct 15, 2024 · 0 comments

Comments

@99ster
Copy link

99ster commented Oct 15, 2024

Description

Both the front-end and the CMS - Craft 5 / Commerce 5 are broken by Redirects:

yii\base\UnknownPropertyException: Getting unknown property: craft\commerce\elements\conditions\purchasables\CatalogPricingCondition::elementType in /var/www/html/vendor/yiisoft/yii2/base/Component.php:154
Stack trace:
#0 /var/www/html/vendor/barrelstrength/sprout/src/core/helpers/ConditionHelper.php(13): yii\base\Component->__get('elementType')
#1 [internal function]: BarrelStrength\Sprout\core\helpers\ConditionHelper::registerConditionRuleTypes(Object(craft\events\RegisterConditionRulesEvent))
#2 /var/www/html/vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Array, Object(craft\events\RegisterConditionRulesEvent))
#3 /var/www/html/vendor/yiisoft/yii2/base/Component.php(650): yii\base\Event::trigger('craft\base\cond...', 'registerConditi...', Object(craft\events\RegisterConditionRulesEvent))
#4 /var/www/html/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(128): yii\base\Component->trigger('registerConditi...', Object(craft\events\RegisterConditionRulesEvent))
#5 /var/www/html/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(242): craft\base\conditions\BaseCondition->getSelectableConditionRules()
#6 /var/www/html/vendor/craftcms/cms/src/base/conditions/BaseCondition.php(217): craft\base\conditions\BaseCondition->validateConditionRule(Object(craft\commerce\elements\conditions\purchasables\CatalogPricingCustomerConditionRule))
#7 /var/www/html/vendor/craftcms/commerce/src/services/CatalogPricing.php(613): craft\base\conditions\BaseCondition->addConditionRule(Object(craft\commerce\elements\conditions\purchasables\CatalogPricingCustomerConditionRule))
#8 /var/www/html/vendor/craftcms/commerce/src/elements/db/ProductQuery.php(716): craft\commerce\services\CatalogPricing->createCatalogPricesQuery(1)
#9 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1714): craft\commerce\elements\db\ProductQuery->afterPrepare()
#10 /var/www/html/vendor/yiisoft/yii2/db/QueryBuilder.php(227): craft\elements\db\ElementQuery->prepare(Object(craft\db\mysql\QueryBuilder))
#11 /var/www/html/vendor/yiisoft/yii2/db/Query.php(157): yii\db\QueryBuilder->build(Object(craft\commerce\elements\db\ProductQuery))
#12 /var/www/html/vendor/yiisoft/yii2/db/Query.php(320): yii\db\Query->createCommand(Object(craft\db\Connection))
#13 /var/www/html/vendor/craftcms/cms/src/db/Query.php(354): yii\db\Query->column(NULL)
#14 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1930): craft\db\Query->column(NULL)
#15 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(2002): craft\elements\db\ElementQuery->column(NULL)
#16 /var/www/html/vendor/twig/twig/src/Extension/CoreExtension.php(1754): craft\elements\db\ElementQuery->ids()
#17 /var/www/html/vendor/craftcms/cms/src/helpers/Template.php(148): Twig\Extension\CoreExtension::getAttribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\commerce\elements\db\ProductQuery), 'ids', Array, 'method', false, false, false, 6)
#18 /var/www/html/storage/runtime/compiled_templates/8a/8a8d6ca2db553f779dbac0a0af8a99da.php(50): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\commerce\elements\db\ProductQuery), 'ids', Array, 'method', false, false, false, 6)
#19 /var/www/html/vendor/twig/twig/src/Template.php(393): __TwigTemplate_370edad5045388d0090e4f9ebbca661e->doDisplay(Array, Array)
#20 /var/www/html/vendor/twig/twig/src/Template.php(349): Twig\Template->yield(Array, Array)
#21 /var/www/html/vendor/twig/twig/src/Template.php(364): Twig\Template->display(Array)
#22 /var/www/html/vendor/twig/twig/src/TemplateWrapper.php(35): Twig\Template->render(Array)
#23 /var/www/html/vendor/twig/twig/src/Environment.php(306): Twig\TemplateWrapper->render(Array)
#24 /var/www/html/vendor/craftcms/cms/src/web/View.php(501): Twig\Environment->render('products/index', Array)
#25 /var/www/html/vendor/craftcms/cms/src/web/View.php(554): craft\web\View->renderTemplate('products/index', Array)
#26 /var/www/html/vendor/craftcms/cms/src/web/TemplateResponseFormatter.php(57): craft\web\View->renderPageTemplate('products/index', Array, 'site')
#27 /var/www/html/vendor/yiisoft/yii2/web/Response.php(1109): craft\web\TemplateResponseFormatter->format(Object(craft\web\Response))
#28 /var/www/html/vendor/craftcms/cms/src/web/Response.php(339): yii\web\Response->prepare()
#29 /var/www/html/vendor/yiisoft/yii2/web/Response.php(340): craft\web\Response->prepare()
#30 /var/www/html/vendor/yiisoft/yii2/base/Application.php(390): yii\web\Response->send()
#31 /var/www/html/httpdocs/index.php(12): yii\base\Application->run()
#32 {main}

Screenshot 2024-10-14 at 15 33 16

How to reproduce

Install Sprout Redirects on Craft 5 with Commerce 5!

This has been confirmed as a bug by Craft support.

And this is the fix they suggested (which works):

replace line 13 in vendors/barrelstrength/sprout/src/core/helpers/ConditionHelper.php with:

if ($event->sender && property_exists($event->sender, 'elementType')) {
$elementType = $event->sender->elementType;
} else {
$elementType = null; // Handle the missing elementType case
}

Sprout Version

5.0.1

Craft Version

Craft Pro 5.4.7.1 + Craft Commerce Pro 5.1.3

Database Type Version

MySQL 8.0.36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant