I have attribute color_swatch
which is visual swatch and it has some items with images.
In my code I can take this data:
[swatch_id] => 57
[color_swatch] => Red
[swatch_id] => 58
[color_swatch] => Blue
[swatch_id] => 59
[color_swatch] => Black
How can I get image of the swatch using this data?
Best Answer
You can get swatch Image from this,
You can find Image value from
eav_attribute_option_swatch
table. Wherevalue
isImage path
andtype
1
is uploaded image filer and2
is color selected from color swatch.Note: I am against of direct loading object with
$objectManager
, for better impact you can inject it in your constructor. I have just given example how you can achieve it. `