gpt4 book ai didi

Magento SOAP API 产品列表分页

转载 作者:行者123 更新时间:2023-12-02 21:32:52 24 4
gpt4 key购买 nike

我正在尝试通过 SOAP API (V2) 读取 Magento 的产品列表,并尝试执行某些/任何类型的分页。

简单场景:

var filters = new filters();
var products = catalogProductList(out pe, Connection.Session, filters, null);

这会导致 Magento 崩溃:“允许的内存大小 1073741824 字节已耗尽(尝试分配 72 字节。”

我尝试通过在 product_id 上指定两个复杂的过滤器来添加分页:

filters.complex_filter = new complexFilter[]
{
new complexFilter()
{
key = "product_id",
value = new associativeEntity()
{
key = "gt",
value = "400"
}
},
new complexFilter()
{
key = "product_id",
value = new associativeEntity()
{
key = "lt",
value = "1000"
}
}
};

但是,在这种情况下,仅应用第二个过滤器,第一个过滤器将被忽略。

我正在考虑阅读类别树,然后阅读分配的产品,但有很多产品未分配给任何类别或多个类别,因此我要么会错过它们,要么会多次获得它们。

有没有办法使用某种类型的分页来读取产品列表,这样我就不会立即读取完整的列表?(注意:请求增加内存并不是真正的选择)

最佳答案

我已经为此想出了一个非常好的解决方案。希望这对某人有帮助。

$in = array();
for ($i = ($page * $size) - $size; $i < ($page * $size); $i++) {
$in[] = $i + 1;
}
$complexFilter = array('complex_filter' =>
array(
array(
'key' => 'product_id',
'value' => array(
'key' => 'in',
'value' => join(",", $in)
)
)
)
);

关于Magento SOAP API 产品列表分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9935191/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com