我需要一些幫助做下列事情。Magento編程:在檢查現有重複項並獲取manu時導入製造商。 ID
我試圖從導入的新制造商不存在(如果新的製造商名稱已經存在,跳過)並導入新的製造商ID,從導入的目標商店中導入製造商列表。
我有代碼只是添加製造商W/O檢查現有製造商的名稱或獲得新的製造商ID。代碼在這裏,但我需要上面說明的能力。
任何幫助將是偉大的。提前致謝。
<?php
require_once 'app/Mage.php';
umask(0);
Mage::app('default');
$_manufacturers = file('manufacturers.txt');
$_attribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', 'manufacturer');
$manufacturers = array('value' => array(), 'order' => array(), 'delete' => array());
$i = 0;
foreach($_manufacturers as $_manufacturer){
$i++;
$manufacturers['value']['option_' . $i] = array($_manufacturer);
}
$_attribute->setOption($manufacturers);
try{
$_attribute->save();
echo 'Manufacturer successfully imported';
}catch(Exception $e){
echo 'Import Error::'.$e->getMessage();
}
?>
-1 http://www.emilvikstrom.se/whyidownvote.html(有什麼你試過了嗎?) –
我看過網際網路,沒有找到任何幫助。我需要的只是預先檢查一個要添加的製造商是否已經存在,如果沒有,請添加它並獲取其新ID。我試過使用上面的代碼。 – user1433709
所以你還沒有嘗試寫任何代碼? –