1

We are in the final steps to migrate from 1 to 2. Now we found that some picture got lost.

Is there a way to select all SKUs and their picture counts like:

SKU    Count
123    2
234    6
345    2

In Magento 1 and Magento 2 Mysql backend?

2

if your Magento install does not use a prefix

on M1, you may try:

select count(*),c.sku from catalog_product_entity_media_gallery as i
left join catalog_product_entity as c on c.entity_id=i.entity_id
group by c.sku;

on M2, you may try:

select count(*),c.sku from catalog_product_entity_media_gallery_value as i
left join catalog_product_entity as c on c.entity_id=i.entity_id
group by c.sku;

if your Magento install uses a prefix, let say test_ is your prefix

on M1, you may try:

select count(*),c.sku from test_catalog_product_entity_media_gallery as i
left join test_catalog_product_entity as c on c.entity_id=i.entity_id
group by c.sku;

on M2, you may try:

select count(*),c.sku from test_catalog_product_entity_media_gallery_value as i
left join test_catalog_product_entity as c on c.entity_id=i.entity_id
group by c.sku;

to check the prefix of your magento install, you may open the file:

 app/etc/local.xml on Magento 1 and look for <table_prefix>  

and app/etc/env.php on Magento 2 and look for 'table_prefix' =>
1
  • Thanx so much, that worked well. – Michael Müller Oct 14 '18 at 22:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.