Price item not available
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!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
- marlonsamot
- Posts: 9
- Joined: 13 Apr 2021, 12:26
Price item not available
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;
Re: Price item not available
Does your product has a price at all?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Price item not available
Hi,
I also have the same problem and the products have prices .
product_id =1 in the database after demo setup ;
Error:
Thank you
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 ;
Code: Select all
Aimeos\MShop\Price\Exception
Price item not available
Re: Price item not available
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, give us a star
If you like Aimeos, give us a star
Re: Price item not available
Yes,
Display : "EUR"
But in function :
https://github.com/aimeos/aimeos-core/b ... se.php#L37
Display null;
thank you
Code: Select all
public function addtobasket(){
$context = app()->make('aimeos.context')->get();
$locale = $context->locale();
$languageid = $locale->getLanguageId();
$currencyid = $locale->getCurrencyId();
dd( $currencyid) ;
}
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);
.
.
.
}
Display null;
thank you
Re: Price item not available
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
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, give us a star
If you like Aimeos, give us a star
Re: Price item not available
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!
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!
Re: Price item not available
Do you pass the required domains when fetching the product?
https://github.com/aimeos/ai-client-htm ... d.php#L462
https://github.com/aimeos/ai-client-htm ... d.php#L462
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Price item not available
Thanks, I am using
Which I believe should be using the domain correctly?
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);
Re: Price item not available
OK, I guess that no longer works, but looking at the code you gave me I think the following works:
Hope that helps anyone else trying!
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);