Fetch product refItems with their stock levels

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
SaurabhSharma
Posts: 12
Joined: 23 Feb 2020, 10:32

Fetch product refItems with their stock levels

Post by SaurabhSharma » 07 Mar 2020, 07:55

I can get list of variant products for a particular product by using

Code: Select all

$item->getRefItems('product')
What I want is to get ref items along with their stock levels. Also I tried looping through refitems but there's no "stock" domain right?
So what method returns the stock data related to a product?

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

Re: Fetch product refItems with their stock levels

Post by aimeos » 08 Mar 2020, 10:35

There's no easy way yet to retrieve the stock items associated to the product items. getRefItems() won't help because these are only the items that are referenced by the mshop_product_list table.

There are already two methods that do something similar you need:
- getCatalogItems()
- getSupplierItems()

We've added a new method getStockItems() now and ported that back to 2019.10 too. If you execute

Code: Select all

composer req aimeos/aimeos-core:2019.10.x-dev
you can use the new method afterwards:

Code: Select all

$product->getStockItems()
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply