Knowing I want Magento assemble and execute the following query :
UPDATE `catalog_product_entity_media_gallery_value` AS `tGV` INNER JOIN `catalog_product_entity_media_gallery` AS `tG` ON `tG` . value_id = value_id SET `tGV` . `position` = 2 WHERE ( `tG` . `value` LIKE '%_pms_%' )
I came to the following code :
$select = $connection ->select() ->join( ['tG' => $tableGallery], '`tG`.`value_id` = `tGV`.`value_id`', ['position' => new Expr('2')] ) ->where("`tG`.`value` LIKE '%_pms_master%'"); $update = $connection->updateFromSelect($select, ['tGV' => $tableGalleryValue]); $connection->query($update);
This code works but it is not obvious to understand and therefore to maintain. Question is : do you have any idea how to do better : simpler / cleaner / more understandable ?