Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import Media: Duplicate lines on the table 'media_gallery_value' #186

Open
PierreLeMaguer opened this issue Apr 27, 2018 · 2 comments
Open

Comments

@PierreLeMaguer
Copy link

Hi,

Magento: 2.1.12
Pimgento: ~100.2.0
I was facing this situation :
I am trying to import 4 images for one product. The temporary pimgento table for media was completed as following :

select * from tmp_pimgento_entities_media\G
*************************** 1. row ***************************
sku: 485690
entity_id: 12082
attribute_id: 87
store_id: 0
value_id: 23616
record_id: NULL
media_original: files/485690/media_photo/GTA-GD51NAT.png
media_cleaned: 485690-485690-media_photo-gta-gd51nat.png
media_value: /4/8/485690-485690-media_photo-gta-gd51nat.png
position: 0
id: 1
*************************** 2. row ***************************
sku: 485690
entity_id: 12082
attribute_id: 88
store_id: 0
value_id: 23616
record_id: NULL
media_original: files/485690/media_photo/GTA-GD51NAT.png
media_cleaned: 485690-485690-media_photo-gta-gd51nat.png
media_value: /4/8/485690-485690-media_photo-gta-gd51nat.png
position: 0
id: 2
*************************** 3. row ***************************
sku: 485690
entity_id: 12082
attribute_id: 89
store_id: 0
value_id: 23616
record_id: NULL
media_original: files/485690/media_photo/GTA-GD51NAT.png
media_cleaned: 485690-485690-media_photo-gta-gd51nat.png
media_value: /4/8/485690-485690-media_photo-gta-gd51nat.png
position: 0
id: 3
*************************** 4. row ***************************
sku: 485690
entity_id: 12082
attribute_id: 133
store_id: 0
value_id: 23616
record_id: NULL
media_original: files/485690/media_photo/GTA-GD51NAT.png
media_cleaned: 485690-485690-media_photo-gta-gd51nat.png
media_value: /4/8/485690-485690-media_photo-gta-gd51nat.png
position: 0
id: 4
*************************** 5. row ***************************
sku: 485690
entity_id: 12082
attribute_id: 178
store_id: 0
value_id: 23617
record_id: NULL
media_original: files/485690/media_photo1/GTA-GD51NAT-2.png
media_cleaned: 485690-485690-media_photo1-gta-gd51nat-2.png
media_value: /4/8/485690-485690-media_photo1-gta-gd51nat-2.png
position: 0
id: 5
*************************** 6. row ***************************
sku: 485690
entity_id: 12082
attribute_id: NULL
store_id: 0
value_id: 23616
record_id: NULL
media_original: files/485690/media_photo/GTA-GD51NAT.png
media_cleaned: 485690-485690-media_photo-gta-gd51nat.png
media_value: /4/8/485690-485690-media_photo-gta-gd51nat.png
position: 0
id: 6
*************************** 7. row ***************************
sku: 485690
entity_id: 12082
attribute_id: NULL
store_id: 0
value_id: 23617
record_id: NULL
media_original: files/485690/media_photo1/GTA-GD51NAT-2.png
media_cleaned: 485690-485690-media_photo1-gta-gd51nat-2.png
media_value: /4/8/485690-485690-media_photo1-gta-gd51nat-2.png
position: 1
id: 7
*************************** 8. row ***************************
sku: 485690
entity_id: 12082
attribute_id: NULL
store_id: 0
value_id: 23618
record_id: NULL
media_original: files/485690/media_photo2/GTA-GD51NAT-3.png
media_cleaned: 485690-485690-media_photo2-gta-gd51nat-3.png
media_value: /4/8/485690-485690-media_photo2-gta-gd51nat-3.png
position: 2
id: 8
*************************** 9. row ***************************
sku: 485690
entity_id: 12082
attribute_id: NULL
store_id: 0
value_id: 23619
record_id: NULL
media_original: files/485690/media_photo3/GTA-GD51NAT-4.png
media_cleaned: 485690-485690-media_photo3-gta-gd51nat-4.png
media_value: /4/8/485690-485690-media_photo3-gta-gd51nat-4.png
position: 3
id: 9

And after the media import, I had for the table catalog_product_entity_media_gallery_value :

value_id | store_id | entity_id | label | position | disabled | record_id |
+----------+----------+-----------+-------+----------+----------+-----------+
23644 | 0 | 12082 | | 0 | 0 | 91429 |
| 23644 | 0 | 12082 | | 0 | 0 | 91430 |
| 23644 | 0 | 12082 | | 0 | 0 | 91431 |
| 23644 | 0 | 12082 | | 0 | 0 | 91432 |
| 23645 | 0 | 12082 | | 0 | 0 | 91433 |
| 23644 | 0 | 12082 | | 0 | 0 | 91434 |
| 23645 | 0 | 12082 | | 1 | 0 | 91435 |
| 23646 | 0 | 12082 | | 2 | 0 | 91436 |
| 23647 | 0 | 12082 | | 3 | 0 | 91437 |

We can see that there are several lines similar (first 4). If I save in the backoffice Magento the product, the table catalog_product_entity_media_gallery_value is updated and I had :

value_id | store_id | entity_id | label | position | disabled | record_id |
+----------+----------+-----------+-------+----------+----------+-----------+
| 23644 | 0 | 12082 | | 0 | 0 | 91468 |
| 23645 | 0 | 12082 | | 1 | 0 | 91469 |
| 23646 | 0 | 12082 | | 2 | 0 | 91470 |
| 23647 | 0 | 12082 | | 3 | 0 | 91471 |

In fact, the line is duplicated for each attribute ('small_image', 'second_image', etc ...) linked to the image. One solution that I found is to add :
$connection->delete($tableMedia, "attribute_id IS NOT NULL"); on the line 391 of vendor/agencednd/module-pimgento/Product/Model/Factory/Import/Media.php

@dnd-derwent
Copy link
Contributor

Hi @PierreLeMaguer

I tried to import 3 images for one product. And I do not have duplicated lines in the table media_gallery_value.
Can you try to update your Pimgento version and tell me if it works better ?

@ahuri909
Copy link

ahuri909 commented Nov 5, 2019

Hi,
I am facing the same issue here, with up to 1024 duplicates lines for a single media.
@PierreLeMaguer : did you eventually do a fix on your own ?

  • Magento : 2.2.9
  • PIMgento : 100.3
    Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants