private function deleteOldData()
    {
        $connection = $this->installer->getConnection();
        $this->installer->run(<<<SQL

    DROP TABLE IF EXISTS `m2epro_listing_category`;
    DROP TABLE IF EXISTS `m2epro_ebay_listing_auto_category`;
    DROP TABLE IF EXISTS `m2epro_ebay_listing_auto_category_group`;

SQL
);
        $oldTable = $this->installer->getTable('m2epro_temp_ebay_listing_auto_category_group');
        $newTable = $this->installer->getTable('m2epro_ebay_listing_auto_category_group');
        if ($this->installer->tableExists($oldTable) && !$this->installer->tableExists($newTable)) {
            $connection->query("RENAME TABLE `{$oldTable}` TO `{$newTable}`");
        }
        $tempTable = $this->installer->getTable('m2epro_ebay_listing');
        $tempTableIndexList = $connection->getIndexList($tempTable);
        if (isset($tempTableIndexList[strtoupper('auto_mode')])) {
            $connection->dropKey($tempTable, 'auto_mode');
        }
        if (isset($tempTableIndexList[strtoupper('auto_global_adding_mode')])) {
            $connection->dropKey($tempTable, 'auto_global_adding_mode');
        }
        if (isset($tempTableIndexList[strtoupper('auto_website_adding_mode')])) {
            $connection->dropKey($tempTable, 'auto_website_adding_mode');
        }
        if (isset($tempTableIndexList[strtoupper('auto_website_deleting_mode')])) {
            $connection->dropKey($tempTable, 'auto_website_deleting_mode');
        }
        if ($connection->tableColumnExists($tempTable, 'auto_mode') !== false) {
            $connection->dropColumn($tempTable, 'auto_mode');
        }
        if ($connection->tableColumnExists($tempTable, 'auto_global_adding_mode') !== false) {
            $connection->dropColumn($tempTable, 'auto_global_adding_mode');
        }
        if ($connection->tableColumnExists($tempTable, 'auto_website_adding_mode') !== false) {
            $connection->dropColumn($tempTable, 'auto_website_adding_mode');
        }
        if ($connection->tableColumnExists($tempTable, 'auto_website_deleting_mode') !== false) {
            $connection->dropColumn($tempTable, 'auto_website_deleting_mode');
        }
        $tempTable = $this->installer->getTable('m2epro_listing');
        if ($connection->tableColumnExists($tempTable, 'categories_add_action') !== false) {
            $connection->dropColumn($tempTable, 'categories_add_action');
        }
        if ($connection->tableColumnExists($tempTable, 'categories_delete_action') !== false) {
            $connection->dropColumn($tempTable, 'categories_delete_action');
        }
    }
 private function renameTables()
 {
     $connection = $this->installer->getConnection();
     $oldTable = $this->installer->getTable('m2epro_amazon_template_new_product');
     $newTable = $this->installer->getTable('m2epro_amazon_template_description');
     if ($this->installer->tableExists($oldTable) && !$this->installer->tableExists($newTable)) {
         $connection->query("RENAME TABLE {$oldTable} TO {$newTable}");
     }
     $oldTable = $this->installer->getTable('m2epro_amazon_template_new_product_description');
     $newTable = $this->installer->getTable('m2epro_amazon_template_description_definition');
     if ($this->installer->tableExists($oldTable) && !$this->installer->tableExists($newTable)) {
         $connection->query("RENAME TABLE {$oldTable} TO {$newTable}");
     }
     $oldTable = $this->installer->getTable('m2epro_amazon_template_new_product_specific');
     $newTable = $this->installer->getTable('m2epro_amazon_template_description_specific');
     if ($this->installer->tableExists($oldTable) && !$this->installer->tableExists($newTable)) {
         $connection->query("RENAME TABLE {$oldTable} TO {$newTable}");
     }
 }
 private function processOperationHistoryTable()
 {
     $connection = $this->installer->getConnection();
     $oldTable = $this->installer->getTable('m2epro_synchronization_run');
     $newTable = $this->installer->getTable('m2epro_operation_history');
     if ($this->installer->tableExists($oldTable) && !$this->installer->tableExists($newTable)) {
         $connection->query("RENAME TABLE `{$oldTable}` TO `{$newTable}`");
     }
     if ($connection->tableColumnExists($newTable, 'nick') === false) {
         $connection->addColumn($newTable, 'nick', 'VARCHAR(255) NOT NULL AFTER `id`');
     }
     if ($connection->tableColumnExists($newTable, 'parent_id') === false) {
         $connection->addColumn($newTable, 'parent_id', 'INT(11) UNSIGNED DEFAULT NULL AFTER `nick`');
     }
     if ($connection->tableColumnExists($newTable, 'data') === false) {
         $connection->addColumn($newTable, 'data', 'TEXT DEFAULT NULL AFTER `end_date`');
     }
     if ($connection->tableColumnExists($newTable, 'kill_now') !== false) {
         $connection->dropColumn($newTable, 'kill_now');
     }
     if ($connection->tableColumnExists($newTable, 'initiator') !== false) {
         $connection->changeColumn($newTable, 'initiator', 'initiator', 'TINYINT(2) UNSIGNED NOT NULL DEFAULT 0');
     }
     $indexList = $connection->getIndexList($newTable);
     if (!isset($indexList[strtoupper('start_date')])) {
         $connection->addKey($newTable, 'start_date', 'start_date');
     }
     if (!isset($indexList[strtoupper('end_date')])) {
         $connection->addKey($newTable, 'end_date', 'end_date');
     }
     if (!isset($indexList[strtoupper('nick')])) {
         $connection->addKey($newTable, 'nick', 'nick');
     }
     if (!isset($indexList[strtoupper('parent_id')])) {
         $connection->addKey($newTable, 'parent_id', 'parent_id');
     }
     $offset = 5;
     $connection->update($newTable, array('nick' => 'synchronization'));
     $connection->update($newTable, array('initiator' => new Zend_Db_Expr('`initiator` + ' . $offset)), '`initiator` IN (1,2)');
     $connection->update($newTable, array('initiator' => 1), '`initiator` = ' . (2 + $offset));
     $connection->update($newTable, array('initiator' => 2), '`initiator` = ' . (1 + $offset));
 }
    private function processEbayTemplates()
    {
        $this->installer->run(<<<SQL

CREATE TABLE IF NOT EXISTS `m2epro_ebay_template_description` (
  template_description_id INT(11) UNSIGNED NOT NULL,
  is_custom_template TINYINT(2) UNSIGNED NOT NULL DEFAULT 1,
  title_mode TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
  title_template VARCHAR(255) NOT NULL,
  subtitle_mode TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
  subtitle_template VARCHAR(255) NOT NULL,
  description_mode TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
  description_template LONGTEXT NOT NULL,
  condition_mode TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
  condition_value INT(11) UNSIGNED NOT NULL DEFAULT 0,
  condition_attribute VARCHAR(255) NOT NULL,
  condition_note_mode TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
  condition_note_template TEXT NOT NULL,
  product_details TEXT DEFAULT NULL,
  cut_long_titles TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
  hit_counter VARCHAR(255) NOT NULL,
  editor_type TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
  enhancement VARCHAR(255) NOT NULL,
  gallery_type TINYINT(2) UNSIGNED NOT NULL DEFAULT 4,
  image_main_mode TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
  image_main_attribute VARCHAR(255) NOT NULL,
  gallery_images_mode TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
  gallery_images_limit TINYINT(2) UNSIGNED NOT NULL DEFAULT 1,
  gallery_images_attribute VARCHAR(255) NOT NULL,
  default_image_url VARCHAR(255) DEFAULT NULL,
  variation_configurable_images VARCHAR(255) NOT NULL,
  use_supersize_images TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
  watermark_mode TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
  watermark_image LONGBLOB DEFAULT NULL,
  watermark_settings TEXT DEFAULT NULL,
  PRIMARY KEY (template_description_id),
  INDEX is_custom_template (is_custom_template)
)
ENGINE = INNODB
CHARACTER SET utf8
COLLATE utf8_general_ci;

SQL
);
        $descriptionTable = $this->installer->getTable('m2epro_template_description');
        $ebayDescriptionTable = $this->installer->getTable('m2epro_ebay_template_description');
        $backupTable = $this->getBackupTableName('m2epro_ebay_template_description');
        if (!$this->installer->tableExists($backupTable) || !$this->installer->tableExists($ebayDescriptionTable) || !$this->installer->tableExists($descriptionTable)) {
            return;
        }
        $tempQuery = "SELECT * FROM `{$descriptionTable}` WHERE `component_mode` = 'ebay'";
        $tempRow = $this->installer->getConnection()->query($tempQuery)->fetch();
        if ($tempRow !== false) {
            return;
        }
        $this->installer->run(<<<SQL

INSERT INTO `m2epro_template_description`
SELECT
    `id`,
    `title`,
    'ebay',
    `create_date`,
    `update_date`
FROM {$backupTable};

INSERT INTO `m2epro_ebay_template_description`
SELECT
    `id`,
    `is_custom_template`,
    `title_mode`,
    `title_template`,
    `subtitle_mode`,
    `subtitle_template`,
    `description_mode`,
    `description_template`,
    `condition_mode`,
    `condition_value`,
    `condition_attribute`,
    `condition_note_mode`,
    `condition_note_template`,
    `product_details`,
    `cut_long_titles`,
    `hit_counter`,
    `editor_type`,
    `enhancement`,
    `gallery_type`,
    `image_main_mode`,
    `image_main_attribute`,
    `gallery_images_mode`,
    `gallery_images_limit`,
    `gallery_images_attribute`,
    `default_image_url`,
    `variation_configurable_images`,
    `use_supersize_images`,
    `watermark_mode`,
    `watermark_image`,
    `watermark_settings`
FROM {$backupTable};

SQL
);
    }
Exemple #5
0
 private function checkToSkipStep($nextTable)
 {
     $nextTable = $this->installer->getTable($nextTable);
     return (bool) $this->installer->tableExists($nextTable);
 }
    private function prepareOrdersTables()
    {
        $connection = $this->installer->getConnection();
        $orderTable = $this->installer->getTable('m2epro_ebay_order');
        $orderBackupOTable = $this->installer->getTable('m2epro' . self::BACKUP_TABLE_PREFIX . '_ebay_order');
        if ($this->installer->tableExists($orderTable) && !$this->installer->tableExists($orderBackupOTable)) {
            $connection->query("RENAME TABLE `{$orderTable}` TO `{$orderBackupOTable}`");
        }
        $orderItemTable = $this->installer->getTable('m2epro_ebay_order_item');
        $orderItemBackupTable = $this->installer->getTable('m2epro' . self::BACKUP_TABLE_PREFIX . '_ebay_order_item');
        if ($this->installer->tableExists($orderItemTable) && !$this->installer->tableExists($orderItemBackupTable)) {
            $connection->query("RENAME TABLE `{$orderItemTable}` TO `{$orderItemBackupTable}`");
        }
        $this->installer->run(<<<SQL
CREATE TABLE IF NOT EXISTS m2epro_ebay_order (
  order_id INT(11) UNSIGNED NOT NULL,
  ebay_order_id VARCHAR(255) NOT NULL,
  selling_manager_id INT(11) UNSIGNED DEFAULT NULL,
  buyer_name VARCHAR(255) NOT NULL,
  buyer_email VARCHAR(255) NOT NULL,
  buyer_user_id VARCHAR(255) NOT NULL,
  buyer_message VARCHAR(500) DEFAULT NULL,
  paid_amount DECIMAL(12, 4) NOT NULL DEFAULT 0.0000,
  saved_amount DECIMAL(12, 4) UNSIGNED NOT NULL DEFAULT 0.0000,
  currency VARCHAR(10) NOT NULL,
  checkout_status TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
  shipping_status TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
  payment_status TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
  shipping_details TEXT DEFAULT NULL,
  payment_details TEXT DEFAULT NULL,
  tax_details TEXT DEFAULT NULL,
  purchase_update_date DATETIME DEFAULT NULL,
  purchase_create_date DATETIME DEFAULT NULL,
  PRIMARY KEY (order_id),
  INDEX ebay_order_id (ebay_order_id),
  INDEX selling_manager_id (selling_manager_id),
  INDEX buyer_email (buyer_email),
  INDEX buyer_name (buyer_name),
  INDEX buyer_user_id (buyer_user_id),
  INDEX paid_amount (paid_amount),
  INDEX checkout_status (checkout_status),
  INDEX payment_status (payment_status),
  INDEX shipping_status (shipping_status)
)
ENGINE = INNODB
CHARACTER SET utf8
COLLATE utf8_general_ci;

CREATE TABLE IF NOT EXISTS m2epro_ebay_order_item (
  order_item_id INT(11) UNSIGNED NOT NULL,
  transaction_id VARCHAR(20) NOT NULL,
  selling_manager_id INT(11) UNSIGNED DEFAULT NULL,
  item_id DECIMAL(20, 0) UNSIGNED NOT NULL,
  title VARCHAR(255) NOT NULL,
  sku VARCHAR(64) DEFAULT NULL,
  price DECIMAL(12, 4) NOT NULL DEFAULT 0.0000,
  qty_purchased INT(11) UNSIGNED NOT NULL,
  tax_details TEXT DEFAULT NULL,
  final_fee DECIMAL(12, 4) NOT NULL DEFAULT 0.0000,
  variation_details TEXT DEFAULT NULL,
  tracking_details TEXT DEFAULT NULL,
  unpaid_item_process_state TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY (order_item_id),
  INDEX transaction_id (transaction_id),
  INDEX selling_manager_id (selling_manager_id),
  INDEX item_id (item_id),
  INDEX sku (sku),
  INDEX title (title),
  INDEX unpaid_item_process_state (unpaid_item_process_state)
)
ENGINE = INNODB
CHARACTER SET utf8
COLLATE utf8_general_ci;
SQL
);
    }