add from order-history with deactivated products -> error
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!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
add from order-history with deactivated products -> error
Hi,
all products are listed in the order history as available, even if they have been deactivated in the meantime.
I tried to get the product.status in account history to
What is your recommendation and the most efficient solution?
Thank you.
all products are listed in the order history as available, even if they have been deactivated in the meantime.
- customer adds a "history-basket" to his current basket
- history-basket contains at least one deactivated product
- -> Error Eintrag mit ID "1234" in "product.id" nicht gefunden {"userId":1,"exception":"[object] (Aimeos\\MShop\\Exception(code: 404): Eintrag mit ID \"1234\" in \"product.id\" nicht gefunden at \\vendor\\aimeos\\aimeos-core\\src\\MShop\\Common\\Manager\\DB.php:635)
I tried to get the product.status in account history to
- exclude deactivated products from being added to customers basket
- highlight products that are currently not available / deactivated
What is your recommendation and the most efficient solution?
Thank you.
Re: add from order-history with deactivated products -> error
The ProductGone plugin is only used if the product is already in the basket but removed before the checkout is completed.
The best option might be to catch the product exceptions here and add an error message to the basket view that at least one product couldn't be added to the basket:
https://github.com/aimeos/ai-client-htm ... #L192-L229
Are you able to provide a PR for the change?
The best option might be to catch the product exceptions here and add an error message to the basket view that at least one product couldn't be added to the basket:
https://github.com/aimeos/ai-client-htm ... #L192-L229
Are you able to provide a PR for the change?
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: add from order-history with deactivated products -> error
tried to create a PR but not sure if done right.
addProducts() function with try/catch:
Are there any options to highlight products that are currently not available / deactivated?
eg. set a "currently not availabe" badge or change to productname-color
thank you
addProducts() function with try/catch:
Code: Select all
protected function addProducts( \Aimeos\Base\View\Iface $view )
{
$context = $this->context();
$domains = ['attribute', 'catalog', 'media', 'price', 'product', 'text', 'locale/site'];
$basketCntl = \Aimeos\Controller\Frontend::create( $context, 'basket' );
$productCntl = \Aimeos\Controller\Frontend::create( $context, 'product' )->uses( $domains );
if( ( $prodid = $view->param( 'b_prodid', '' ) ) !== '' && $view->param( 'b_quantity', 0 ) > 0 )
{
try
{
$basketCntl->addProduct(
$productCntl->get( $prodid ),
(float) $view->param( 'b_quantity', 0 ),
(array) $view->param( 'b_attrvarid', [] ),
$this->getAttributeMap( $view->param( 'b_attrconfid', [] ) ),
array_filter( (array) $view->param( 'b_attrcustid', [] ) ),
(string) $view->param( 'b_stocktype', 'default' ),
$view->param( 'b_siteid' )
);
}
catch( \Exception $e )
{
//eg. product has been deactivated
$msg = $view->translate( 'client', "At least one product couldn't be added to the basket." );
$view->errors = array_merge( $view->get( 'errors', [] ), [$msg] );
}
}
else
{
foreach( (array) $view->param( 'b_prod', [] ) as $values )
{
if( ( $values['prodid'] ?? null ) && ( $values['quantity'] ?? 0 ) > 0 )
{
try
{
$basketCntl->addProduct( $productCntl->get( $values['prodid'] ),
(float) ( $values['quantity'] ?? 0 ),
array_filter( (array) ( $values['attrvarid'] ?? [] ) ),
$this->getAttributeMap( (array) ( $values['attrconfid'] ?? [] ) ),
array_filter( (array) ( $values['attrcustid'] ?? [] ) ),
(string) ( $values['stocktype'] ?? 'default' ),
$values['siteid'] ?? null
);
}
catch( \Exception $e )
{
//eg. product has been deactivated
$msg = $view->translate( 'client', "At least one product couldn't be added to the basket." );
$view->errors = array_merge( $view->get( 'errors', [] ), [$msg] );
}
}
}
}
$this->clearCached();
}
eg. set a "currently not availabe" badge or change to productname-color
thank you
Re: add from order-history with deactivated products -> error
Thanks! Highlighting products upfront is only possible if the original products are loaded too in the history view. It's possible to add "product" to the list of fetched domains here:
https://github.com/aimeos/ai-client-htm ... hp#L70-L83
https://github.com/aimeos/ai-client-htm ... hp#L70-L83
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