In Magento 2, Set base image as small image












1














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
    Nov 23 '18 at 12:23










  • I want to set a base image which is already set in the small image.
    – Akash
    Nov 23 '18 at 12:52
















1














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
    Nov 23 '18 at 12:23










  • I want to set a base image which is already set in the small image.
    – Akash
    Nov 23 '18 at 12:52














1












1








1







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 Nov 23 '18 at 11:52









Akash

588117




588117












  • You want to set small image which is already set in base image?
    – Rohan Hapani
    Nov 23 '18 at 12:23










  • I want to set a base image which is already set in the small image.
    – Akash
    Nov 23 '18 at 12:52


















  • You want to set small image which is already set in base image?
    – Rohan Hapani
    Nov 23 '18 at 12:23










  • I want to set a base image which is already set in the small image.
    – Akash
    Nov 23 '18 at 12:52
















You want to set small image which is already set in base image?
– Rohan Hapani
Nov 23 '18 at 12:23




You want to set small image which is already set in base image?
– Rohan Hapani
Nov 23 '18 at 12:23












I want to set a base image which is already set in the small image.
– Akash
Nov 23 '18 at 12:52




I want to set a base image which is already set in the small image.
– Akash
Nov 23 '18 at 12:52










2 Answers
2






active

oldest

votes


















2














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
    Nov 23 '18 at 12:35



















0














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
    Nov 23 '18 at 12:13











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',
autoActivateHeartbeat: false,
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









2














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
    Nov 23 '18 at 12:35
















2














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
    Nov 23 '18 at 12:35














2












2








2






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 Nov 23 '18 at 12:15









Hitesh

1,3091423




1,3091423












  • It's working. Thanks
    – Akash
    Nov 23 '18 at 12:35


















  • It's working. Thanks
    – Akash
    Nov 23 '18 at 12:35
















It's working. Thanks
– Akash
Nov 23 '18 at 12:35




It's working. Thanks
– Akash
Nov 23 '18 at 12:35













0














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
    Nov 23 '18 at 12:13
















0














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
    Nov 23 '18 at 12:13














0












0








0






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 Nov 23 '18 at 12:10









Sunny Rahevar

929112




929112












  • Image Url does not generate When I import via CSV file.I have done this
    – Akash
    Nov 23 '18 at 12:13


















  • Image Url does not generate When I import via CSV file.I have done this
    – Akash
    Nov 23 '18 at 12:13
















Image Url does not generate When I import via CSV file.I have done this
– Akash
Nov 23 '18 at 12:13




Image Url does not generate When I import via CSV file.I have done this
– Akash
Nov 23 '18 at 12:13


















draft saved

draft discarded




















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




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

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks