Catalog (Category) Import via Script

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!
mohal_04
Advanced
Posts: 108
Joined: 27 Mar 2018, 05:59

Catalog (Category) Import via Script

Post by mohal_04 » 28 Jun 2018, 12:15

Laravel: 5.6
Aimeos: 2018.04
PHP: 7.1.18

Hi guys,

I need to import product categories from old website into this new Laravel Aimeos setup. So, can you guide me how to do it using a PHP Script. Or is there any Laravel (Aimeos) Package that could help me?

In "mshop_catalog" table, I see all catalog items (categories). I can write a PHP script that will insert new categories in this table but I noticed that "mshop_catalog" table is using Nested Set Model, which is something new for me. So, can you help me understand, how I write a script that help me with adjusting Nested Set Model also.

Thanks!

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

Re: Catalog (Category) Import via Script

Post by aimeos » 29 Jun 2018, 10:54

You can use the catalog CSV importer if you can export your old categories in that format:
https://aimeos.org/docs/Developers/Cont ... g_from_CSV

The alternative is to create a job controller that uses the catalog manager to import an arbitrary format:
- https://aimeos.org/docs/Developers/Cont ... controller
- https://aimeos.org/api/latest/class-Aim ... ndard.html
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

mohal_04
Advanced
Posts: 108
Joined: 27 Mar 2018, 05:59

Re: Catalog (Category) Import via Script

Post by mohal_04 » 29 Jun 2018, 11:55

aimeos wrote:You can use the catalog CSV importer if you can export your old categories in that format:
https://aimeos.org/docs/Developers/Cont ... g_from_CSV

The alternative is to create a job controller that uses the catalog manager to import an arbitrary format:
- https://aimeos.org/docs/Developers/Cont ... controller
- https://aimeos.org/api/latest/class-Aim ... ndard.html
Hi,

Thanks for the help. I shall look into both of these solutions. Do we have similar solutions for Products, Customers, and Orders?

Please, reply!

Thanks!

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

Re: Catalog (Category) Import via Script

Post by aimeos » 29 Jun 2018, 19:21

For products, there's a CSV importer too. If you want to migrate from an existing foreign system (Magento, whatever), then the best way is to write setup tasks for migrating the data if you have access to both databases simultaniously: https://aimeos.org/docs/Developers/Library/Setup_tasks

There you have the possibility to use the Aimeos managers to migrate complex data like the category tree ($this->additional is the context item) but also have to possibility to use hand written SQL statements where needed.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

mohal_04
Advanced
Posts: 108
Joined: 27 Mar 2018, 05:59

Re: Catalog (Category) Import via Script

Post by mohal_04 » 02 Jul 2018, 07:43

aimeos wrote:You can use the catalog CSV importer if you can export your old categories in that format:
https://aimeos.org/docs/Developers/Cont ... g_from_CSV

The alternative is to create a job controller that uses the catalog manager to import an arbitrary format:
- https://aimeos.org/docs/Developers/Cont ... controller
- https://aimeos.org/api/latest/class-Aim ... ndard.html
Hi,

I have placed CSV file in "./public/csv" directory and changed configuration in "./config/shop.php" file like this:

Code: Select all

'controller' => [
	    'jobs' => array(
	        'catalog' => array(
	            'import' => array(
	                'csv' => array(
	                    'location' => 'public/csv/catalog.csv'
	                )
	            )
	        )
	    )
	],
Now, how can I run this import? I am doing this in Laravel 5.6. Please help!

Thanks!

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

Re: Catalog (Category) Import via Script

Post by aimeos » 02 Jul 2018, 08:26

Execute the "catalog/import/csv" job: https://aimeos.org/docs/Laravel/Configure_cronjobs
Your location has to be a directory by default as long as you don't configure this otherwise.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

mohal_04
Advanced
Posts: 108
Joined: 27 Mar 2018, 05:59

Re: Catalog (Category) Import via Script

Post by mohal_04 » 03 Jul 2018, 10:09

aimeos wrote:Execute the "catalog/import/csv" job: https://aimeos.org/docs/Laravel/Configure_cronjobs
Your location has to be a directory by default as long as you don't configure this otherwise.
Hi,

Thank you very much for your help! I successfully imported Categories. Now the next difficult task is to import products. Any helpful material on that?

Thanks!

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

Re: Catalog (Category) Import via Script

Post by aimeos » 03 Jul 2018, 10:33

Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

mohal_04
Advanced
Posts: 108
Joined: 27 Mar 2018, 05:59

Re: Catalog (Category) Import via Script

Post by mohal_04 » 04 Jul 2018, 08:02

Hi,

I have very different data in JSON format. Is there any alternative method of importing product data? I want to conditionally import catalog code.

Thanks!

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

Re: Catalog (Category) Import via Script

Post by aimeos » 05 Jul 2018, 15:59

Like said, create a job controller that uses the managers to import an arbitrary format directly:
- https://aimeos.org/docs/Developers/Cont ... controller
- https://aimeos.org/api/latest/namespace ... MShop.html
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply