通过SOAP调用获取图像缩略图

发布于 2024-11-14 18:25:14 字数 834 浏览 4 评论 0原文

我正在尝试使用 Magento 的 Web 服务 API 通过第三方应用程序在我的商店中显示产品。当我使用“catalog_product_attribute_media.list”查询某个项目的图像数据时,我得到如下信息:

Array
(
    [0] => Array
        (
            [file] => /a/k/akio-dresser.jpg
            [label] => 
            [position] => 1
            [exclude] => 1
            [url] => http://example.com/magento/media/catalog/product/a/k/akio-dresser.jpg
            [types] => Array
                (
                    [0] => thumbnail
                    [1] => small_image
                    [2] => image
                )

        )

)

这告诉我,我应该能够获取该图像的“thumbnail”或“small_image”版本,但我无法弄清楚知道如何实际做到这一点。我查看了文档并尝试了我能找到的所有方法,但没有成功。还有其他人知道我可以使用什么 SOAP 调用吗?调用catalog_product_attribute_media.info似乎返回完全相同的信息,而catalog_product_attribute_media.types似乎根本不返回任何内容。

I’m trying to display products in my store through a third party application using Magento’s web services API. When I query image data for an item using “catalog_product_attribute_media.list”, I get something like this:

Array
(
    [0] => Array
        (
            [file] => /a/k/akio-dresser.jpg
            [label] => 
            [position] => 1
            [exclude] => 1
            [url] => http://example.com/magento/media/catalog/product/a/k/akio-dresser.jpg
            [types] => Array
                (
                    [0] => thumbnail
                    [1] => small_image
                    [2] => image
                )

        )

)

This tells me that I should be able to get the “thumbnail” or “small_image” version of this image, but I can’t figure out how to actually do it. I’ve looked through the documentation and tried everything I could find but have had no success. Does anybody else know what SOAP call I could use? The call catalog_product_attribute_media.info seems to return exactly the same information, and catalog_product_attribute_media.types doesn’t seem to return anything at all.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

装纯掩盖桑 2024-11-21 18:25:14

API调用结果是指产品图像的原始文件,而不是在运行时(即加载产品页面时)生成的缓存缩略图/小图像。

返回的属性与您在产品管理页面中获得的布局相对应。因此,给定的图像可用于产品页面上的主产品图像、类别列表中使用的小图像或添加到购物篮时使用的缩略图。

Magento 会动态缩放这些图像,与某些旧式推车相比,这是一种更好的安排,在旧式推车中,您必须准备好“正确”尺寸的图像。然而,这意味着磁盘上只有缩略图的缓存副本,没有 API 调用来访问它。

我遇到了类似的问题,想要在 Magento 之外获取产品图片。我的解决方法是使用 cron 脚本拉取过去 24 小时内更改的大型原始图像,然后使用 imagemagick 创建缩略图,然后使用图像的新“本地”副本。
这不是解决方法,我实际上想对缩略图进行一些命令行处理,以删除多余的空白,锐化边缘并为颜色添加一些额外的活力。这种图像处理并不实时,而且我也不想要默认的“模糊”缩略图。仅对新鲜图像进行一整夜的计划工作就完成了我的工作。

The API call result refers to the original file(s) for the product image(s), not the cached thumbnails/small images that are generated at runtime, i.e. when the product page is loaded.

The returned attributes correspond to the layout that you get in the admin page for the product. So a given image can be used for the main product image on the product page, the small image used in the category listings or the thumbnail used for when added to basket.

Magento scales these images on the fly, this is a much better arrangement that what you get with some older carts where you have to get images prepared to 'correct' sizes. However, that means that there is nothing but a cached copy of the thumbnail on disk with no API call to access it.

I faced a similar problem of wanting the product images outside of Magento. My workaround was to use a cron script to pull down the big original images that had changed in the last 24 hours, to then create the thumbnails with imagemagick and then use the new 'local' copy of the image.
This was no workaround, I actually wanted to do some command line processing to the thumbnails, to remove excess whitespace, sharpen the edges and add some extra vibrancy to the colours. This image processing was not realistic in real time and I did not want the default 'blurry' thumbnails anyway. An overnight cron-job on just the fresh images did the job for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文