2012-07-25 116 views
0

如果我刪除core_resource.code ='my_setup_module'並重新運行magento,我的sql /文件中的所有內容都會重複。有沒有辦法來防止這種情況? (僅此而已。這剩下的就是緩衝材料,計算器讓我提交。)Magento addAttribute刪除core_resource條目後重復

例如SQL文件

$installer->addAttribute('catalog_product', 'googlemerchant_category', array(
    'label'   => 'Google Merchant category', 
    'type'   => 'varchar', 
    'input'   => 'multiselect', 
    'backend'  => 'eav/entity_attribute_backend_array', 
    'global'  => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 
    'group'   => 'Google Merchant', 
    'visible'  => 1, 
    'required'  => 0, 
    'position'  => 2, 
    'option' => 
     array (
      'value' => 
       array(
        'option1' => array('Apparel & Accessories > Clothing'), 
        'option2' => array('Apparel & Accessories > Clothing > Activewear > Sweatshirts'), 
        'option3' => array('Apparel & Accessories > Clothing > Underwear & Socks > Socks'), 
        'option4' => array('Apparel & Accessories > Clothing Accessories'), 
        'option5' => array('Apparel & Accessories > Shoes'), 
        'option6' => array('Apparel & Accessories > Shoes > Athletic Shoes'), 
        'option7' => array('Apparel & Accessories > Shoes > Sneakers'), 
        'option8' => array('Apparel & Accessories > Clothing > Hats'), 
        'option9' => array('Apparel & Accessories > Clothing > Shorts'), 
        'option10' => array('Apparel & Accessories > Handbags'), 
        'option11' => array('Food, Beverages & Tobacco > Food Items'), 
        'option12' => array('Hardware > Flooring'), 
        'option13' => array('Health & Beauty > Health Care > Physical Therapy Equipment'), 
        'option14' => array('Media'), 
        'option15' => array('Media > Books'), 
        'option16' => array('Media > Books > Non-Fiction'), 
        'option17' => array('Media > Books > Non-Fiction > Body, Mind & Spirit Books'), 
        'option18' => array('Media > Books > Non-Fiction > Health & Fitness Books'), 
        'option19' => array('Media > DVDs & Videos'), 
        'option20' => array('Sporting Goods > Exercise & Fitness'), 
        'option21' => array('Sporting Goods > Exercise & Fitness > Abdominal Equipment'), 
        'option22' => array('Sporting Goods > Exercise & Fitness > Exercise Balls'), 
        'option23' => array('Sporting Goods > Exercise & Fitness > Exercise Bands'), 
        'option24' => array('Sporting Goods > Exercise & Fitness > Foam Rollers'), 
        'option25' => array('Sporting Goods > Exercise & Fitness > Free Weight Bars'), 
        'option26' => array('Sporting Goods > Exercise & Fitness > Gym Mats'), 
        'option27' => array('Sporting Goods > Exercise & Fitness > Jump Ropes'), 
        'option28' => array('Sporting Goods > Exercise & Fitness > Medicine Balls'), 
        'option29' => array('Sporting Goods > Exercise & Fitness > Stopwatches'), 
        'option30' => array('Sporting Goods > Exercise & Fitness > Weight Benches'), 
        'option31' => array('Sporting Goods > Exercise & Fitness > Weightlifting Belts'), 
        'option32' => array('Sporting Goods > Exercise & Fitness > Weightlifting Gloves'), 
        'option33' => array('Sporting Goods > Exercise & Fitness > Weightlifting Machine Accessories'), 
        'option34' => array('Sporting Goods > Gymnastics > Gymnastics Bars'), 
        'option35' => array('Sporting Goods > Gymnastics > Gymnastics Mats'), 
        'option36' => array('Sporting Goods > Gymnastics > Gymnastics Rings'), 
        'option37' => array('Sporting Goods > Jumping') 
       ) 
     ) 
)); 

回答

1

很明顯我們複製當您刪除模塊的core_resource條目,它會重新運行整個安裝程序並再次找到您的安裝文件來執行。請記住,Magento只知道模塊的設置是否由core_resource表運行。所以,如果它沒有在那裏找到你的模塊條目,它將只運行你的設置文件,而不管它是否已經運行。

+0

有沒有什麼辦法可以「僞證」呢? – 2012-07-25 15:28:02

+0

請檢查這篇文章:http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-6-magento-setup-resources/ – Kalpesh 2012-07-25 15:32:43

+0

謝謝。我猜如果我真的想要,我可以執行一些SQL'select'語句並從那裏開始。我們有信息重複的地方有問題。我知道關於core_resource,但想確定沒有我缺少的邊緣案例。 謝謝。 – 2012-07-25 15:51:54