Magento API アップロードした商品がフロントエンドに表示されない - バックエンドに再保存しない限り
-
13-09-2019 - |
質問
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");
}
解決
手動または API 経由で Magento データベースに挿入されたものには属性が欠落しており、何らかの理由で Magento UI に保存するとデフォルト値に設定されるというケースを私は多く見てきました。UI はデフォルト値を適切に設定しますが、API またはデータベースの挿入では属性が設定されません。
したがって、あなたの場合、デバッグの最初の行は次のようになります
- API を使用して製品を「アップロード」します (どのような API メソッドを使用していますか?)それともカスタム API を使用していますか?)
- その製品の属性値のスナップショットを取得します。
- Magento UI 経由で製品を保存する
- その製品の属性値のスナップショットを取得します。
- 違い #2 と #4
- "upload" [原文ママ] メソッドが #4 に存在するが #2 には存在しない属性を設定していることを確認してください。
Magento では、 エンティティの属性値 モデリング スキーム。クエリではなくデータベースの柔軟性を最適化します。簡単に言うと、次のクエリを実行して、基本的な製品属性値を取得できます。
[3455] のすべてのインスタンスをデータベースの製品 ID に置き換えることができます。この ID は、Magento 管理 UI で Proudct の URL を調べることで取得できます。クエリを実行できます それなし ただし、デフォルトのインデックス作成はこのユースケース向けに最適化されていないため、データベースのサイズによってはクエリが遅くなります。
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;
他のヒント
「私は空の文字列で設定されたかなりの数の余分な性質は。だから私はそれらのすべてを設定する場所が比較とするために、あなたのSQLを使用していました。そして、それは効果を持っていないようでした。それが煮詰め終了で私はmageProduct.websites設定=新しい[] { "塩基"}; - ダン14時12" 分に6月16日
おかげでダン!これは私のために働きました。クラスのコードサンプルはmageProduct.websitesを示し=新しい[] {「0」}。間違っていた、私はmageProduct.websites =新しい[] {「ベース」}にそれを変更し、そしてそれが動作します。
このページでは、最も有用でした。 CSVのインポートを実行している間、私は私が追加する必要がありましたが見つかりました: _product_websitesそれがインポートされた各製品のベースにしたことを確認します。また、私は輸入がうまく働い見つけた後、あなたは1に設定さis_in_stockのためのフィールドを持っていることを確認します。
私のために働いた最小フィールドのリストは以下のとおりです。 SKU、 _格納、 _attribute_set、 _タイプ、 _カテゴリー、 _root_category、 説明、 msrp_display_actual_price_type、 msrp_enabled、 名前、 簡単な説明、 数量、 is_in_stock、 状態、 tax_class_id、 可視性、 価格、 重量、 _product_websites
サンプルレコードます:
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