使用Google生成产品图片¶
拥有产品图片对于很多原因都很有用。但是,如果要为很多产品分配图片,这会非常耗时。
幸运的时,通过在Odoo数据库中配置 谷歌自定义搜索 API,基于产品条码的图片搜索是非常高效的。
配置¶
在Odoo数据库中使用 谷歌自定义搜索 是非常高效的。
Note
谷歌账户允许用户每天选择100张免费图片。如果需要更高数量的图片,需要升级计费。
谷歌API仪表板¶
要使用谷歌自定义搜索API,必须首先生成谷歌自定义搜索API凭证。然后,使用谷歌账户登录。
从这里,选择(或创建)一个API项目来保存凭证。首先,为项目起一个 memorable
从左侧栏中选择凭证选项,然后点击 Create Credentials,并选择 API密钥从下拉菜单中。
复制并保存 你的API key。稍后,将使用此密钥。当密钥已复制并保存时,请点击 Close ,以删除弹出窗口。
在此页面中,搜索 ` Custom Search API`,并选择它。
从 “Custom Search API” 页,点击 启用 ,以启用该API。
谷歌可编程搜索仪表板¶
要使用 谷歌可编程搜索 ,必须首先生成谷歌可编程搜索API凭证。然后,使用谷歌账户登录。
On the Create a new search engine form, fill out the name of the search engine, along with what the engine should search, and be sure to enable Image Search and SafeSearch.
Validate the form by clicking Create.
Doing so reveals a new page with the heading: Your new search engine has been created.
From this page, click Customize to open the page. Then, copy the ID in the Search engine ID field. This ID is needed for the Odoo configuration.
Odoo¶
In the Odoo database, go to the and scroll to the Integrations section. From here, check the box beside Google Images. Then, click Save.
Next, return to the , and scroll to the Integrations section. Then, enter the API Key and Search Engine ID in the fields beneath the Google Images feature.
点击 保存 。
Product images in Odoo with Google Custom Search API¶
Adding images to products in Odoo can be done on any product or product variant. This process can be completed in any Odoo application that provides access to product pages (e.g. Sales app, Inventory app, etc.).
Below is a step-by-step guide detailing how to utilize the Google Custom Search API to assign images to products in Odoo using the Odoo Sales application:
Navigate to the Products page in the Sales app (). Or, navigate to the Product Variants page in the Sales app ().
Select the desired product that needs an image.
Note
Only products (or product variants) that have a barcode, but not an image, are processed.
If a product with one or more variants is selected, each variant that matches the aforementioned criteria is processed.
Click the Action ⚙️ (gear) icon on the product page, and select Get Pictures from Google Images from the menu that pops up.
On the pop-up window that appears, click Get Pictures.
Once clicked, the image(s) will appear incrementally.
Note
Only the first 10 images are fetched immediately. If you selected more than 10, the rest are fetched as a background job.
The background job processes about 100 images in a minute. If the quota authorized by Google (either with a free or a paid plan) is reached, the background job puts itself on hold for 24 hours. Then, it will continue where it stopped the day before.