Creating a new extension

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!
swat
Posts: 10
Joined: 15 Jul 2019, 13:01

Creating a new extension

Post by swat » 30 Jul 2019, 14:05

Good day.
I am trying to create a new extension. The extension will store site data in the database.
For this, I created a new directory automatically. I also added some files to it - ext \ myEXT \ admin \ jqadm \ src \ Admin \ Jqadm \ Settings \ Factory.php and Standard.php. And the presentation files are ext \ myEXT \ admin \ jqadm \ templates \ settings \ item-standard.php and add navbar.php and admin.php. After add ext \ myEXT \ lib \ custom \ src \ Settings \ Manager \ Factory.php and I’m not sure about the error class "\ Aimeos \ MShop \ Tag \ Manager \ Settings \ Standard". Tell me, I want to make a new extension, so which class should I inherit from in the file
ext \ myEXT \ admin \ jqadm \ src \ Admin \ Jqadm \ Settings \ Factory.php and Standard.php to not receive an error. So how is the extension different from the standard, should it be some kind of baseline? Help me .

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

Re: Creating a new extension

Post by aimeos » 31 Jul 2019, 08:27

Use this as your class header for your Factory class:

Code: Select all

class Factory
	extends \Aimeos\Admin\JQAdm\Common\Factory\Base
	implements \Aimeos\Admin\JQAdm\Common\Factory\Iface
Your class header for your Standard class must look like:

Code: Select all

class Standard
	extends \Aimeos\Admin\JQAdm\Common\Admin\Factory\Base
	implements \Aimeos\Admin\JQAdm\Common\Admin\Factory\Iface
The error you receive is due to using a wrong manager name. Look for

Code: Select all

\Aimeos\MShop::create( $context, 'tag/settings' )
which doesn't exist.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

swat
Posts: 10
Joined: 15 Jul 2019, 13:01

Re: Creating a new extension

Post by swat » 31 Jul 2019, 08:53

I understand that for the class that is ext \ myEXT \ admin \ jqadm \ src \ Admin \ Jqadm \ Settings \ Factory.php? But there and there it is. If for the class on the path ext \ myEXT \ lib \ custom \ src \ Settings \ Manager \ Factory.php, then after it asks to implement the create method and I get 2 identical classes - this is not correct. Tell me correctly, I understand - this class - ext \ myEXT \ admin \ jqadm \ src \ Admin \ Jqadm \ Settings \ Factory.php handles our tasks, but this ext \ myEXT \ lib \ custom \ src \ Settings \ Manager \ Factory .php rewrites the parent? In the class I need to describe the possibility of adding, editing data from the database, but how can I do this? Now I got a new Unable error to call method "getSubManager", /var/www/siteName/ext/ai-admin-jqadm/admin/jqadm/src/Admin/JQAdm/Base.php:51

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

Re: Creating a new extension

Post by aimeos » 31 Jul 2019, 09:02

The classes in "ext \ myEXT \ lib \ custom" have nothing to do with the JQAdm classes. The JQAdm factory creates the Standard JQAdm class and inside this class, you can use classes from "ext \ myEXT \ lib \ custom". If you have implemented such a class which must be named "\Aimeos\MShop\Settings\Manager\Standard" and located in ./lib/custom/src/MShop/Settings/Manager directory together with another Factory.php class (not to confuse with the JQAdm Factory class), you can use it in your JQAdm Standard class for storing data.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

swat
Posts: 10
Joined: 15 Jul 2019, 13:01

Re: Creating a new extension

Post by swat » 31 Jul 2019, 09:29

Thank. I seem to be beginning to understand my class Factory -> Standard and in the Standard class there is an appeal to Class "\ Aimeos \ MShop \ Settings \ Manager \ Factory" not available but since this class is not there I need to describe it in my extension? (I copied to my Factory and Standard classes from ext \ ai-admin-jqadm \ admin \ src \ aimeos \ admin \ jqadm \ group). Tell me how can I better access the database in which file? And what methods?)

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

Re: Creating a new extension

Post by aimeos » 01 Aug 2019, 08:58

It's depends what you want to achieve? Where will the settings be used? Would you like to merge them with the existing file based configuration?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

swat
Posts: 10
Joined: 15 Jul 2019, 13:01

Re: Creating a new extension

Post by swat » 01 Aug 2019, 09:45

In the admin panel of the site there will be a separate tab with the settings from the settings table, they will be displayed on it and they can be edited. Tell me how can I get this data from the database and edit (as I understand it, editing occurs when filling out the form and sending it and after receiving the data method and changing them in the database)

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

Re: Creating a new extension

Post by aimeos » 01 Aug 2019, 09:52

You can either store them directly in the database if you just want to merge them later to the config object in the context:

Code: Select all

$dbm = $this->getContext()->getDatabaseManager();
$conn = $dbm->acquire();
$stmt = $conn->create( 'REPLACE INTO settings (key, value) VALUES (?, ?)' );
$stmt->bind( 1, $key );
$stmt->bind( 2, $value );
$stmt->execute()->finish();
$dbm->release( $conn );
You can also use a Laravel Eloquent model for this instead.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

swat
Posts: 10
Joined: 15 Jul 2019, 13:01

Re: Creating a new extension

Post by swat » 05 Aug 2019, 10:00

Thank. I figured it out.
Tell me when saving my data should work out the save method which is Aimeos \ Admin \ JQAdm \ Settings Standard. But when you click save nothing happens, the action will enter the address / admin / default / jqadm / save / settings? Lang = en

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

Re: Creating a new extension

Post by aimeos » 06 Aug 2019, 08:08

You have to implement what should be done in the save() method of your JQAdm class.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply