コード例 #1
0
ファイル: raw.php プロジェクト: CherylMuniz/fashion
        $categoryNameId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_category', 'name');
        $this->query("DROP TABLE IF EXISTS `oberig_categories`");
        $this->query("CREATE TABLE IF NOT EXISTS `oberig_categories` (\n            `store` varchar(255) DEFAULT NULL,\n            `categories` varchar(255) DEFAULT NULL,\n            `cat_id` int(11),\n            `is_active` int(11),\n            `meta_title` varchar(255) DEFAULT NULL,\n            `meta_keywords` varchar(255) DEFAULT NULL,\n            `meta_description` varchar(255) DEFAULT NULL,\n            `include_in_menu` int(11),\n            `is_anchor` int(11),\n            `description` varchar(255) DEFAULT NULL,\n            `name` varchar(255) DEFAULT NULL\n            )ENGINE=InnoDB DEFAULT CHARSET=utf8");
        $this->query("LOAD DATA INFILE '" . $this->CSVCategoryFile . "' \n                               INTO TABLE `oberig_categories` \n                               FIELDS TERMINATED BY ',' \n                               ENCLOSED BY '\"'\n                               LINES TERMINATED BY '\n' IGNORE 1 LINES \n        ");
        $this->query("DROP TABLE IF EXISTS `oberig_category_mapping`");
        $this->query("CREATE TABLE IF NOT EXISTS `oberig_category_mapping` (\n                `old_cat_id` int(11),\n                `new_cat_id` int(11),\n                `name` varchar(255) DEFAULT NULL\n                )ENGINE=InnoDB DEFAULT CHARSET=utf8");
        $this->query("\n            INSERT INTO oberig_category_mapping (old_cat_id, name) SELECT cat_id, name FROM `oberig_categories`; \n         ");
        $this->query("\n             UPDATE oberig_category_mapping ocm \n             INNER JOIN catalog_category_entity_varchar cev \n                ON ocm.name = cev.value\n             SET ocm.new_cat_id = cev.entity_id\n             WHERE cev.attribute_id={$categoryNameId} and cev.store_id=0;\n         ");
    }
    public function importImages()
    {
        $imgId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product', 'image');
        $imgSmallId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product', 'small_image');
        $media_gallery_id = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product', 'media_gallery');
        $old_imgId = 74;
        $old_imgSmallId = 75;
        $old_media_gallery_id = 77;
        $this->query("DELETE FROM catalog_product_entity_varchar WHERE attribute_id = {$imgId} ");
        $this->query("INSERT INTO catalog_product_entity_varchar (entity_type_id, attribute_id, store_id, entity_id, value) \n        SELECT 4, {$imgId}, 0, cpe.entity_id, op.image FROM oberig_products op\n        INNER JOIN catalog_product_entity cpe \n            ON cpe.sku = op.sku \n        WHERE op.store_id=0\n        ");
        $this->query("DELETE FROM catalog_product_entity_varchar WHERE attribute_id = {$imgSmallId} ");
        $this->query("INSERT INTO catalog_product_entity_varchar (entity_type_id, attribute_id, store_id, entity_id, value) \n        SELECT 4, {$imgSmallId}, 0, cpe.entity_id, op.small_image FROM oberig_products op\n        INNER JOIN catalog_product_entity cpe \n            ON cpe.sku = op.sku \n        WHERE op.store_id=0\n        ");
        $this->query("DELETE FROM catalog_product_entity_media_gallery WHERE attribute_id = {$media_gallery_id} ");
        $this->query("INSERT INTO catalog_product_entity_media_gallery (attribute_id, entity_id, value) \n        SELECT {$media_gallery_id}, cpe.entity_id, cpm_old.value FROM {$this->oldDB}.catalog_product_entity_media_gallery cpm_old\n        INNER JOIN {$this->oldDB}.catalog_product_entity cpe_old\n            ON cpe_old.entity_id = cpm_old.entity_id\n        INNER JOIN catalog_product_entity cpe \n            ON cpe.sku = cpe_old.sku \n        WHERE cpm_old.attribute_id = {$old_media_gallery_id}\n        ");
    }
}
$imp = new Oberig_Import();
$imp->loadCsv();
//$imp->loadCategories();
$imp->addProduct();
$imp->importImages();
//set attribute sell_by_phone_only
コード例 #2
0
ファイル: raw.php プロジェクト: CherylMuniz/fashion
        $model->saveOptions($options);
    }
    public function _afterImport()
    {
        //enable indexes
        $processes = Mage::getSingleton('index/indexer')->getProcessesCollection();
        $processes->walk('setMode', array(Mage_Index_Model_Process::MODE_REAL_TIME));
        $processes->walk('save');
        echo date("\nY-d-m H:i:s") . " - reindex start\n";
        passthru("php indexer.php reindexall");
        echo date("\nY-d-m H:i:s") . " - reindex finish\n";
        //enable cache
        $model = Mage::getModel('core/cache');
        $options = $model->canUse();
        foreach ($options as $option => $value) {
            $options[$option] = 1;
        }
        $model->saveOptions($options);
    }
}
echo date("\nY-d-m H:i:s") . " - import start\n";
$imp = new Oberig_Import();
$imp->loadCsv();
$imp->_beforeImport();
$imp->loadCategories();
$imp->addProduct();
$imp->importImages();
$imp->loadProductLinks();
$imp->productLinksMapping();
$imp->_afterImport();
echo date("\nY-d-m H:i:s") . " - import completed\n";