2
votes

I'm trying to modify a magento oscommerce import script to work with attributes and configurable products. It's a challenge to say the least.

But I'm getting progress. Currently I'm trying to add attribute set name to magento, and after that, I'm writing to my tmp table where I need magento attribute set id, for the attribute set I've just created.

My problem is I don't know how to get that id.

My current code:

$sql = "select * from ezmage_variant_sets";
$results = $readConnection->fetchAll($sql);

foreach($results as $row) {
    if ($row['variant_imported'] != 'y'){
        $this->createAttributeSet($row['osc_variants_title'],-1);

        // update tmp table
        $sql = "update ezmage_variant_sets set variant_imported='y',mage_variant_id=".$variant->getId()." where osc_variants_id=".$row['osc_variants_id'];              
        $writeConnection->query($sql);  

    }

}

Problem is $variant->getId(). What would I need to get that id?

1
where is createAttributeSet method defined ?? - Meabed
in a public function in my script - Dyvel
yes could you paste it here so people can see it ? - Meabed

1 Answers

1
votes

maybe not the most efficient of them all, but:

$attrSetCollection = Mage::getModel("eav/entity_attribute_set")->getCollection();
$attrSet = $attrSetCollection->addFieldToFilter("attribute_set_name", $row['osc_variants_title'])->getFirstItem();
echo $attrSet->getAttributeSetId();