code4business / freeproduct2

Magento2 extension that allows creating sales rules that add gift products.
64 stars 28 forks source link

PHP 8.1.7 error #39

Closed caos989 closed 2 years ago

caos989 commented 2 years ago

Preconditions

Settings / Sale Rules

Steps to reproduce

  1. Add product to cart

Expected result

  1. Product is in cart

Actual result

  1. Deprecated Functionality: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /home/xxx/public_html/magento244/vendor/code4business/freeproduct2/SalesRule/Action/AbstractGiftAction.php on line 86
caos989 commented 2 years ago

can be solved with: $skus = explode(',', $rule->getData(static::RULE_DATA_KEY_SKU) ?? '');

instead of $skus = explode(',', $rule->getData(static::RULE_DATA_KEY_SKU) );

got the solution from: https://stackoverflow.com/questions/71097927/php-8-1-explode-passing-null-to-parameter-2-string-of-type-string-is-de