Custom Module

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!
kishanbupadhyaya
Posts: 16
Joined: 20 Jun 2019, 10:16

Custom Module

Post by kishanbupadhyaya » 03 Jul 2019, 06:55

Hi Aimeos,

I want to add one custom module with different features simply i want to add home page with dynamic content how can i add that section in my site. i just want learn how you manage to add one page with controllers, classes and his view with data from database as per our need.

Thank you,
Kishan Upadhyay

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

Re: Custom Module

Post by aimeos » 03 Jul 2019, 08:42

In your Laravel Home controller, index action use the Aimeos frontend controller to retrieve the products you want to display:
- https://aimeos.org/docs/Laravel/Extend_Aimeos
- https://github.com/aimeos/ai-controller ... /Iface.php
- https://github.com/aimeos/ai-client-htm ... #L647-L655

For example:

Code: Select all

$context = $this->app->make('\Aimeos\Shop\Base\Context')->get();
$cntl = \Aimeos\Controller\Frontend::create( $context, 'product' );
$products = $cntl->uses( ['text', 'price', 'media'] )->category( '<catid>' )->search();
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

kishanbupadhyaya
Posts: 16
Joined: 20 Jun 2019, 10:16

Re: Custom Module

Post by kishanbupadhyaya » 03 Jul 2019, 10:15

Hi Aimeos,

Thank you for your reply it means to lot for me here i have started work as per given instruction but having this error in aimeos version 2018.07 i have attached screenshots of my work. please help me on this.

Thank you,
Kishan Upadhyay
Attachments
I'm getting error while using this
I'm getting error while using this
Screenshot_3.jpg (86.3 KiB) Viewed 3165 times
my HomeController code
my HomeController code
Screenshot_2.jpg (170.92 KiB) Viewed 3165 times
Error in browser
Error in browser
Screenshot_1.jpg (179.13 KiB) Viewed 3165 times

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

Re: Custom Module

Post by aimeos » 03 Jul 2019, 10:19

Version 2018.07 isn't supported any more and you should use at least 2018.10. If you start from scratch, use 2019.04 or the upcoming 2019.07 because the posted code is for these versions.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

kishanbupadhyaya
Posts: 16
Joined: 20 Jun 2019, 10:16

Re: Custom Module

Post by kishanbupadhyaya » 03 Jul 2019, 10:28

Hi Aimeos,

Here we are using laravel 5.7 and aimeos version 2018.07. we have also try to install aimeos version 2019.04 but get nothing means it's not working then help me to configure in laravel 5.7 with aimeos 2019.04

Thank You
Kishan Upadhyay

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

Re: Custom Module

Post by aimeos » 03 Jul 2019, 10:41

Upgrade to 2018.10 which should be rather flawless. The 2018.10 version uses the old API:
https://github.com/aimeos/ai-controller ... /Iface.php

Code: Select all

$context = $this->app->make('\Aimeos\Shop\Base\Context')->get();
$cntl = \Aimeos\Controller\Frontend\Factory::createController( $context, 'product' );
$filter = $cntl->createFilter();
$filter = $cntl->addFilterCategory( $filter, '<catid>' );
$products = $cntl->search( $filter );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

kishanbupadhyaya
Posts: 16
Joined: 20 Jun 2019, 10:16

Re: Custom Module

Post by kishanbupadhyaya » 05 Jul 2019, 07:32

Hi Aimeos,

I have updated my aimeos version 2018.10 and now i have tried to get things as per your instruction and i get data from your side and have some questions. And i have done code in way is it proper way to do it.

1) How do i get target url of product or category
2) How can i use your class like view.php, Aimeos.php from vendor

Thank you,
Kishan Upadhyay
Attachments
Screenshot_2.jpg
Screenshot_2.jpg (141.97 KiB) Viewed 3126 times
Screenshot_1.jpg
Screenshot_1.jpg (173.42 KiB) Viewed 3126 times

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

Re: Custom Module

Post by aimeos » 05 Jul 2019, 08:45

kishanbupadhyaya wrote: 05 Jul 2019, 07:32 1) How do i get target url of product or category
In your existing code where you use $this->config() to get the target, controller, action and url config:

Code: Select all

$url = $this->url( $detailTarget, $detailController, $detailAction, $params, [], $detailConfig );
Don't forget to prevent XSS by:

Code: Select all

$enc = $this->encoder();
$enc->attr( $url );
To display images:

Code: Select all

$enc->attr( $this->content( $mediaItem->getPreview() ) );
kishanbupadhyaya wrote: 05 Jul 2019, 07:32 2) How can i use your class like view.php, Aimeos.php from vendor
Don't know what you mean.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

kishanbupadhyaya
Posts: 16
Joined: 20 Jun 2019, 10:16

Re: Custom Module

Post by kishanbupadhyaya » 05 Jul 2019, 08:53

Hi Aimeos,

As per your instruction i have try to get url from category list but go this error.

Thank you,
Kishan Upadhyay
Attachments
Screenshot_3.jpg
Screenshot_3.jpg (97.02 KiB) Viewed 3103 times
Screenshot_2.jpg
Screenshot_2.jpg (247.08 KiB) Viewed 3106 times
Screenshot_1.jpg
Screenshot_1.jpg (243.81 KiB) Viewed 3106 times

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

Re: Custom Module

Post by aimeos » 05 Jul 2019, 12:27

If you want to use Blade templates, please read this article:
https://aimeos.org/docs/Laravel/Use_Blade_templates

Generate URLs by using the Laravel route() method.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply