Wednesday, January 13, 2016

Set Base Image on Thumbnail Image

<?php
require_once '../app/Mage.php';

Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('admin');

Mage::register('isSecureArea', 1);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

set_time_limit(0);
ini_set('memory_limit','1024M');

$connection = Mage::getSingleton('core/resource')->getConnection('core_write');

$sqlSp = "select entity_id from catalog_product_entity_varchar where `value` like '%https:%' and attribute_id = 87";
$res = $connection->fetchAll($sqlSp);

foreach ($res as $v) {
    $entityID = $v["entity_id"];
    $sqlURL = "select `value` from catalog_product_entity_varchar where entity_id = ? and attribute_id = 86";
    $url = $connection->fetchOne($sqlURL, $entityID);
    echo $entityID . " - " . $url . PHP_EOL;
    $sqlUpdte = "UPDATE catalog_product_entity_varchar SET `value` = ? where entity_id = ? and attribute_id = 87";
    $connection->query($sqlUpdte, array($url, $entityID));
}

No comments:

Post a Comment