管理パネルでproduct attribute
「 」として作成しましたmerchant
。テーブルmerchant
に新しい列を追加したい。sales_flat_order_item
新しい列には、属性名を入力する必要があります。イベントオブザーバーメソッドを使用せずにこれを行うにはどうすればよいですか? どんな助けでも大歓迎です。(私はマジェントCE 1.7を使用しています)
1 に答える
まず、sales_flat_quote item と sales_flat_order_item に新しい列を追加する必要があります。最良の説明はここにあります: http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-6-magento-setup-resources
セットアップ リソースは次のようにする必要があります。
$installer = $this;
$installer->startSetup();
$installer->getConnection()
->addColumn(
$installer->getTable('sales/quote_item'), 'merchant', 'VARCHAR(20) NOT NULL');
$installer->getConnection()
->addColumn(
$installer->getTable('sales/order_item'), 'merchant', 'VARCHAR(20) NOT NULL')
quote_item から order_item にデータを渡すには、config.xml で次のように指定する必要があります。
そして、見積もりアイテムにデータを保存するには、オブザーバーが必要です。これを読むことをお勧めします: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method イベントあなたが探しているのは、オブザーバーメソッドでは、このようなことをしなければなりません
class MyNamespace_Mymodule_Model_Observer
{
public function saveTheMerchant($observer)
{
$item = $observer->getEvent()->getQuoteItem();
$product = $item->getProduct();
$item->setMerchant($product->getMethant());
$item->save();
}
}
ご挨拶。