vanilophp / demo

Vanilo Demo Application
https://vanilo.io/docs/
190 stars 54 forks source link

getThumbnailUrl on cart page not returning the image. #46

Closed daniel-farina closed 4 years ago

daniel-farina commented 4 years ago

Hello everyone,

For some reason the following is not returning a thumbnail:

{{ $item->product->getThumbnailUrl() ?: '/images/product.jpg' }}

resources/views/cart/show.blade.php

it works fine on the product and category page with:

{{ $product->getThumbnailUrl() }}

I also tried:

  @if($item->product->hasImage())
 YES:: {{$item->product->getThumbnailUrl() }}
@else
NO IMAGE
@endif

and I can confirm it returns no image.

Is this a known issue?, I'll keep on trying to figure it out and post an update if I find anything. Any help is appreciated!

Thanks

fulopattila122 commented 4 years ago

What does $item->product->getThumbnailUrl() exactly return? NULL or some broken URL?

daniel-farina commented 4 years ago

It returns the default:

<img src="/images/product.jpg" class="product-image">

i will try with a fresh installation soon to discard any changes I made first and test it on a fresh installation. I'll update this once I figure it out.

daniel-farina commented 4 years ago

@fulopattila122 If you do the following on the CartController on the show method, does it it return false to you?

    public function show()
    {
       $item = Cart::getItems()->first();
        dd($item->product->hasImage());

        return view('cart.show');
    }

Mine returns false, even though the item does have images . If I run this on the ProductController I get true.

    public function show(Product $product)
    {
        dd($product->hasImage());

        return view('product.show', ['product' => $product]);
    }
daniel-farina commented 4 years ago

We can close this ticket. The problem was the incorrect model information in the database after implementing a custom Product model.

Thank you!