0
MagentoトラフのPHPからデータを取得しようとしていますが、動作しますが、複数のコレクションを追加する必要があります。私はちょうど初心者ですので、私を許してください:-)Magentoは関数のトラフを取得する
私は顧客の詳細を得るために以下のコードを使用していますが、これは問題ありません。 最後の列に郵便番号を記入するためのアドレスの詳細を取得するには、顧客/住所を追加する必要があります。
<?php
function getcustomers() {
/* Magento's Mage.php path
* Mage Enabler users may skip these lines
*/
require_once ("app/Mage.php");
umask(0);
Mage::app("nl");
/* Magento's Mage.php path */
/* Get customer model, run a query */
$collection = Mage::getModel('customer/customer')
//$collection = Mage::getModel('customer/address')
->getCollection()
->addAttributeToSelect('*');
$result = array();
foreach ($collection as $customer) {
$result[] = $customer->toArray();
}
return $result;
}
?>
<html>
<head>
<title>Customers</title>
<style>
table {
border-collapse: collapse;
}
td {
padding: 5px;
border: 1px solid #000000;
}
</style>
</head>
<body>
<table>
<tr>
<td>ID</td>
<td>Lastname</td>
<td>Firstname</td>
<td>Email</td>
<td>Is Active?</td>
<td>Date Created</td>
<td>Date Updated</td>
<td>Website ID</td>
<td>Store ID</td>
<td>Zip Code</td>
</tr>
<?php
$result = getcustomers();
if(count($result) > 0){
foreach($result as $key => $value){
echo "<tr>";
echo "<td>".$value['entity_id']."</td>";
echo "<td>".$value['lastname']."</td>";
echo "<td>".$value['firstname']."</td>";
echo "<td>".$value['email']."</td>";
echo "<td>";
echo $value['is_active'] == 1 ? "Yes" : "No";
echo "</td>";
echo "<td>".$value['created_at']."</td>";
echo "<td>".$value['updated_at']."</td>";
echo "<td>".$value['website_id']."</td>";
echo "<td>".$value['store_id']."</td>";
echo "<td>".$value['zipcode']."</td>";
echo "</tr>";
}
}else{
echo "<tr><td colspan=\"7\">No records found</td></tr>";
}
?>
</table>
</body>
</html>
あなたは正しいですが、 '$ customer-> getData()'をまったく使用する必要はありません。顧客オブジェクトと '$ customer-> getId()'を使用するだけで済みます。 '$ customer-> getAddresses()'を呼び出し、それらのアドレスを取得します。 –
@VernBurtonああ、アドレスが顧客の一部であるかどうかはわかりませんでした:) –
@DavidYll - Magento Uで開発者を見たことがありますか? –