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(); $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']); } } } } } ////////////////
if (isset($_GET['display'])) { if ($_GET['display'] == "true") { $display = true; } else { $display = false; } } $_SESSION['display'] = isset($display) ? $display : true; if ($_SESSION['display']) { echo '<div class="container-fluid"><div class="row"><div class="col-xs-12 text-center"><h3>Running Amazon Listing Fix</h3></div></div><div class="row"><hr /><div class="col-xs-6 col-xs-offset-3">'; } /////////////////// // Start Script // /////////////////// $mage_db = new MageDB(); $results = $mage_db->select("catalog_product_entity", null, "entity_id,sku"); if ($results) { foreach ($results as $result) { $mp[$result['entity_id']] = $result['sku']; } } else { $mp = $results; } $ai = $mage_db->select("m2epro_amazon_listing_product", null, "listing_product_id,sku"); if ($mp and $ai) { if ($_SESSION['display']) { $report->start("Comparing Amazon Item Sku's to Products", 3); } foreach ($ai as $si) { $result = $mage_db->select("m2epro_listing_product", $si['listing_product_id'], "product_id", 1); $si['product_id'] = $result['product_id'];