Page 1 of 1
Mapping different products
Posted: 25 Sep 2017, 21:33
by Bevi
Hi, how am I supposed to make a different mapping for each category? Is it even possible, or will I have to make a new shop for every kind of product?
Re: Mapping different products
Posted: 26 Sep 2017, 11:11
by aimeos
Can you explain that in more detail please?
Re: Mapping different products
Posted: 26 Sep 2017, 14:39
by Bevi
I have the following categories in my shop:
1.Wheels
2.Modeling
3.Clothes
4Electronics
each of them needs a different mapping in order to import their own csv, but, as far as I know, I could only make 1 type of mapping in the shop.php.
What should I do?
Re: Mapping different products
Posted: 26 Sep 2017, 15:32
by aimeos
You can copy and extend from the existing factory (
https://github.com/aimeos/ai-controller ... actory.php), e.g. to a sub-directory controller/jobs/src/Controller/Jobs/Product/Import/Csv/Clothes/Factory.php in your own Aimeos extension. In the createController() method of your new factory add this:
Code: Select all
public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null )
{
$mapping = [
// ...
];
$context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping );
return parent::createController( $context, $aimeos, $name );
}
Then, you can execute the importer for each category with the required mapping:
Code: Select all
artisan aimeos:jobs product/import/csv/clothes
Re: Mapping different products
Posted: 26 Sep 2017, 21:39
by Bevi
I'm getting this error:
Code: Select all
[Symfony\Component\Debug\Exception\FatalThrowableError] Call to undefined method Aimeos\Controller\Jobs\Common\Factory\Base::createController()
Are you sure it's:
Code: Select all
return parent::createController( $context, $aimeos, $name );
?
Re: Mapping different products
Posted: 26 Sep 2017, 22:00
by aimeos
You may have forgotten to extend from the existing class like this:
Code: Select all
class Factory
extends \Aimeos\Controller\Jobs\Product\Import\Csv\Factory
implements \Aimeos\Controller\Jobs\Common\Factory\Iface
Re: Mapping different products
Posted: 27 Sep 2017, 16:03
by Bevi
I can now execute
Code: Select all
php artisan aimeos:jobs "product/import/csv/pneumatici"
(please note "pneumatici" is my product name), but I'm still reading from the mapping array in shop.php
So i tried to put 'name' => 'Pneumatici', in the shop.php (not sure if it's the right thing to do) and now I'm getting this error:
Code: Select all
[Aimeos\Controller\Jobs\Exception]
Class "\Aimeos\Controller\Jobs\Product\Import\Csv\Pneumatici" not available
What should I do from here?
Re: Mapping different products
Posted: 28 Sep 2017, 08:02
by aimeos
The full code for the file "controller/jobs/src/Controller/Jobs/Product/Import/Csv/Clothes/Standard.php" in you own Aimeos extension is:
Code: Select all
namespace Aimeos\Controller\Jobs\Product\Import\Csv\Clothes;
class Factory
extends \Aimeos\Controller\Jobs\Product\Import\Csv\Factory
implements \Aimeos\Controller\Jobs\Common\Factory\Iface
{
public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null )
{
$mapping = [
// mapping for clothes
];
$context->getConfig()->set( 'controller/jobs/product/import/csv/mapping', $mapping );
return parent::createController( $context, $aimeos, $name );
}
}
Then you can execute:
Code: Select all
php artisan aimeos:jobs "product/import/csv/clothes"
Re: Mapping different products
Posted: 14 Nov 2017, 09:02
by antonlinderer
Just a small correction... the mentioned code is for file "controller/jobs/src/Controller/Jobs/Product/Import/Csv/Clothes/Factory.php" and thel code for the file "controller/jobs/src/Controller/Jobs/Product/Import/Csv/Clothes/Standard.php" remains the same as in the file "controller/jobs/src/Controller/Jobs/Product/Import/Csv/Standard.php"