Add supplier drop down option to Aimeos Admin?

Help for integrating the Laravel package
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!
bill
Posts: 51
Joined: 24 Apr 2017, 17:51

Add supplier drop down option to Aimeos Admin?

Post by bill » 28 Jun 2017, 18:21

Hi

I am trying to add suppliers options for each product in the Aimeos admin and I need to get that in the front end?

currently see my screenshot I don't have that option

can you please help me?
Last edited by bill on 30 Jun 2017, 03:47, edited 1 time in total.

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

Re: Add supplier drop down option to Aimeos Admin?

Post by aimeos » 28 Jun 2017, 21:54

Do it the other way round: Go to the Supplier tab and add your products to that supplier. You can then fetch the supplier data by looking up the product ID.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

bill
Posts: 51
Joined: 24 Apr 2017, 17:51

Re: Add supplier drop down option to Aimeos Admin?

Post by bill » 29 Jun 2017, 12:58

Can you show me the code to fetch the supplier by product ID ? Assuming I am in the basket page ?

bill
Posts: 51
Joined: 24 Apr 2017, 17:51

Re: Add supplier drop down option to Aimeos Admin?

Post by bill » 29 Jun 2017, 18:53

What is really the best way to get it inside the client/html/basket/body-default.php ; I need to print the supplier Code for the product attached to it

I did this code below but seems its doing a search twice? one for 'supplier/list' and one for 'supplier'? is there away we can make it simpler?

Code: Select all

// NOT SURE WHY I cant get $conext variable inside the template files??
                $context = App::make('\Aimeos\Shop\Base\Context')->get(true);
                $manager = \Aimeos\MShop\Factory::createManager( $context, 'supplier/lists' );
                $search = $manager->createSearch( true );
                $expr = array(
                                    $search->compare( '==', 'supplier.lists.refid', $product->getProductId() ),
                $search->compare( '==', 'supplier.lists.domain', 'product' ),
                $search->getConditions(),
            );
            $search->setConditions( $search->combine( '&&', $expr ) );
            $supplierItems = $manager->searchItems( $search);

            foreach( $supplierItems as $item ) {
                    $supID = $item->getParentId() ;
                }
                // find the supplier code
                $manager = \Aimeos\MShop\Factory::createManager( $context, 'supplier' );
                $search = $manager->createSearch( true );
                $expr = array(
                    $search->compare( '==', 'supplier.id', $supID ),
                    $search->getConditions(),
                );
                $search->setConditions( $search->combine( '&&', $expr ) );
                $supplier = $manager->searchItems( $search);
                foreach( $supplier as $item ) {
                    print_r($item->getCode());
                }

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

Re: Add supplier drop down option to Aimeos Admin?

Post by aimeos » 30 Jun 2017, 04:37

You can shorten this to:

Code: Select all

$context = App::make('\Aimeos\Shop\Base\Context')->get(true);
$manager = \Aimeos\MShop\Factory::createManager( $context, 'supplier' );

$search = $manager->createSearch( true );
$expr = array(
    $search->compare( '==', 'supplier.lists.refid', $product->getProductId() ),
    $search->compare( '==', 'supplier.lists.domain', 'product' ),
    $search->getConditions(),
);
$search->setConditions( $search->combine( '&&', $expr ) );

print_r( $manager->searchItems(  $search ) );
The reason why the context isn't available in the templates is that templates are only for creating the output based on the assigned data. Fetching and managing the data is the task of the client (controller). This separation is extremely important to be able to maintain applications in the long run.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

bill
Posts: 51
Joined: 24 Apr 2017, 17:51

Re: Add supplier drop down option to Aimeos Admin?

Post by bill » 30 Jun 2017, 21:20

If I want to add this code in our /ext folder for the client controller , can I override or add it to the (client) controller instead inside the template code?

is that possible and how we could do that?

Thanks in advance

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

Re: Add supplier drop down option to Aimeos Admin?

Post by aimeos » 01 Jul 2017, 10:43

To dynamically add data to views, please have a look at how to implement a client decorator:
https://aimeos.org/docs/Developers/Html ... components

The context is decorators is already available via

Code: Select all

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

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: Add supplier drop down option to Aimeos Admin?

Post by MikaelNazarenko » 29 Jun 2021, 05:21

Hi community!

For me this is also actual problem now. I would like to add possibility in admin to set supplier inside product..

Was something changed now regarding to this problem ?

My components are pretty fresh I think:

Code: Select all

aimeos/ai-admin-jqadm                     2021.04.6 Aimeos Vue.js+Bootstrap admin interface
aimeos/ai-admin-jsonadm                   2021.04.1 Aimeos ai-admin-jsonadm extension
aimeos/ai-client-html                     2021.04.7 Aimeos ai-client-html extension
aimeos/ai-client-jsonapi                  2021.04.1 Aimeos JSON API extension
aimeos/ai-cms-grapesjs                    2021.04.2 Aimeos GrapesJS CMS extension
aimeos/ai-controller-frontend             2021.04.1 Aimeos ai-controller-frontend extension
aimeos/ai-controller-jobs                 2021.04.3 Aimeos ai-controller-jobs extension
aimeos/ai-gettext                         2021.04.1 Aimeos Gettext extension
aimeos/ai-laravel                         2021.04.3 Laravel adapter for Aimeos web shops and e-commerce solutions
aimeos/ai-swiftmailer                     2021.04.1 SwiftMailer adapter for Aimeos web shops and e-commerce solutions
aimeos/aimeos-core                        2021.04.3 Full-featured e-commerce components for high performance online shops
aimeos/aimeos-laravel                     2021.04.4 Professional, full-featured and high performance Laravel e-commerce package for online shops and complex B2B projects
aimeos/map                                2.2.0     Easy and elegant handling of PHP arrays as array-like map objects similar to jQuery and Laravel Collections

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

Re: Add supplier drop down option to Aimeos Admin?

Post by aimeos » 29 Jun 2021, 05:48

In the current version this is already possible in the "Supplier" tab of the product detail view of the admin backend.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: Add supplier drop down option to Aimeos Admin?

Post by MikaelNazarenko » 29 Jun 2021, 06:00

Great! Thank you so much for the quick help ! So seems I need to update aimeos/aimeos-core ? What the current version ?

Post Reply