Magento 1.5,数字 SKU 和 productIdentifierType [英] Magento 1.5, numeric SKUs and productIdentifierType

查看:16
本文介绍了Magento 1.5,数字 SKU 和 productIdentifierType的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Magento 1.5 中,像这样从 C# 访问 catalogProductInfo API 调用适用于非数字 SKU:

In Magento 1.5, accessing the catalogProductInfo API call from C# like this works with non-numeric SKUs:

catalogProductRequestAttributes fetchattrib = new catalogProductRequestAttributes();
fetchattrib.attributes = new string[] { "name", "description", "and_so_on"};
fetchattrib.additional_attributes = new string[] { "custom_attribs_go_here"};

string storeView = null;
string productIdentifierType = null;
catalogProductReturnEntity ret = m_magentoClient.catalogProductInfo(
    sessionId, sku, storeView, fetchattrib, productIdentifierType);

但是对于数字 SKU,我会收到产品不存在"错误.
大概这是因为 Magento 无法判断您传递的是 product_id 还是 SKU.根据我能找到的所有文档,将 productIdentifierType 设置为 'sku' 理论上应该可以解决这个问题:

But with numeric SKUs I get 'Product not exists' errors.
Presumably this is because Magento cannot tell whether you are passing it a product_id or an SKU. Setting the productIdentifierType to 'sku' should fix that, in theory, according to all the documentation I can find:

...
string productIdentifierType = "sku";
...

但它没有修复它.
事实上,情况似乎更糟,然后 Magento 停止查找非数字 SKUS.
所以大概 "sku" 不是要传递的正确值.

But it doesn't fix it.
In fact it seems to make it worse, Magento then stops finding non-numeric SKUS.
So presumably "sku" is not the right value to pass.

有人有什么想法吗?

推荐答案

简短的回答是某个地方存在一个错误,导致 product.update 的最后一个参数无法正确设置(或者可能是 Varien 没有)t 尚未实现它),这也为方法 product.info 带来了问题.

Short answer is that there's a bug somewhere preventing the last param of product.update from being set properly (or maybe Varien haven't yet implemented it), which also presents a problem for the method product.info.

一个快速的解决方法(如果您不介意失去通过 ID 更新的选项)只是在产品 API update() 方法中设置 $identifierType):

A quick workaround (if you don't mind losing the option to update by ID) is just to set the $identifierType in the Product API update() method ):

app/code/core/Mage/Catalog/Model/Product/Api.php l.198

public function update($productId, $productData, $store = null, $identifierType = 'sku')

最后在app/code/core/Mage/Catalog/Helper/Product.php的l.427左右的getProduct()方法的if($idBySku)条件下加载产品

And finally load the product within the if ($idBySku) condition of the method getProduct() around l.427 of app/code/core/Mage/Catalog/Helper/Product.php

$productId = $idBySku;
$product->load($productId);

这有点软糖.我会寻找更好的解决方法作为替代;否则,也许其他人可以发布更好的解决方案.

It's a bit of a fudge. I'll have a look for a better workaround as an override; otherwise, maybe someone else can post a better solution.

这篇关于Magento 1.5,数字 SKU 和 productIdentifierType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆