Price item not available

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!
User avatar
marlonsamot
Posts: 9
Joined: 13 Apr 2021, 12:26

Price item not available

Post by marlonsamot » 21 Apr 2021, 11:45

Hi please help with this. I have a problem it always return price item not available in this code.

Code: Select all

        $context = app()->make('aimeos.context')->get();
        $product_id = 15; // parameter
        $quantity = 1; // parameter
        $product = \Aimeos\Controller\Frontend::create( $context, 'product' )->get( $product_id, ['text', 'price', 'media', 'attribute'] );
        $addToBasket = \Aimeos\Controller\Frontend::create( $context, 'basket' )->addProduct( $product,$quantity );
        return $addToBasket;


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

Re: Price item not available

Post by aimeos » 24 Apr 2021, 09:19

Does your product has a price at all?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

mahmoud
Posts: 27
Joined: 27 Mar 2020, 22:01

Re: Price item not available

Post by mahmoud » 26 Apr 2021, 01:19

Hi,
I also have the same problem and the products have prices .
product_id =1 in the database after demo setup ;

Code: Select all

     $context = app()->make('aimeos.context')->get();     
 

        $product_id = 1; // parameter
        $quantity = 1; // parameter
        $product = \Aimeos\Controller\Frontend::create( $context, 'product' )->get( $product_id, ['text', 'price', 'media'] );
 
      
        return $product ;
Error:

Code: Select all

Aimeos\MShop\Price\Exception
Price item not available 
Thank you

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

Re: Price item not available

Post by aimeos » 27 Apr 2021, 05:20

Is a price for the used currency and quantity "1" available?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

mahmoud
Posts: 27
Joined: 27 Mar 2020, 22:01

Re: Price item not available

Post by mahmoud » 29 Apr 2021, 00:17

Yes,

Code: Select all

   public function addtobasket(){
        $context = app()->make('aimeos.context')->get();   
        $locale = $context->locale();
        $languageid = $locale->getLanguageId();
        $currencyid = $locale->getCurrencyId();         
       dd( $currencyid) ;      
    }
Display : "EUR"
But in function :

Code: Select all

public function getLowestPrice( \Aimeos\Map $priceItems, float $quantity, string $currencyId = null ) : \Aimeos\MShop\Price\Item\Iface
	{
		$priceList = $this->getPriceList( $priceItems, $currencyId );
 dd( "curency ".$currencyId); 
 .
 .
 .
 
		 
	}
https://github.com/aimeos/aimeos-core/b ... se.php#L37
Display null;

thank you

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

Re: Price item not available

Post by aimeos » 01 May 2021, 15:42

Check the following:

1.) Is the type and list type for the prices "default" because of:
https://github.com/aimeos/ai-controller ... d.php#L235

2.) Currency parameter for getLowestPrice() is always NULL (but that isn't a problem) because of:
https://github.com/aimeos/ai-controller ... se.php#L37
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

cchamilt
Posts: 3
Joined: 08 Nov 2021, 02:55

Re: Price item not available

Post by cchamilt » 08 Nov 2021, 18:00

Hi, sorry to jump in an old thread, but I am running in to a similar situation in 2021.10.

I can add the product into the normal cart, but I have to have a custom checkout process so I am trying to use addProduct. The context appears to have the right language and currency to match the product. Also, it does appear the default type and list are returning empty when calculating price.

Is there more documentation or explanation on how to add default type and list for a product?

Also, why does this code path appear to function in the normal aimeos catalog?

Thanks!

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

Re: Price item not available

Post by aimeos » 09 Nov 2021, 10:24

Do you pass the required domains when fetching the product?
https://github.com/aimeos/ai-client-htm ... d.php#L462
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

cchamilt
Posts: 3
Joined: 08 Nov 2021, 02:55

Re: Price item not available

Post by cchamilt » 10 Nov 2021, 01:24

Thanks, I am using

Code: Select all

        
$product = \Aimeos\Controller\Frontend::create( $context, 'product' )->find( 'prodname', ['attribute', 'media', 'price', 'product', 'text'] );
$addToBasket = \Aimeos\Controller\Frontend::create( $context, 'basket' )->addProduct( $product, 1);
Which I believe should be using the domain correctly?

cchamilt
Posts: 3
Joined: 08 Nov 2021, 02:55

Re: Price item not available

Post by cchamilt » 10 Nov 2021, 01:34

OK, I guess that no longer works, but looking at the code you gave me I think the following works:

Code: Select all

$domains = ['attribute', 'media', 'price', 'product', 'text'];
$product = \Aimeos\Controller\Frontend::create( $context, 'product' )->uses($domains);
$basket = \Aimeos\Controller\Frontend::create($context, 'basket');
$addToBasket = $basket->addProduct( $product->find( 'prodname'), 1);
Hope that helps anyone else trying!

Post Reply