2

Magento API 経由で製品をアップロードしていますが、フロントエンドに表示されません。バックエンドに入り、それらを開き、何も変更せず、製品を保存すると、製品が表示されます。

理由はありますか?バックエンドに保存する行為は、DBにいくつかの余分なフラグを保存していると思いますが、何がわかりません。

@スティーブ・マドセン。ここにコードがあります。バックエンド インターフェイスがそれを促し、製品を開いたので、重要なものが欠けているとは思いません。

public void Import(Product product)
        {
            var mageProduct = new catalogProductCreateEntity();
            mageProduct.name = product.Name;
            mageProduct.description = product.Description;
            mageProduct.price = product.Price.ToString();
            mageProduct.short_description = product.ShortDescription;
            mageProduct.description = product.Description;
            mageProduct.status = "1";
            mageProduct.weight = "0";
            mageProduct.tax_class_id = "2";

            mageProduct.gift_message_available = "0";


            var additionalattributes = new associativeEntity[4];

            var entity = new associativeEntity();
            entity.key = "ship_price";
            entity.value = product.PostageCost;
            additionalattributes[0] = entity;

            entity = new associativeEntity();
            entity.key = "depth_cm";
            entity.value = product.Depth;
            additionalattributes[1] = entity;

            entity = new associativeEntity();
            entity.key = "height_cm";
            entity.value = product.Height;
            additionalattributes[2] = entity;

            entity = new associativeEntity();
            entity.key = "width_cm";
            entity.value = product.Width;
            additionalattributes[3] = entity;

            mageProduct.additional_attributes = additionalattributes;

            _m.catalogProductCreate(MageSessionProvider.GetSession(), "simple", "26", product.SKU, mageProduct);

            var stock = new catalogInventoryStockItemUpdateEntity();
            stock.manage_stock = 0;
            stock.qty = "0";

            _m.catalogInventoryStockItemUpdate(MageSessionProvider.GetSession(), product.SKU, stock);
            Console.WriteLine(product.Name + " imported");
        }
4

3 に答える 3

3

手動で、または API を介して Magento データベースに挿入された何かが、何らかの理由で Magento UI に保存されたときにデフォルト値に設定される属性が欠落しているケースをたくさん見てきました。UI はデフォルト値を適切に設定していますが、API またはデータベースの挿入では属性が設定されていません。

したがって、あなたの場合、デバッグの最初の行は次のようになります

  1. API を使用して製品を「アップロード」[原文のまま] (どの API メソッドを使用していますか? または、カスタム API を使用していますか?)
  2. その商品の属性値のスナップショットを取得します
  3. Magento UI を介して製品を保存します
  4. その商品の属性値のスナップショットを取得します
  5. 差分 #2 と #4
  6. 「アップロード」[sic] メソッドが #2 ではなく #4 に存在するすべての属性を設定していることを確認してください

Magento は、クエリではなくデータベースの柔軟性を最適化するエンティティ属性値モデリング スキームを使用します。簡単に言えば、次のクエリを実行して、基本的な製品属性値を取得できます。

[3455] のすべてのインスタンスをデータベースの製品 ID に置き換える必要があります。この ID は、Magento 管理 UI で proudct の URL を調べることで取得できます。WHERE 句を使用せずにクエリを実行できますが、既定のインデックス作成はこのユース ケースに最適化されておらず、データベースのサイズによってはクエリが遅くなります。

SELECT eav_attribute.frontend_label, eav_attribute.attribute_code,
catalog_product_entity_varchar.value
FROM catalog_product_entity
LEFT JOIN catalog_product_entity_varchar ON catalog_product_entity.entity_id = catalog_product_entity_varchar.entity_id
LEFT JOIN eav_attribute on catalog_product_entity_varchar.attribute_id = eav_attribute.attribute_id
WHERE catalog_product_entity.entity_id = 3455

UNION

SELECT eav_attribute.frontend_label, eav_attribute.attribute_code,
catalog_product_entity_text.value
FROM catalog_product_entity
LEFT JOIN catalog_product_entity_text ON catalog_product_entity.entity_id = catalog_product_entity_text.entity_id
LEFT JOIN eav_attribute on catalog_product_entity_text.attribute_id = eav_attribute.attribute_id
WHERE catalog_product_entity.entity_id = 3455

UNION

SELECT eav_attribute.frontend_label, eav_attribute.attribute_code,
catalog_product_entity_datetime.value
FROM catalog_product_entity
LEFT JOIN catalog_product_entity_datetime ON catalog_product_entity.entity_id = catalog_product_entity_datetime.entity_id
LEFT JOIN eav_attribute on catalog_product_entity_datetime.attribute_id = eav_attribute.attribute_id
WHERE catalog_product_entity.entity_id = 3455

UNION

SELECT eav_attribute.frontend_label, eav_attribute.attribute_code,
catalog_product_entity_decimal.value
FROM catalog_product_entity
LEFT JOIN catalog_product_entity_decimal ON catalog_product_entity.entity_id = catalog_product_entity_decimal.entity_id
LEFT JOIN eav_attribute on catalog_product_entity_decimal.attribute_id = eav_attribute.attribute_id
WHERE catalog_product_entity.entity_id = 3455

UNION

SELECT eav_attribute.frontend_label, eav_attribute.attribute_code,
catalog_product_entity_gallery.value
FROM catalog_product_entity
LEFT JOIN catalog_product_entity_gallery ON catalog_product_entity.entity_id = catalog_product_entity_gallery.entity_id
LEFT JOIN eav_attribute on catalog_product_entity_gallery.attribute_id = eav_attribute.attribute_id
WHERE catalog_product_entity.entity_id = 3455

UNION

SELECT eav_attribute.frontend_label, eav_attribute.attribute_code,
catalog_product_entity_int.value
FROM catalog_product_entity
LEFT JOIN catalog_product_entity_int ON catalog_product_entity.entity_id = catalog_product_entity_int.entity_id
LEFT JOIN eav_attribute on catalog_product_entity_int.attribute_id = eav_attribute.attribute_id
WHERE catalog_product_entity.entity_id = 3455;
于 2009-06-15T22:22:02.683 に答える
1

このページが一番役に立ちました。CSV インポートの実行中に、_product_websites を追加し、インポートされた各製品のベースに設定されていることを確認する必要があることがわかりました。また、is_in_stock のフィールドが 1 に設定されていることを確認してください。その後、インポートが正常に機能することがわかりました。

私のために働いた最小フィールドのリストは次のとおりです。

サンプルレコード:

ku,_store,_attribute_set,_type,_category,_root_category,description,msrp_display_actual_price_type,msrp_enabled,name,short_description,status,tax_class_id,visibility,price,weight,_product_websites,qty,is_in_stock
CC0003,,Default,simple,Specialist Therapeutics,Products,Conn Test #3,Use config,Use config,Conn Test #3,ConnTest,1,0,4,0,1,base,3000,1
于 2013-02-15T16:33:32.277 に答える
1

「あなたの SQL を使用して比較したところ、空の文字列で設定されたかなりの数の余分なプロパティがありました。そのため、それらすべてを設定しました。そして、それは効果がないようでした。最終的には、mageProduct を設定することになりました。 .websites = new[] { "base" }; – ダン 6 月 16 日 14:12"

ありがとうダン!これは私にとってはうまくいきました。クラス コード サンプルは、mageProduct.websites = new[] { "0" }; を示しています。これは正しくありません。mageProduct.websites = new[] { "base" }; に変更しました。そしてそれは動作します。

于 2009-09-16T18:00:27.177 に答える