Guest User

Untitled

a guest
May 29th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. <?php
  2. require_once 'app/Mage.php';
  3. Mage::app();
  4.  
  5. mysql_connect(localhost, DATABASE_USER, DATABASE_PASSWORD);
  6. mysql_select_db(DATABASE_NAME) or die("Unable to select database");
  7.  
  8. $result = mysql_query("SELECT * FROM `catalog_product_entity_varchar` WHERE attribute_id in (74,75,76) AND value='no_selection'");
  9.  
  10. while ($row = mysql_fetch_array($result)) {
  11. $id = $row["entity_id"];
  12. $product = Mage::getModel("catalog/product")->load($id);
  13. $mediaGallery = $product->getMediaGallery();
  14. if ($mediaGallery["images"][0]["file"] != '' || $mediaGallery["images"][0]["file"] != NULL) {
  15. $path = $mediaGallery["images"][0]["file"];
  16. $update_result = mysql_query("UPDATE `catalog_product_entity_varchar` SET VALUE='".$path."' WHERE attribute_id in (74,75,76) and entity_id=".$id);
  17. echo "set images for product ".$id."<br />";
  18. }
  19. }
  20. ?>
Add Comment
Please, Sign In to add comment