2011-12-08 18 views

cevap

22

Ne denediğimi bilmiyorum, bu yüzden sadece Magento 1.6.1 kayıt formuna yeni bir schooL müşteri özniteliği eklemek için gereken tüm adımları listeleyeceğim.

  1. Tercihe göre bir modül oluşturun veya bazı .phtml dosyasında buna benzer kod yerleştirin ve bir kez çalıştırın. Bu doğru yapıyor ve bir modül oluşturuyorsanız, mysql_install dosyasına böyle bir kod koyun:

    <?php 
    $installer = $this; 
    $installer->startSetup(); 
    $setup = Mage::getModel('customer/entity_setup', 'core_setup'); 
    $setup->addAttribute('customer', 'school', array(
        'type' => 'int', 
        'input' => 'select', 
        'label' => 'School', 
        'global' => 1, 
        'visible' => 1, 
        'required' => 0, 
        'user_defined' => 1, 
        'default' => '0', 
        'visible_on_front' => 1, 
         'source'=> 'profile/entity_school', 
    )); 
    if (version_compare(Mage::getVersion(), '1.6.0', '<=')) 
    { 
         $customer = Mage::getModel('customer/customer'); 
         $attrSetId = $customer->getResource()->getEntityType()->getDefaultAttributeSetId(); 
         $setup->addAttributeToSet('customer', $attrSetId, 'General', 'school'); 
    } 
    if (version_compare(Mage::getVersion(), '1.4.2', '>=')) 
    { 
        Mage::getSingleton('eav/config') 
        ->getAttribute('customer', 'school') 
        ->setData('used_in_forms', array('adminhtml_customer','customer_account_create','customer_account_edit','checkout_register')) 
        ->save(); 
    } 
    $installer->endSetup(); 
    ?> 
    
  2. sizin modül Config.xml dosyasında. Modülümün adını Excellence_Profile olduğunu unutmayın.

    <profile_setup> <!-- Replace with your module name --> 
    <setup> 
        <module>Excellence_Profile</module> <!-- Replace with your module name --> 
        <class>Mage_Customer_Model_Entity_Setup</class> 
    </setup> 
    </profile_setup> 
    
  3. Burada müşteri kayıt formuna, bizim niteliğini katacak. 1.6.0 sürümünde (+) kullanılan phtml dosyası persistance/customer/register.phtml ve 1.6.0 sürümünde (-) kullanılan phtml dosyası customer/form/register.phtml 'dir. Bu yüzden pento dosyasını magento sürümüne göre açmalı ve bu kodu etikete eklemeliyiz. . magento 1.4.2 (+) için

    <li> 
    <?php 
    $attribute = Mage::getModel('eav/config')->getAttribute('customer','school'); 
    ?> 
    <label for="school" class="<?php if($attribute->getIsRequired() == true){?>required<?php } ?>"><?php if($attribute->getIsRequired() == true){?><em>*</em><?php } ?><?php echo $this->__('School') ?></label> 
    <div class="input-box"> 
    <select name="school" id="school" class="<?php if($attribute->getIsRequired() == true){?>required-entry<?php } ?>"> 
    <?php 
    $options = $attribute->getSource()->getAllOptions(); 
    foreach($options as $option){ 
    ?> 
    <option value='<?php echo $option['value']?>' <?php if($this->getFormData()->getSchool() == $option['value']){ echo 'selected="selected"';}?>><?php echo $this->__($option['label'])?></option> 
    <?php } ?> 
    </select> 
    </div> 
    </li> 
    
  4. tüm bu kayıt aşaması için yeterlidir. Buradan bir kullanıcı oluşturursanız, yönetici olarak okul metin alanını görmelisiniz. (-) magento 1.4.1 için , başka şey modülleri config.xml dosyasını açın ve ekleme yapmak gerekir: Bir kere, kullanıcı MyAccount-> Hesap Bilgileri bölümünde hesabını yarattı

    <global> 
         <fieldsets> 
          <customer_account> 
           <school><create>1</create><update>1</update><name>1</name></school> 
          </customer_account> 
         </fieldsets> 
    </global> 
    
  5. Okul alanını da düzenleyebilmelidir. Bunun için phtml dosyasını customer/form/edit.phtml açıp kod koymak:

    <?php 
    <li> 
    <?php 
    $attribute = Mage::getModel('eav/config')->getAttribute('customer','school'); 
    ?> 
    <label for="is_active" class="<?php if($attribute->getIsRequired() == true){?>required<?php } ?>"><?php if($attribute->getIsRequired() == true){?><em>*</em><?php } ?><?php echo $this->__('School') ?></label> 
    <div class="input-box"> 
    <select name="school" id="school" class="<?php if($attribute->getIsRequired() == true){?>required-entry<?php } ?>"> 
    <?php 
    $options = $attribute->getSource()->getAllOptions(); 
    foreach($options as $option){ 
    ?> 
    <option value='<?php echo $option['value']?>' <?php if($this->getCustomer()->getSchool() == $option['value']){ echo 'selected="selected"';}?>><?php echo $this->__($option['label'])?></option> 
    <?php } ?> 
    </select> 
    </div> 
    </li> 
    
  6. bir kayıt formu da magento ödeme sayfasında görünür. (-) burada size bir alan eklemek için, magento sürüm 1.6 için checkout/onepage/billing.phtml düzenlemeniz gereken magento sürüm 1.6 (+) dosyası ve persistant/checkout/onepage/billing.phtml ve kodu bulun: koşul sizin alanını eklerseniz bu iç

    <?php if(!$this->isCustomerLoggedIn()): ?> 
    

    <global> 
        <fieldsets> 
         <checkout_onepage_quote> 
         <customer_school> 
          <to_customer>school</to_customer> 
         </customer_school> 
         </checkout_onepage_quote> 
         <customer_account> 
          <school> 
           <to_quote>customer_school</to_quote> 
          </school> 
         </customer_account> 
         </fieldsets> 
        </global> 
    
  7. Sonraki ihtiyacımız için:

    <li> 
    <li> 
    <?php 
    $attribute = Mage::getModel('eav/config')->getAttribute('customer','school'); 
    ?> 
    <label for="school" class="<?php if($attribute->getIsRequired() == true){?>required<?php } ?>"><?php if($attribute->getIsRequired() == true){?><em>*</em><?php } ?><?php echo $this->__('School') ?></label> 
    <div class="input-box"> 
    <select name="billing[school]" id="school" class="<?php if($attribute->getIsRequired() == true){?>required-entry<?php } ?>"> 
    <?php 
    $options = $attribute->getSource()->getAllOptions(); 
    foreach($options as $option){ 
    ?> 
    <option value='<?php echo $option['value']?>'><?php echo $this->__($option['label'])?></option> 
    <?php } ?> 
    </select> 
    </div> 
    </li> 
    

    Sonraki aşağıdaki satırları ekleyin modül config.xml veya başka herhangi bir config.xml dosyasını açmak Alıntı tablosunda bazı değişiklikler yapın, yani magento'daki sales_flat_quote tablosu. Eğer bir modül varsa o zaman sql dosyasının yükseltme sürümünü oluşturmak ve bu kod koymak: Bu size magento önbelleği, özellikle “Flush Magento Önbellek” ve “Flush kaldırmasını sağlayın yaptıktan sonra

    $tablequote = $this->getTable('sales/quote'); 
    $installer->run(" 
    ALTER TABLE $tablequote ADD `customer_school` INT NOT NULL 
    "); 
    

Önbellek Deposu ”. Şimdi sipariş verdiğinizde, müşteri doğru okul özniteliğiyle oluşturulur.

+0

Büyük şeyler Teşekkür:

ben için Global-> fieldsets düğümünü uzatmak zorunda kaldı! 'Source' => 'profile/entity_school' için bunun için belirli bir model oluşturmalıyız, buna ihtiyacım yoktu, ama diğerleri için bunun bir örneğini koymak güzel olurdu. – Shadowbob

0

Yeni alanları checkout_register biçiminde kaydetmemle ilgili sorunlar yaşadım.

<global> 
    <fieldsets> 
     <checkout_onepage_quote> 
      <customer_school> 
       <to_customer>school</to_customer> 
      </customer_school> 
     </checkout_onepage_quote> 

     <checkout_onepage_billing> 
      <school> 
       <to_customer>*</to_customer> 
      </school> 
     </checkout_onepage_billing> 

     <customer_account> 
      <school> 
       <to_quote>customer_school</to_quote> 
      </school> 
     </customer_account> 

     <sales_convert_order> 
      <customer_school> 
       <to_quote>*</to_quote> 
      </customer_school> 
     </sales_convert_order> 
    </fieldsets> 
</global> 
İlgili konular