デフォルトでMagentoのOrder REST APIは、注文に使用された店舗クレジット金額(DBのcustomer_balance_amount col)を提出しません。私はそれをAPIインターフェイスに公開する必要がありますが、現在は不可能です。オブザーバを使用して、それはAPIデータ上の任意の反射Magento 2のOrder REST APIにcustomer_balance_amountを追加
と
http://www.ipragmatech.com/extend-magento2-rest-api-easy-steps/持っていないようです - -
http://magehit.com/blog/how-to-get-value-of-custom-attribute-on-magento-2-rest-api/私は成功してみましたが、それは実際に作成に関する:私は2つのアプローチを試してみました現在のAPIをオーバーライド/拡張するのではなく、新しいエドポイントを作成します。
モジュール販売コアモジュール内のOrderInterfaceとOrderモデルを直接変更することで、実際にそれを再現することができましたが、コアを変更するのではなく「正しい」方法を実現したいと思います。
誰かが何らかの知識を共有してくれれば、感謝しています。
編集:ソリューションの作業をしたコードを追加しますが、目標はそのようなコアファイルを編集し、それ適切な方法ではないようにすることです:
ベンダー/ Magentoの/モジュール販売/ API /データ/ OrderInterface.php:
/*
* Customer Balance Amount
*/
const CUSTOMER_BALANCE_AMOUNT = 'customer_balance_amount';
/**
* Returns customer_balance_amount
*
* @return float Customer Balance Amount
*/
public function getCustomerBalanceAmount();
/**
* Sets the customer_balance_amount for the order.
*
* @param float $amount
* @return $this
*/
public function setCustomerBalanceAmount($amount);
ベンダー/ Magentoの/モジュール販売/モデル/ Order.php:
/**
* Returns customer_balance_amount
*
* @return float
*/
public function getCustomerBalanceAmount()
{
return $this->getData(OrderInterface::CUSTOMER_BALANCE_AMOUNT);
}
/**
* Sets the customer_balance_amount for the order.
*
* @param float $amount
* @return $this
*/
public function setCustomerBalanceAmount($amount)
{
return $this->setData(OrderInterface::CUSTOMER_BALANCE_AMOUNT, $amount);
}
よろしく、 アレックス
Magentoのは、拡張子がベンダー/ Magentoの/モジュール-顧客バランスの/ etc/extension_attributes.xmlに属性としてGiftMessageモジュールを見てみると、バランスの列を定義しないのでそれはこのようになります
リンクコードが得意ですが、あなたの質問に関連するコードを含める必要があります – Machavity
@Machavityは発言に感謝します。私は実際に動作するサンプルコードを追加しましたが、コアを直接変更することで、私の質問は「正しい方法」にする方法です。 –