Bagisto: getting different variant of a configurable product in front end

Created on 15 Apr 2020  路  4Comments  路  Source: bagisto/bagisto

hi in the home page i want to receive the images and some other attributes of all variants of a configurable product in homepage in velocity theme . any idea how can i get that . thanks

Help Wanted

Most helpful comment

Sample code to do so on blade:
@if (WebkulProductHelpersProductType::hasVariants($product->type))
@foreach($product->variants as $key => $variant)
$variantImage = $variant->images;
@endforeach
@endif

@farshadff Hope this helps.

All 4 comments

Sample code to do so on blade:
@if (WebkulProductHelpersProductType::hasVariants($product->type))
@foreach($product->variants as $key => $variant)
$variantImage = $variant->images;
@endforeach
@endif

@farshadff Hope this helps.

@dejavuejs thanks mate i will let you know the result as soon as i try that . thanks a lot <3

Hello @farshadff

You can also get product variants using relationship.

$product->variants

Return empty collection in case of no variant.

Feel free to reopen this if you still have any query.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AkashWeybee picture AkashWeybee  路  3Comments

ms-gsp picture ms-gsp  路  4Comments

marcelowu picture marcelowu  路  4Comments

accountmine picture accountmine  路  7Comments

bergstar picture bergstar  路  4Comments