关闭

65. magent 手动创建用户

103人阅读 评论(0) 收藏 举报
分类:

1.手动创建用户

//$groups = Mage::getResourceModel('customer/group_collection')->getData();
//如不了解 ‘customer_group_id’, 可以把 $groups 打印出来,选择你所需的 groupId 号
//其实就是相当于选择用户组, 示例中我选择 1

//填写新建的用户帐号信息
$newAccount = array(
                'email'     => 'shawn0828@hotmail.com',
                'password'  => 'test123456',
                'firstName' => 'Shawn',
                'lastName'  => 'Sun',
                'groupId'   => '1',
);

$customer = Mage::getModel('customer/customer');
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->loadByEmail($newAccount['email']);

if (!$customer->getId()) {

    $customer->setGroupId($newAccount['groupId']);
    $customer->setEmail($newAccount['email']);
    $customer->setFirstname($newAccount['firstName']);
    $customer->setLastname($newAccount['lastName']);
    $customer->setPassword($newAccount['password']);
    $customer->setConfirmation(null);
    $customer->save();

    echo $customer->getId();
}

2.获取一个目录中最低的产品价格 Minimum Product Price in a Category

$layer    = Mage::getSingleton('catalog/layer');

$category = Mage::getModel('catalog/category')->load($this->getCategoryId());

if ($category->getId()) {
    $origCategory = $layer->getCurrentCategory();
    $layer->setCurrentCategory($category);
}

$collection = $layer->getProductCollection();
$collection->getSelect()->reset('order');
$collection->getSelect()->order('minimal_price','asc');
$collection->getSelect()->limit(1);

echo $collection->getFirstItem()->getMinimalPrice();

http://www.sunzhenghua.com/magento-create-customer-account-and-get-minimum-product

http://www.unexpectedit.com/magento/how-magento-stores-customer-password

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:345525次
    • 积分:11418
    • 等级:
    • 排名:第1369名
    • 原创:265篇
    • 转载:613篇
    • 译文:479篇
    • 评论:11条
    最新评论