Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Set&;在Magento Enterprise中获取自定义客户属性_Magento - Fatal编程技术网

Set&;在Magento Enterprise中获取自定义客户属性

Set&;在Magento Enterprise中获取自定义客户属性,magento,Magento,我们在Magento Enterprise(1.12.0.2)中创建一个自定义客户属性来存储用户帐户id,从而允许我们保持RMS与Magento同步 我需要手动设置RMS id(通过PHP),然后稍后获取RMS id。自定义属性是一个文本字段,其标签是RMS_id。我需要执行以下操作: 检查是否使用客户id设置了rms_id 如果未设置,请使用提供的值更新客户rms_id 看起来很简单,但是我是Magento开发的新手,无法找到解决此问题的方法。所有搜索都返回自定义产品属性的结果,该属性不是作为

我们在Magento Enterprise(1.12.0.2)中创建一个自定义客户属性来存储用户帐户id,从而允许我们保持RMS与Magento同步

我需要手动设置RMS id(通过PHP),然后稍后获取RMS id。自定义属性是一个文本字段,其标签是RMS_id。我需要执行以下操作:

  • 检查是否使用客户id设置了rms_id
  • 如果未设置,请使用提供的值更新客户rms_id

  • 看起来很简单,但是我是Magento开发的新手,无法找到解决此问题的方法。所有搜索都返回自定义产品属性的结果,该属性不是作为自定义客户属性的asme。任何帮助都将不胜感激。

    对于客户属性,神奇的方法应该仍然有效<代码>$\u客户->getRmsId()-如果不是,请确保该属性是集合/模型对象的一部分。这可能很有用:除了save方法外,它工作得很好。显然,Magento不喜欢saveAttribute并抛出了一个严重错误,所以我用$customer->save()替换了它;它就像一个符咒。谢谢是否有方法使用rms id加载单个客户?理想的解决方案是像$customer->loadByrmsd($rms_id)这样的东西;$customer模型中没有saveAttribute()方法。您应该使用$customer->getResource()->saveAttribute($customer,'rms_id')@NickParsonMage客户模型客户没有saveAttribute函数。尼克帕森的答案是正确的。
    /* @var $customer Mage_Customer_Model_Customer */    
    $customer = Mage::getModel('customer/customer')->load({customer id});
    
    if (!$customer->getRmsId()) {
        $customer->setRmsId({value});
        //the original version of this answer was wrong; need to use the resource model.
        $customer->getResource()->saveAttribute($customer,'rms_id');
    }