コード例 #1
0
ファイル: 1attrsup.php プロジェクト: CherylMuniz/fashion
        $model->setSourceModel($object['source_model']);
        $model->setEntityTypeId($this->typeId);
        $model->addData($data);
        try {
            $model->save();
            $model->setSourceModel($object['source_model']);
            // TODO: check why need it, and how fix it for right set source_model
            $model->save();
            echo $model->getAttributeCode() . " ..........................ok. ID: " . $model->getId() . "\n";
        } catch (Exception $ex) {
            echo "Error: " . $ex->getMessage() . "\n";
        }
        //add attribute options
        if (empty($object['options'])) {
            echo "Model " . $model->getAttributeCode() . " saved ..........................ok. \n";
            return;
        }
        $option['attribute_id'] = $model->getId();
        foreach ($object['options'] as $opt) {
            $option['value']['option'][0] = $opt['label'];
            //mage::d($option); //die;
            $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
            $setup->addAttributeOption($option);
        }
        echo "Model " . $model->getAttributeCode() . " saved. options added ..........................ok. \n";
    }
}
echo date("\nY-d-m H:i:s\n") . "Begin\n";
$im = new Oberig_Import_Attributes();
$im->load();
echo date("\nY-d-m H:i:s\n") . "End\n";
コード例 #2
0
ファイル: attributes.php プロジェクト: CherylMuniz/fashion
                $option['value']['option'][0] = $opt['label'];
                mage::d($option);
                //die;
                $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
                $setup->addAttributeOption($option);
            }
            echo "Model " . $model->getAttributeCode() . " saved. options added ..........................ok. \n";
            //$model = Mage::getModel('catalog/resource_eav_attribute')->load($model->getId())->delete(); //die;
            //}
        }
        // set tax class options TODO: API
        $this->query("insert ignore into tax_class select * from {$this->oldDB}.tax_class");
        //die;
    }
}
$im = new Oberig_Import_Attributes();
$im->attributeSetMapping();
$im->attrSetsGroups();
$im->loadAttributes();
die;
//drop table oberig_attribute_set_mapping;
//create table `oberig_attribute_set_mapping` (
//`attribute_set_name` varchar(255) DEFAULT NULL,
//`attribute_group_name` varchar(255) DEFAULT NULL,
//`attribute_code` varchar(255) DEFAULT NULL
//);
//INSERT INTO `oberig_attribute_set_mapping`
//SELECT attribute_set_name,attribute_group_name,attribute_code FROM fashione_staging2.`eav_attribute_set` eas
//INNER JOIN fashione_staging2.`eav_attribute_group` eag
//ON eas.attribute_set_id = eag. attribute_set_id
//INNER JOIN fashione_staging2.`eav_entity_attribute` eea