Access to list of the related item

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
ahmed31916
Advanced
Posts: 148
Joined: 14 Apr 2022, 12:15

Access to list of the related item

Post by ahmed31916 » 06 May 2022, 17:32

Hello,
I have this collection:

Code: Select all

^ Aimeos\Map {#1286 ▼
  #list: array:3 [▼
    18 => Aimeos\MShop\Product\Item\Standard {#1358 ▼
      -date: "2022-05-06 17:30:00"
      -available: true
      -modified: false
      -prefix: "product."
      #bdata: array:20 [▶]
      -listItems: array:4 [▶]
      -listRefItems: array:4 [▼
        "catalog" => array:2 [▶]
        "media" => array:1 [▶]
        "price" => array:1 [▼
          63 => Aimeos\MShop\Price\Item\Standard {#1364 ▼
            -currencyid: "EUR"
            -tax: null
            -precision: 2
            -available: true
            -modified: false
            -prefix: "price."
            #bdata: array:18 [▶]
            -listItems: []
            -listRefItems: []
            -listRmItems: []
            -listPrepared: false
            -listRmMap: []
            -listMap: []
            -listMax: 0
            -propItems: []
            -propRmItems: []
            -propMax: 0
          }
        ]
        "text" => array:1 [▶]
      ]
      -listRmItems: []
      -listPrepared: false
      -listRmMap: []
      -listMap: []
      -listMax: 7
      -propItems: []
      -propRmItems: []
      -propMax: 0
    }
    23 => Aimeos\MShop\Product\Item\Standard {#1276 ▶}
    25 => Aimeos\MShop\Product\Item\Standard {#1375 ▶}
  ]
  #sep: "/"
}
How can I access to the price value?
I tried like this:

Code: Select all

$item['price.value']
But didn't work!

User avatar
aimeos
Administrator
Posts: 7915
Joined: 01 Jan 1970, 00:00

Re: Access to list of the related item

Post by aimeos » 07 May 2022, 06:10

Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
ahmed31916
Advanced
Posts: 148
Joined: 14 Apr 2022, 12:15

Re: Access to list of the related item

Post by ahmed31916 » 07 May 2022, 13:12

thank you.
I wonder, Is this Ok?
Using getRefItem() in a blade, made me to add foreach loop for every related list. That mean I consumes site performance.
Is there another solution?

Code: Select all

@foreach ($products as $item)
      {{$item['product.label']}}
      @foreach ($item->getRefItems('price') as $itemee)
           {{($itemee->getValue() ?? '')}}
           {{($itemee->getCurrencyId() ?? '')}}
      @endforeach
@endforeach
Attachments
Screenshot 2022-05-07 160355.png
Screenshot 2022-05-07 160355.png (39.95 KiB) Viewed 668 times

User avatar
aimeos
Administrator
Posts: 7915
Joined: 01 Jan 1970, 00:00

Re: Access to list of the related item

Post by aimeos » 09 May 2022, 13:34

No, it's OK because you want to output all products and all prices.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply