Skip to content

Fix cart builder for product without image #21

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

Merged
merged 2 commits into from
Dec 13, 2024
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

v2.1.0
------

- Fix: CartBuilder fix call to member function getPath() on null

v2.0.0
------

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "alma/sylius-payment-plugin",
"type": "sylius-plugin",
"version": "2.1.0",
"keywords": [
"alma",
"buy now pay later",
Expand Down
2 changes: 1 addition & 1 deletion src/AlmaSyliusPaymentPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

final class AlmaSyliusPaymentPlugin extends Bundle
{
const VERSION = "2.0.0";
const VERSION = "2.1.0";

use SyliusPluginTrait;

Expand Down
4 changes: 2 additions & 2 deletions src/DataBuilder/CartDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ private function getProductPictureUrl(ProductVariantInterface $variant): string
/** @var ImageInterface[] $images */
$images = $subject->getImages();

if (count($mainPictures) > 0) {
if (!empty($mainPictures) && $mainPictures[0] !== null ) {
$path = $mainPictures[0]->getPath();
} elseif (count($images) > 0) {
} elseif (!empty($images) && $images[0] !== null) {
$path = $images[0]->getPath();
}

Expand Down