Automatic image display on variant selection, is possbile?

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
SmallSeedBox
Posts: 2
Joined: 08 Oct 2018, 11:23

Automatic image display on variant selection, is possbile?

Post by SmallSeedBox » 08 Oct 2018, 12:04

Hi guys, after some trial and error I cannot seem to find a way to display a image for a product variant when selection an attribute(in my case color).
Assume a clean installation of aimeos 18.7.x and :
- add one product as selection type without any images(let's call it X);
- add two products as default Article(Y and Z);
- add one image for each Y and Z;
- define two attributes, type color, with different names(tried with domain media and products);
- Add Y and Z as variants for X;

Now, when looking at the products, the attributes are displayed correctly, both images are there to select. But no matter which attribute I select, the image does not change.
Looking at the template [image-partial-standard.php], i notice <?= $getVariantData( $mediaItem ); ?> , which should create in html the correct options. But, there is no such info.
I remember a few months ago I have done something like this trying to do something else, and managed to have one image which inherited the variant data, but never could replicate it, and when deleting that image and uploading again (the same one), there was no info.
thanks!

SmallSeedBox
Posts: 2
Joined: 08 Oct 2018, 11:23

Re: Automatic image display on variant selection, is possbil

Post by SmallSeedBox » 10 Oct 2018, 08:11

Meanwhile, I dug up a little bit.
First :
Php version : 7.0.32-0ubuntu0.16.04.1
Typo3 version : 8.7.15
Aimeos version : 18.7.3

I seems to find no way to add records here : `mshop_media_list`, through the admin interface . Before upgrading to 18.7.3, a somewhat managed to add some records here, which are visible as "data-variant-color="10" data-variant-width="11" data-variant-length="12" for each image. If I add an attribute[att_name], type color, with domain 'Media', and after that add it to the products 'Variant attributes', the attribute will change it's domain to 'Product'. No matter which attribute I add, or change the order (add image after the attribute, or in reverse), the above table is update. If I add records manually in Sql, the image attributes are visible, but does not seem the right way.

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

Re: Automatic image display on variant selection, is possbil

Post by aimeos » 16 Oct 2018, 06:36

The feature was accidentially removed but will be in 2018.10 LTS again.
Details at https://github.com/aimeos/aimeos-typo3/issues/76
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

ThomasD

Re: Automatic image display on variant selection, is possbil

Post by ThomasD » 28 Jan 2019, 12:19

Hi guys,

i have a problem with importing the media and show them with the variants.
Like above mentioned the mshop_media_list table stays empty. After opening the product in the aimeos panel in backend and saving it, it works like a charm and the table is filled with the .
Is there a way to write the lines to the database during import?

I'm using:
Typo3 9.5.4
PHP 7.2.11
MYSQL 5.6.19
and aimeos 18.10.5

my import TS looks like:

Code: Select all

controller.jobs.product.import.csv{
	location = [censored]/fileadmin/csv_imports/products
	container.type = Directory
	container.content = CSV
	csv.skip-lines = 1
}
controller.common.product.import.csv.mapping {
	item { 
		0 = product.code 
		1 = product.label
		2 = product.type 
		3 = product.status
	}
	text {
		4 = text.languageid
		5 = text.type
		6 = text.content
		7 = text.languageid
		8 = text.type
		9 = text.content
	}
	media {
		10 = media.url
		11 = media.url
		12 = media.url
		13 = media.url
		14 = media.url
		15 = media.url 
		16 = media.url
		17 = media.url
		18 = media.url
		19 = media.url
		20 = media.url
	}
	price {
		21 = price.currencyid
		22 = price.quantity
		23 = price.value
		24 = price.taxrate
	}
	attribute {
		25 = product.lists.type
		26 = attribute.type
		27 = attribute.code
		28 = product.lists.type
		29 = attribute.type
		30 = attribute.code
		31 = product.lists.type
		32 = attribute.type
		33 = attribute.code
	}
	catalog {
		34 = catalog.code
		35 = catalog.code
	}
	stock {
		36 = stock.stocklevel
	}
	product {
		37 = product.code
		38 = product.code
		39 = product.code
		40 = product.code
		41 = product.code
		42 = product.code
		43 = product.code
		44 = product.code
		45 = product.code
		46 = product.code
		47 = product.code
		48 = product.code
		49 = product.code
		50 = product.code
		51 = product.code
		52 = product.code
		53 = product.code
		54 = product.code
		55 = product.code
		56 = product.code
		57 = product.code
		58 = product.code
		59 = product.code
		60 = product.code
	}
}

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

Re: Automatic image display on variant selection, is possbil

Post by aimeos » 29 Jan 2019, 07:17

The CSV import currently doesn't care about that automatically. If you extend the "media" import processor in that way, variant specific images will be shown in the frontend without saving them in the admin interface:
https://github.com/aimeos/ai-controller ... d.php#L137

If the product has variant attributes ("$attributes = $product->getRefItems( 'attriubte', null, 'variant' );" does the job), assign them also to the media items ("$refItem" in that case) in a loop via "$refItem->addListItem( 'attribute', $newListItem, $attribute );".

Can you create a PR for that change? We would like to add it also to the core :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

ThomasD

Re: Automatic image display on variant selection, is possbil

Post by ThomasD » 29 Jan 2019, 19:11

First of all, thank you for your fast reply.
To be honest, unfortunately my php isn't the best.
So it will be hard for me to change
the code correctly, but i'll try it anyway. When i'm done I will start a PR.

Post Reply