【问题标题】:Get Magento Attribute Set id in import script在导入脚本中获取 Magento 属性集 id
【发布时间】:2013-03-21 09:23:22
【问题描述】:

我正在尝试修改 magento oscommerce 导入脚本以使用属性和可配置产品。至少可以说这是一个挑战。

但我正在取得进展。目前我正在尝试将属性集名称添加到magento,之后,我正在写入我需要magento属性集ID的tmp表,用于我刚刚创建的属性集。

我的问题是我不知道如何获取该 ID。

我当前的代码:

$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);  

    }

}

问题是 $variant->getId()。我需要什么才能获得该 ID?

【问题讨论】:

  • createAttributeSet 方法定义在哪里??
  • 在我的脚本中的公共函数中
  • 是的,你能把它贴在这里让人们看到吗?

标签: magento import attributes


【解决方案1】:

也许不是最有效的,但是:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-11
    • 1970-01-01
    相关资源
    最近更新 更多