Example #1
0
$html = new Frontend();
$report = new Report();
$alerts = new Alerts();
$scripts = new Scripts();
///////////////////
// Start Script	 //
///////////////////
$_SESSION['debug'] = true;
$mage_db = new MageDB();
$db = new Database();
$settings = $db->select('settings', 1, '*', 1);
$codes = ['brand', 'manufacturer'];
foreach ($codes as $code) {
    $attribute = $mage_db->select('eav_attribute', "`attribute_code`='{$code}'", '*', 1);
    if ($attribute) {
        $products = $mage_db->select('catalog_product_entity');
        if ($products) {
            foreach ($products as $product) {
                $varchar = $mage_db->select('catalog_product_entity_varchar', '`attribute_id`=' . $attribute['attribute_id'] . ' AND `entity_id`=' . $product['entity_id'], '*', 1);
                if ($varchar) {
                    $mage_db->update('catalog_product_entity_varchar', 'value', $settings['brand'], '`attribute_id`=' . $attribute['attribute_id'] . ' AND `entity_id`=' . $product['entity_id']);
                } else {
                    $mage_db->insert('catalog_product_entity_varchar', 'entity_type_id,attribute_id,entity_id,value', '4||' . $attribute['attribute_id'] . '||' . $product['entity_id'] . '||' . $settings['brand']);
                }
            }
        }
    }
}
////////////////
// End Script //
////////////////
Example #2
0
function __autoload($class_name)
{
    include "../" . APP_CLASSES . "{$class_name}.class.php";
}
$html = new Frontend();
$report = new Report();
$alerts = new Alerts();
$scripts = new Scripts();
///////////////////
// Start Script	 //
///////////////////
$_SESSION['debug'] = true;
$mage_db = new MageDB();
$attribute = $mage_db->select('eav_attribute', "`attribute_code`='gtin'", '*', 1);
if ($attribute) {
    $mage_db->update('eav_attribute', 'attribute_code,frontend_label,is_required,default_value', 'ean||EAN||1||EXCEP', "`attribute_id`=" . $attribute['attribute_id']);
} else {
    $attribute = $mage_db->select('eav_attribute', "`attribute_code`='ean'", '*', 1);
}
if ($attribute) {
    $mage_db->update('eav_attribute_label', 'value', 'EAN', "`attribute_id`=" . $attribute['attribute_id']);
    $products = $mage_db->select('catalog_product_entity');
    if ($products) {
        foreach ($products as $product) {
            $varchar = $mage_db->select('catalog_product_entity_varchar', '`attribute_id`=' . $attribute['attribute_id'] . ' AND `entity_id`=' . $product['entity_id'], '*', 1);
            if ($varchar) {
                $mage_db->update('catalog_product_entity_varchar', 'value', 'EXCEP', '`attribute_id`=' . $attribute['attribute_id'] . ' AND `entity_id`=' . $product['entity_id']);
            } else {
                $mage_db->insert('catalog_product_entity_varchar', 'entity_type_id,attribute_id,entity_id,value', '4||' . $attribute['attribute_id'] . '||' . $product['entity_id'] . '||EXCEP');
            }
        }