문제

Magento의 Sales_Quote_Address 모델에 사용자 정의 특성을 추가하고 싶습니다.나는 이제 몇 시간 동안 Google에서 검색했으며, 그렇게하는 방법을 찾을 수 없습니다.가능합니까?아니면 Sales_Order 자체에서 속성을 설정하고 그 후에 그립니다.

고맙습니다

도움이 되었습니까?

해결책

그래서, 내가 끝난 일은 다음과 같습니다 :

$installer = $this;
$installer->startSetup();
/* @var $addressHelper Mage_Customer_Helper_Address */
$addressHelper = Mage::helper('customer/address');
$store         = Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID);

/* @var $eavConfig Mage_Eav_Model_Config */
$eavConfig = Mage::getSingleton('eav/config');
// update customer address user defined attributes data
$attributes = array(
    'attribute_name'           => array(
        'label'    => 'Attribute label',
        'backend_type'     => 'int',
        'frontend_input'    => 'select',
        'is_user_defined'   => 0,
        'is_system'         => 0,
        'is_visible'        => 0,
        'sort_order'        => 140,
        'is_required'       => 0,
        'multiline_count'   => 0
    ),
);

foreach ($attributes as $attributeCode => $data) {
    $attribute = $eavConfig->getAttribute('customer_address', $attributeCode);
    $attribute->setWebsite($store->getWebsite());
    $attribute->addData($data);
    $usedInForms = array(
        'adminhtml_customer_address',
        'customer_address_edit',
        'customer_register_address'
    );
    $attribute->setData('used_in_forms', $usedInForms);
    $attribute->save();
}

    $installer->run("
            ALTER TABLE {$this->getTable('sales_flat_quote_address')} ADD COLUMN `column_name` TINYINT(4) DEFAULT NULL;
            ALTER TABLE {$this->getTable('sales_flat_order_address')} ADD COLUMN `column_name` TINYINT(4) DEFAULT NULL;
            ");
    $installer->endSetup();
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top