从基础开始,我想以编程方式导入客户。这是我的代码。
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
require 'app/Mage.php';
require_once 'Zend/Crypt/Hmac.php';
Mage::app('default');
$websiteId = Mage::app()->getWebsite()->getId();
$store = Mage::app()->getStore();
$customer = Mage::getModel("customer/customer");
$customer->setWebsiteId($websiteId);
$customer->setStore($store);
$customer->setFirstname('fst');
$customer->setLastname('lst');
$customer->setEmail('fst@ex.com');
$customer->setPassword('somepassword');
$customer->save();
echo $customer->getId();
$address = Mage::getModel("customer/address");
$address->setCustomerId($customer->getId());
$address->setFirstname($customer->getFirstname());
$address->setLastname($customer->getLastname());
$address->setCountryId('US');
$address->setPostcode('31000');
$address->setCity('Osijek');
$address->setTelephone('0038511223344');
$address->setFax('0038511223355');
$address->setCompany('Inchoo');
$address->setStreet('Kersov');
$address->setIsDefaultBilling('1');
$address->setIsDefaultShipping(false);
$address->setSaveInAddressBook('1');
$address->save();
但它只创建帐单地址。我想再添加一个地址并将其设置为送货。