1

3つの異なるストアビューでMagento1.5.0.1をインストールしています。途中のある時点で、2つのストアが製品属性のデフォルト値を使用しません。私は、すべての商品がすべての店舗でデフォルト値を使用するようにする方法を見つけようとしています。そうすれば、クライアントは1か所で更新するだけで済みます。この記事を見つけましたが、具体的に呼ばれる製品にのみ適用されるようです。誰かが私の状況でそのコードを使用する方法を説明できますか?または、新しいコードを提案しますか?

4

3 に答える 3

9

これを機能させる唯一の方法は、MySQLを使用することでした。

DELETE FROM `catalog_product_entity_text` where store_id != 0;
DELETE FROM `catalog_product_entity_datetime` where store_id != 0;
DELETE FROM `catalog_product_entity_decimal` where store_id != 0;
DELETE FROM `catalog_product_entity_int` where store_id != 0;
DELETE FROM `catalog_product_entity_varchar` where store_id != 0;

上記は、すべての属性にデフォルト値を使用するようにすべての製品をリセットします。

于 2013-04-02T03:05:48.843 に答える
0

Mage :: getSingleton('catalog / product_action')を使用して、大量の製品を連続して更新する必要があります。

1°)すべての製品の使用について、必要な製品のIDを取得します:

$ids = Mage::getModel('catalog/product')->getCollection()->getAllIds();

2°)属性のリストを作成し、値を「false」に関連付けます

$attributes = array('name'=>false,'description'=>false,....)

3°)変更するストアIDのリストを取得し、配列にも設定します。

$stores = array(1,2,3);

次に、スクリプトを作成します。

foreach ($stores as $store_id)
{
     Mage::getSingleton('catalog/product_action')->updateAttributes($ids, $attributes, $store_id);
}

すべての商品(ID)を更新して、store_idの属性をデフォルトに設定します(「false」値のおかげで)。

于 2013-02-26T11:29:04.430 に答える
0

これにより、任意のストアに設定されている値が取得され、それらがすべての製品のデフォルト値にマージされます。

     <?php 
    $cat = mysql_connect("host", "user", "password") or die(mysql_error());
        mysql_select_db("database",$cat) or die(mysql_error());

        $types = array(
        'catalog_product_entity_text',
        'catalog_product_entity_datetime',
        'catalog_product_entity_decimal',
    'catalog_product_entity_int',
    'catalog_product_entity_varchar'
    );

    foreach($types as $type){

    $result = mysql_query("select * from $type where store_id != 0",$cat) or die(mysql_error());  

        while ($row = mysql_fetch_assoc($result)) {

            if(!is_null($row['value'])){

                mysql_query("update $type set value = '".mysql_real_escape_string(stripslashes($row['value']))."' 
                where store_id = '0' 
                and entity_id = '".$row['entity_id']."' 
                and attribute_id = '".$row['attribute_id']."'",$cat) or die(mysql_error()); 
            }

            mysql_query("delete from $type where value_id = '".$row['value_id']."'",$cat) or die(mysql_error()); 

        }

    }
?>
于 2013-06-25T02:39:42.617 に答える