1

我在 Magento 中保存产品时遇到问题。

我有一个产品并且有多个商店(多个组和视图)。

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

假设我正在为商店编辑产品French并单击保存。但问题是,新保存/输入的 store 值French被复制到所有商店(EnglishGerman等)。

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

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

谢谢

新增:

我也想知道储蓄price, cost, special price, grouped price, tier price

4

3 回答 3

1

在保存之前设置您要为其保存产品的商店的 storeId,同样适用于加载产品

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

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

祝你好运!

于 2013-06-18T15:22:48.467 回答
1

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

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

但是,为了使其他字段(成本、特价、分组价格、等级价格)也表现得像价格字段/属性,我需要将 Scope(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 

我找到了我需要的属性。并将is_global它们的值更改为0

这样做之后,一切都按照我的需要正常工作。我知道这种手动过程。我正在尝试获得程序化解决方案。

于 2013-06-21T18:02:31.757 回答
0

我在 1.5 中遇到了这个问题

我覆盖 app\code\core\Mage\Catalog\Model\Resource\Eav\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'));
            }
        }
于 2013-11-18T11:56:35.727 回答