2015-05-14 42 views
0

我正在創建一個模塊以在我的商店中插入新屬性和新類型的產品。作爲模板,我使用虛擬產品類型的相同註冊屏幕,並僅包含此類產品的新選項。 對於這一點,在我的config.xml中,我用:需要在新類型的產品中創建新屬性

<catalog> 
      <product> 
       <type> 
        <incomm_virtual translate="label" module="incomm"> 
         <label>Incomm Virtual</label> 
         <model>incomm/product_type</model> 
         <price_model>incomm/product_price</price_model> 
         <is_qty>1</is_qty> 
         <composite>0</composite> 
         <can_use_qty_decimals>0</can_use_qty_decimals> 
        </incomm_virtual> 
       </type> 
      </product> 
     </catalog> 

,並配置在同一config.xml中的SQL的安裝:

<resources> 
    <abc_incommproduct_setup> 
     <setup> 
      <module>ABC_Incomm</module> 
      <class>Mage_Catalog_Model_Resource_Setup</class> 
     </setup> 
    </abc_incommproduct_setup> 
</resources> 

使用的下一個文件mymodule中/模型/含產物/ type.php:

class ABC_Incomm_Model_Product_Type 
     extends Mage_Catalog_Model_Product_Type_Virtual 
{ 
    const TYPE_INCOMM   = 'incomm'; 
    const XML_PATH_AUTHENTICATION = 'catalog/incomm/authentication'; 

    protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode) 
    { 
     if ($this->_isStrictProcessMode($processMode)) { 
      return Mage::helper('ABC_Incomm_Helper_Data')->__(
       'Incomm product %s cannot be added to cart. ' . 
       ' On the product detail page click the "Go to parent site"'. 
       ' button to access the product.', 
       $product->getName() 
      ); 
     } 
     return parent::_prepareProduct($buyRequest, $product, $processMode); 
    } 
} 

在相同的文件夾中,virtual.php:

class ABC_Incomm_Model_Product_Virtual extends Mage_Catalog_Model_Product_Type_Virtual { 
} 

最後,在SQL文件夾中的SQL安裝文件/ abc_incommproduct_setup/MySQL的安裝,4-0.1.0.php

$this->startSetup(); 

$this->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'terms_of_use', array(
    'group'   => 'General', 
    'input'   => 'textarea', 
    'type'   => 'text', 
    'sort_order' => 4, 
    'label'   => 'Terms of use', 
    'backend'  => '', 
    'visible'  => true, 
    'required'  => true, 
    'wysiwyg_enabled' => true, 
    'visible_on_front' => true, 
    'apply_to'    => 'incomm', //only in this type of product 
    'global'  => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 
)); 

$this->endSetup(); 

我的問題是這樣的,禁止在Magento緩存後,明確緩存幷包含新類型的產品,在Product Types列表中出現我的NEW類型的產品,但選項不會加載通過sql插入的新屬性,發生了什麼?我的sqlinstall.php沒有運行?

回答

1

可能是因爲您的新產品類型是,如​​3210中所指定的,而不是incomm。嘗試編輯'apply_to' => 'incomm''apply_to' => 'incomm_virtual'並重新運行安裝程序

0

如果您升級腳本,請遵循與安裝升級腳本類似的模式,但文件名現在是data-upgrade- {old-version} - {new-版本} .php,它們位於數據文件夾下。

如果你不想升級你的腳本,只是改變它。不要忘記從core_resource表中刪除youmodule_setup代碼的現有條目。它只能立即加載。如果你不刪除你的腳本不會被加載。

相關問題