In Magento 2, Set base image as small image





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty{ margin-bottom:0;
}






up vote
1
down vote

favorite












I have nearly 40k products and all images have been set to small only. If I go into the backend and then set each image one by one to the base, it will take me forever. Is there any way to do it via the database?










share|improve this question






















  • You want to set small image which is already set in base image?
    – Rohan Hapani
    2 days ago










  • I want to set a base image which is already set in the small image.
    – Akash Patel
    2 days ago

















up vote
1
down vote

favorite












I have nearly 40k products and all images have been set to small only. If I go into the backend and then set each image one by one to the base, it will take me forever. Is there any way to do it via the database?










share|improve this question






















  • You want to set small image which is already set in base image?
    – Rohan Hapani
    2 days ago










  • I want to set a base image which is already set in the small image.
    – Akash Patel
    2 days ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have nearly 40k products and all images have been set to small only. If I go into the backend and then set each image one by one to the base, it will take me forever. Is there any way to do it via the database?










share|improve this question













I have nearly 40k products and all images have been set to small only. If I go into the backend and then set each image one by one to the base, it will take me forever. Is there any way to do it via the database?







magento2 product-images






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 days ago









Akash Patel

50416




50416












  • You want to set small image which is already set in base image?
    – Rohan Hapani
    2 days ago










  • I want to set a base image which is already set in the small image.
    – Akash Patel
    2 days ago


















  • You want to set small image which is already set in base image?
    – Rohan Hapani
    2 days ago










  • I want to set a base image which is already set in the small image.
    – Akash Patel
    2 days ago
















You want to set small image which is already set in base image?
– Rohan Hapani
2 days ago




You want to set small image which is already set in base image?
– Rohan Hapani
2 days ago












I want to set a base image which is already set in the small image.
– Akash Patel
2 days ago




I want to set a base image which is already set in the small image.
– Akash Patel
2 days ago










2 Answers
2






active

oldest

votes

















up vote
2
down vote



accepted










If you want to do by MySQL way follow below way



First, run below query to know the query is actually working and you will get a list of images



select  ev.value, mg.value from catalog_product_entity_media_gallery AS mg,
catalog_product_entity_media_gallery_value AS mgv,
catalog_product_entity_varchar AS ev
WHERE mg.value_id = mgv.value_id
AND mgv.entity_id = ev.entity_id
AND ev.attribute_id IN (87, 88, 89)
AND mgv.position = 1;


After that run below query to update small image path with a thumbnail image



UPDATE catalog_product_entity_media_gallery AS mg,
catalog_product_entity_media_gallery_value AS mgv,
catalog_product_entity_varchar AS ev
SET ev.value = mg.value
WHERE mg.value_id = mgv.value_id
AND mgv.entity_id = ev.entity_id
AND ev.attribute_id IN (87, 88, 89)
AND mgv.position = 1;


You should run first in test ENV, after making sure you can run on other ENV.



Hope It will solve your issue






share|improve this answer





















  • It's working. Thanks
    – Akash Patel
    2 days ago


















up vote
0
down vote













You can use the CSV.
Please add two more column 'base_image' and 'thumbnail_image' in the csv file and re import all the products.Then after reindex the process.






share|improve this answer





















  • Image Url does not generate When I import via CSV file.I have done this
    – Akash Patel
    2 days ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f251081%2fin-magento-2-set-base-image-as-small-image%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote



accepted










If you want to do by MySQL way follow below way



First, run below query to know the query is actually working and you will get a list of images



select  ev.value, mg.value from catalog_product_entity_media_gallery AS mg,
catalog_product_entity_media_gallery_value AS mgv,
catalog_product_entity_varchar AS ev
WHERE mg.value_id = mgv.value_id
AND mgv.entity_id = ev.entity_id
AND ev.attribute_id IN (87, 88, 89)
AND mgv.position = 1;


After that run below query to update small image path with a thumbnail image



UPDATE catalog_product_entity_media_gallery AS mg,
catalog_product_entity_media_gallery_value AS mgv,
catalog_product_entity_varchar AS ev
SET ev.value = mg.value
WHERE mg.value_id = mgv.value_id
AND mgv.entity_id = ev.entity_id
AND ev.attribute_id IN (87, 88, 89)
AND mgv.position = 1;


You should run first in test ENV, after making sure you can run on other ENV.



Hope It will solve your issue






share|improve this answer





















  • It's working. Thanks
    – Akash Patel
    2 days ago















up vote
2
down vote



accepted










If you want to do by MySQL way follow below way



First, run below query to know the query is actually working and you will get a list of images



select  ev.value, mg.value from catalog_product_entity_media_gallery AS mg,
catalog_product_entity_media_gallery_value AS mgv,
catalog_product_entity_varchar AS ev
WHERE mg.value_id = mgv.value_id
AND mgv.entity_id = ev.entity_id
AND ev.attribute_id IN (87, 88, 89)
AND mgv.position = 1;


After that run below query to update small image path with a thumbnail image



UPDATE catalog_product_entity_media_gallery AS mg,
catalog_product_entity_media_gallery_value AS mgv,
catalog_product_entity_varchar AS ev
SET ev.value = mg.value
WHERE mg.value_id = mgv.value_id
AND mgv.entity_id = ev.entity_id
AND ev.attribute_id IN (87, 88, 89)
AND mgv.position = 1;


You should run first in test ENV, after making sure you can run on other ENV.



Hope It will solve your issue






share|improve this answer





















  • It's working. Thanks
    – Akash Patel
    2 days ago













up vote
2
down vote



accepted







up vote
2
down vote



accepted






If you want to do by MySQL way follow below way



First, run below query to know the query is actually working and you will get a list of images



select  ev.value, mg.value from catalog_product_entity_media_gallery AS mg,
catalog_product_entity_media_gallery_value AS mgv,
catalog_product_entity_varchar AS ev
WHERE mg.value_id = mgv.value_id
AND mgv.entity_id = ev.entity_id
AND ev.attribute_id IN (87, 88, 89)
AND mgv.position = 1;


After that run below query to update small image path with a thumbnail image



UPDATE catalog_product_entity_media_gallery AS mg,
catalog_product_entity_media_gallery_value AS mgv,
catalog_product_entity_varchar AS ev
SET ev.value = mg.value
WHERE mg.value_id = mgv.value_id
AND mgv.entity_id = ev.entity_id
AND ev.attribute_id IN (87, 88, 89)
AND mgv.position = 1;


You should run first in test ENV, after making sure you can run on other ENV.



Hope It will solve your issue






share|improve this answer












If you want to do by MySQL way follow below way



First, run below query to know the query is actually working and you will get a list of images



select  ev.value, mg.value from catalog_product_entity_media_gallery AS mg,
catalog_product_entity_media_gallery_value AS mgv,
catalog_product_entity_varchar AS ev
WHERE mg.value_id = mgv.value_id
AND mgv.entity_id = ev.entity_id
AND ev.attribute_id IN (87, 88, 89)
AND mgv.position = 1;


After that run below query to update small image path with a thumbnail image



UPDATE catalog_product_entity_media_gallery AS mg,
catalog_product_entity_media_gallery_value AS mgv,
catalog_product_entity_varchar AS ev
SET ev.value = mg.value
WHERE mg.value_id = mgv.value_id
AND mgv.entity_id = ev.entity_id
AND ev.attribute_id IN (87, 88, 89)
AND mgv.position = 1;


You should run first in test ENV, after making sure you can run on other ENV.



Hope It will solve your issue







share|improve this answer












share|improve this answer



share|improve this answer










answered 2 days ago









Hitesh

1,008321




1,008321












  • It's working. Thanks
    – Akash Patel
    2 days ago


















  • It's working. Thanks
    – Akash Patel
    2 days ago
















It's working. Thanks
– Akash Patel
2 days ago




It's working. Thanks
– Akash Patel
2 days ago












up vote
0
down vote













You can use the CSV.
Please add two more column 'base_image' and 'thumbnail_image' in the csv file and re import all the products.Then after reindex the process.






share|improve this answer





















  • Image Url does not generate When I import via CSV file.I have done this
    – Akash Patel
    2 days ago















up vote
0
down vote













You can use the CSV.
Please add two more column 'base_image' and 'thumbnail_image' in the csv file and re import all the products.Then after reindex the process.






share|improve this answer





















  • Image Url does not generate When I import via CSV file.I have done this
    – Akash Patel
    2 days ago













up vote
0
down vote










up vote
0
down vote









You can use the CSV.
Please add two more column 'base_image' and 'thumbnail_image' in the csv file and re import all the products.Then after reindex the process.






share|improve this answer












You can use the CSV.
Please add two more column 'base_image' and 'thumbnail_image' in the csv file and re import all the products.Then after reindex the process.







share|improve this answer












share|improve this answer



share|improve this answer










answered 2 days ago









Sunny Rahevar

790112




790112












  • Image Url does not generate When I import via CSV file.I have done this
    – Akash Patel
    2 days ago


















  • Image Url does not generate When I import via CSV file.I have done this
    – Akash Patel
    2 days ago
















Image Url does not generate When I import via CSV file.I have done this
– Akash Patel
2 days ago




Image Url does not generate When I import via CSV file.I have done this
– Akash Patel
2 days ago


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f251081%2fin-magento-2-set-base-image-as-small-image%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Quarter-circle Tiles

build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

Mont Emei