show product sclider based on product code
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!
- mahammadareef
- Posts: 54
- Joined: 14 Oct 2022, 11:54
show product sclider based on product code
I have a requirement I want to show the list of products based on the product_codes list given on the admin side where I want to keep one option in the backend where I have to add product_code ...how to do this? please help me
- mahammadareef
- Posts: 54
- Joined: 14 Oct 2022, 11:54
Re: show product sclider based on product code
Code: Select all
public function data( \Aimeos\Base\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\Base\View\Iface
{
$texts = [];
$context = $this->context();
$config = $context->config();
$cntl = \Aimeos\Controller\Frontend::create( $context, 'product' );
$template = $config->get( 'client/html/additional/productslider/template-header', 'additional/productslider/header' );
$domains = $config->get( 'client/html/catalog/lists/domains', ['media', 'media/property', 'price', 'text'] );
// $domains = $context->config()->get( 'client/html/account/favorite/domains', ['text', 'price', 'media'] );
if( $view->config( 'client/html/cms/page/basket-add', false ) ) {
$domains = array_merge_recursive( $domains, ['product' => ['default'], 'attribute' => ['variant', 'custom', 'config']] );
}
$products = ( clone $cntl )->uses( $domains )
->category( 1, 'default' )
->slice( 0,10 )
->search();
$this->addMetaItems( $products, $expire, $tags );
$tview = $context->view()->set( 'products', $products );
if( !$products->isEmpty() && (bool) $config->get( 'client/html/catalog/lists/stock/enable', true ) === true )
{
$tview->itemsStockUrl = $this->getStockUrl( $tview, $products );
}
$view->sliderItems = $products;
return parent::data( $view, $tags, $expire );
}
this is the code to fetch products category vise, the same way I need the products list of given product_codes of products !
for example if ` $product.code = "demo-selection-article,demo-article,Demo-variant-article-4"; `
this is the condition i want to list the products details of these 3 articles only
Thankyou
- mahammadareef
- Posts: 54
- Joined: 14 Oct 2022, 11:54
Re: show product sclider based on product code
i tried with this code ,
$products = ( clone $cntl )->uses( $domains )
->filter()->add( ['product.code' => ['demo-selection-article-3','demo-selection-article-4'] ] )->slice( 0,10 )
->slice( 0,10 )
->search();
it giving me this error
/home2
Called unknown macro "filter" on class "Aimeos\Controller\Frontend\Product\Standard"
#0
$products = ( clone $cntl )->uses( $domains )
->filter()->add( ['product.code' => ['demo-selection-article-3','demo-selection-article-4'] ] )->slice( 0,10 )
->slice( 0,10 )
->search();
it giving me this error
/home2
Called unknown macro "filter" on class "Aimeos\Controller\Frontend\Product\Standard"
#0
Re: show product sclider based on product code
filter() is a method of the mangers but the frontend controllers have a simpler interface. Use compare() instead:
See: https://github.com/aimeos/ai-controller ... hp#L53-L62
Code: Select all
$products = $cntl->uses( $domains )
->compare( '==', 'product.code', ['demo-selection-article-3','demo-selection-article-4'] )
->slice( 0,10 )
->search();
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