【发布时间】:2019-04-20 12:22:55
【问题描述】:
为了将客户下的订单与来自 WooCommerce REST API 的某些信息通过REST API 存储到 Exact Online 仪表板。我用过PHP Client library for Exact Online。
虽然存在问题 - 将数据存储到 Exact Online 后,无法访问数组中的特定字段。具体来说,当使用
进行 REST API 调用时 /api/v1/{division}/bulk/CRM/Accounts?
$filter=ID eq Email eq'nishanth@gmail.com'&$select=ID,Email
或
$url = "https://start.exactonline.de/api/v1/" + mandant.number + "/crm/Accounts?
$filter=Email eq '" + orderitem.email + "'&$select=ID,Code";
下面是代码
$customer = [
'address' => 'No.22/N, 91 Cross, XYZ Street, ABC Road',
'address2' => 'DEF',
'city' => 'GHI',
'customerid' => '999',
'country' => 'DE',
'name' => 'Nishanth',
'zipcode' => '123456'
];
// Create a new account
$account->AddressLine1 = $customer['address'];
$account->AddressLine2 = $customer['address2'];
$account->City = $customer['city'];
$account->Code = $customer['customerid'];
$account->Country = $customer['country'];
$account->IsSales = 'true';
$account->Name = $customer['name'];
$account->Postcode = $customer['zipcode'];
$account->Email = 'nishanth@gmail.com';
$account->Status = 'C';
$account->save();
这是用Email ID过滤后得到的结果
echo '<pre>'; print_r($account->filter("Email eq 'nishanth@gmail.com'"));
[attributes:protected] => Array
(
[Accountant] =>
[AddressLine1] => No.22/N, 91 Cross, XYZ Street, ABC Road
[AddressLine2] => DEF
[City] => GHI
[Code] => 1000
[ConsolidationScenario] => 6
[Country] => DE
[CountryName] => Germany
[Created] => /Date(1555764341137)/
[Creator] => 5bbfbd93-52f1-4f4b-b34e-fd213e479f8e
[CreatorFullName] => Nishanth
[Division] => 54810
[Email] => nishanth@gmail.com
[ID] => bb124287-647c-4267-bd60-004efa1302aa
[LogoThumbnailUrl] => https://start.exactonline.de//docs/images/placeholder_account_myeol.png
[LogoUrl] => https://start.exactonline.de//docs/images/placeholder_account_myeol.png
[Modified] => /Date(1555764341137)/
[Modifier] => 5bbfbd93-52f1-4f4b-b34e-fd213e479f8e
[ModifierFullName] => Nishanth
[Name] => Nishanth Jay
[Postcode] => 123456
)
利用以下内置函数,例如,
public function find()
{
$result = $this->connection()->get($this->url);
return new self($this->connection(), $result);
}
public function findWithSelect($select = '')
{
$result = $this->connection()->get($this->url, [
'$select' => $select
]);
return new self($this->connection(), $result);
}
尽管使用以下内置函数进行调用:
$Accounts->filter("Email eq 'nishanth@gmail.com'")[0]->findWithSelect('ID');
$checkAccount = $Accounts->filter("Email eq 'nishanth@gmail.com'");
$checkAccount[0]->find('ID');
$checkAccount[0]->findWithSelect('Code');
上面的内置库导致
[attributes:protected] => Array
(
)
我应该如何访问数组中的特定属性?
同样,通过$getCurrentDivision->findWithSelect('CurrentDivision'); 或$getDivision->CurrentDivision; 等调用可以轻松地从库中检索CurrentDivision
为什么在检索数组后,同一个函数不能工作?
【问题讨论】:
标签: php exact-online picqer-exact-php-client