Sending an email to each supplier

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!
Alexandre Bornand
Posts: 4
Joined: 01 Jul 2019, 14:40

Sending an email to each supplier

Post by Alexandre Bornand » 01 Jul 2019, 14:47

Hello, I would like to send an email to the suppliers of the items at the end of the payment process, containing the list of items, the supplier reference and the customer's contact details.

I'm a little lost in the way email works, if you can explain to me the steps to follow or the files to complete, it would be very nice of you.

I am under version 2018.10.
Laravel : 5.8.
Thank you in advance.
Sincerely BORNAND Alexandre.

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

Re: Sending an email to each supplier

Post by aimeos » 02 Jul 2019, 08:50

Create a delivery service decorator that is called when you execute the order/export/delivery job using

Code: Select all

./artisan aimeos:jobs order/export/delivery
It's documented there: https://aimeos.org/docs/Developers/Library/Service esp. https://aimeos.org/docs/Developers/Libr ... _decorator

For sending an e-mail, you can retrieve the mailer instance by

Code: Select all

$this->getContext()->getMail()
This instance has the following API:
- https://github.com/aimeos/aimeos-core/b ... /Iface.php
- https://github.com/aimeos/aimeos-core/b ... /Iface.php
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Alexandre Bornand
Posts: 4
Joined: 01 Jul 2019, 14:40

Re: Sending an email to each supplier

Post by Alexandre Bornand » 06 Aug 2019, 09:26

Hello, after 1 month of trying, I can't develop this mail module...
Is it possible to have a little more precision?

I created a provider in: "ext/.../lib/custom/src/MShop/Service/Provider/Delivery/Myprovider.php"
I followed the documentation and added the recovery of items....
But I don't understand how to retrieve the email from the inventory, nor don't understand I send an email.

Sorry for my ignorance, I have to return this project in 1 month and I would really like this feature to work.

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

Re: Sending an email to each supplier

Post by aimeos » 06 Aug 2019, 10:37

Maybe the Aimeos company can help you to get it implemented:
https://aimeos.com/aimeos-gmbh/contact
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Alexandre Bornand
Posts: 4
Joined: 01 Jul 2019, 14:40

Re: Sending an email to each supplier

Post by Alexandre Bornand » 06 Aug 2019, 12:12

Seriously?
I'll manage, thanks anyway.

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

Re: Sending an email to each supplier

Post by aimeos » 07 Aug 2019, 09:18

Sending emails is pretty obvious when you look at the interfaces:

Code: Select all

$mailer = $this->getContext()->getMail();
$msg = $mailer->createMessage();
$msg->setSender( '<email>' )->addTo( '<email>' )
	->setSubject( 'test' )->setBody( 'message' );
$mailer->send( $msg );
You can get the suppliercode from each product in the service provider with:

Code: Select all

$basket = $this->getOrderBase( $order->getBaseId(), \Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT );
foreach( $basket->getProducts() as $product ) {
	$suppliercode = $product->getSupplierCode();
}
Retrieve the supplier e-mail:

Code: Select all

$manager = \Aimeos\MShop::create( $this->getContext(), 'supplier' );
$email = $manager->findItem( $suppliercode )->getEmail();
Additionally, you only have to pass the supplier code in the frontend when a customer adds a product to the basket.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply