Bagisto Forum

    Bagisto

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Sort variants by price in configurable product in API

    Bug Report
    2
    3
    1357
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      AkashWeybee last edited by

      How can I Sort variants by price in the configurable product in API?

      ea45270f-9dbf-4b41-b880-4b644a761a02-image.png

      1 Reply Last reply Reply Quote 0
      • devansh-webkul
        devansh-webkul last edited by

        Hi @AkashWeybee,

        This is customization, I can only help you with the code rest you need to do it at your end.

        These variants are coming from here,
        https://github.com/bagisto/bagisto/blob/5a4ea8db9c5ef6eb784365a8dc3aac6dba7c09ee/packages/Webkul/API/Http/Resources/Catalog/Product.php#L219

        You need to create one more method in the model let's say variantsByPriceOrder which will retrieve based on the price, then call it,

        return [
            'variants' => $product->variantsByPriceOrder
        ];
        
        A 1 Reply Last reply Reply Quote 0
        • A
          AkashWeybee @devansh-webkul last edited by

          @devansh-webkul Thank you, sir!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post