2013-06-18 65 views
1

我在使用Magento保存产品时遇到问题。在magento的多个商店中保存产品的问题

我有一个产品,并有多个商店(多组和意见)。

  • 示例网站
    • 存储组1
      • 英语
      • 法国
      • 德国
    • 存储组2
      • 孟加拉
      • 印地文

说我是编辑产品的商店French并点击保存。但事情是,新保存/输入的商店French的值被复制到所有商店(EnglishGerman等)。

我需要为指定商店保存这些值(即使是价格值)。不是所有的商店。

如果解决方案是一种编程方式,我同意这样做。

感谢

新增:

我也想知道如何保存设置商店的STOREID之前节省price, cost, special price, grouped price, tier price

回答

1

我自己解决了price, cost, special price, grouped price, tier price保存问题。

我在Google上搜索并得到了一个免费的扩展名为Store View Pricing。这解决了我80%的问题。它只是提供了以商店为单位节省价格的机会。

但是,为了使其他字段(成本,特价,分组价格,等级价格)的行为与价格字段/属性一样,我需要将范围(is_global:DB名称)更改为Store View(0 :设为DB)。我确实在DB上运行以下查询:

SELECT ea.attribute_id, ea.entity_type_id, ea.attribute_code, ea.frontend_label, cea.is_global 
FROM `eav_attribute` AS ea 
INNER JOIN `catalog_eav_attribute` AS cea ON ea.attribute_id = cea.attribute_id 
WHERE `attribute_code` LIKE '%price%' 
ORDER BY ea.`attribute_id` ASC 

我找到了我需要的属性。并将其值改为0

这样做后,所有工作正常,因为我需要。我知道这是一个手动过程。我正试图获得一个程序化解决方案。

1

要保存的产品,同样正在与加载一件商品

$product->setStoreId('2')->setName('Name for Store 2')->save();

$product->setStoreId('2')->load(17)->getName()

祝你好运!

+1

感谢@ mischa-leiss的回答。节省'价格,成本,特价,分组价格,一级价格'怎么样? –

+0

你不能保存不同的商店意见不同的价格。这只是与不同的网站合作... –

0

我在1.5

这个问题,我在此改变应用程序\代码\核心\法师\目录\型号\资源\杨仁\ Mysql4 \ Abstract.php

protected function _insertAttribute($object, $attribute, $value) { 
     /** 
     * save required attributes in global scope every time if store id different from default 
     */ 
     $storeId = Mage::app()->getStore($object->getStoreId())->getId(); 
     if ($attribute->getIsRequired() && $this->getDefaultStoreId() != $storeId) { 

       $bind = array(
        'entity_type_id' => $attribute->getEntityTypeId(), 
        'attribute_id' => $attribute->getAttributeId(), 
        'store_id' => $this->getDefaultStoreId(), 
        'entity_id' => $object->getEntityId(), 
        'value' => $this->_prepareValueForSave($value, $attribute) 
       ); 
       $this->_getWriteAdapter()->insertOnDuplicate($attribute->getBackend()->getTable(), $bind, array('value')); 
      } 

protected function _insertAttribute($object, $attribute, $value) { 
     /** 
     * save required attributes in global scope every time if store id different from default 
     */ 
     $storeId = Mage::app()->getStore($object->getStoreId())->getId(); 
     if ($attribute->getIsRequired() && $this->getDefaultStoreId() != $storeId) { 

      $table = $attribute->getBackend()->getTable(); 
      $select = $this->_getReadAdapter()->select() 
        ->from($table) 
        ->where('entity_type_id = ?', $attribute->getEntityTypeId()) 
        ->where('attribute_id = ?', $attribute->getAttributeId()) 
        ->where('store_id = ?', $this->getDefaultStoreId()) 
        ->where('entity_id = ?', $object->getEntityId()); 
      $row = $this->_getReadAdapter()->fetchOne($select); 

      if (!$row) { 
       $bind = array(
        'entity_type_id' => $attribute->getEntityTypeId(), 
        'attribute_id' => $attribute->getAttributeId(), 
        'store_id' => $this->getDefaultStoreId(), 
        'entity_id' => $object->getEntityId(), 
        'value' => $this->_prepareValueForSave($value, $attribute) 
       ); 
       $this->_getWriteAdapter()->insertOnDuplicate($attribute->getBackend()->getTable(), $bind, array('value')); 
      } 
     }