php - Making this into a cron job? -
found lovely piece of sql query code excluded multiple images on magento.
update catalog_product_entity_media_gallery_value set disabled = 0; update catalog_product_entity_media_gallery_value mgv, (select entity_id, count(*) image_count, max(value_id) value_id catalog_product_entity_media_gallery mg group entity_id having image_count = 2) mg set mgv.disabled = 1 mgv.value_id = mg.value_id
i looking have run cron job instead of direct database have no idea how write one.
can made cron job?
point me in right direction please.
using command line tool comes databases wrap these statements in script, this, using mysql
/path/to/mysql --whateverparametersyouneed yourdb << here update catalog_product_entity_media_gallery_value set disabled = 0; update catalog_product_entity_media_gallery_value mgv, (select entity_id, count(*) image_count, max(value_id) value_id catalog_product_entity_media_gallery mg group entity_id having image_count = 2) mg set mgv.disabled = 1 mgv.value_id = mg.value_id; here
this called here-document, see how can write here doc file in bash script? more information.
then, call script cron.
Comments
Post a Comment