softwarepunt/pinterest-xml-catalog
Composer 安装命令:
composer require softwarepunt/pinterest-xml-catalog
包简介
PHP Library for generating Pinterest Catalogs in XML (RSS 2.0) format
README 文档
README
Unofficial PHP Library for generating Pinterest Catalogs in XML (RSS 2.0, ATOM 1.0) format
This can be used to generate a data source for daily product ingestion by Pinterest. You must already have a business account and a claimed website that meets their merchant guidelines.
You can use this to help convert product data to XML, but you'll have to serve the output yourself.
Installation
Add the library to your project via Composer:
composer require softwarepunt/pinterest-xml-catalog
Requirements
- PHP 7.4+
ext-dom
Usage
Creating an XML catalog
Collect your product data, and then feed it into a XmlCatalog instance.
<?php use SoftwarePunt\PinterestXmlCatalog\XmlCatalog; use SoftwarePunt\PinterestXmlCatalog\Models\ProductData; // Create a new, blank catalog $xmlCatalog = new XmlCatalog(); // Gather product data $product = new ProductData(); $product->id = "4000086"; $product->title = "Illuminating Makeup Mirror"; $product->description = "A ring light mirror with 23 LED strip lights."; $product->link = "https://www.example.com/cat/illuminating-makeup-mirror"; $product->imageLink = "https://www.example.com/media/catalog/product/image.jpg"; $product->additionalImageLink = "https://www.example.com/media/catalog/product/image_side.jpg"; $product->price = "14,99 EUR"; // Add products to catalog (can be ProductData, other object, or data array) $xmlCatalog->addProduct($product); // Convert to XML and serve as response echo $xmlCatalog->toXmlString();
Product data
Pinterest uses the Google Merchant Data specifications for RSS 2.0, which you can refer to for documentation on the specific fields used.
👉 This library currently only targets fields that are in the Pinterest sample or docs, not the full Google-supported set of fields.
Using the ProductData class is recommended because it contains relevant phpdocs to make your life easier. You can also
pass your own associative array or object for each product to addProduct() if you prefer.
If you are adding products from your own object or array, you should make sure that the property names / array keys can
be understood by the library. For example, if you want to set the Google Product Category, valid keys to set it
are googleProductCategory, g:google_product_category and google_product_category.
Required fields
When filling products, the following fields are always required:
| Field name | XML Element | Description |
|---|---|---|
id |
g:id |
Product ID. Always required. Example: "DS0294-L". |
title |
title |
Product name. Always required. Example: "Women’s denim shirt, large". |
description |
description |
Product description. Always required. Example: "Casual fit denim shirt made with the finest quality Japanese denim.". |
link |
link |
Product URL. Always required. Example: "https://www.example.com/cat/womens-clothing/denim-shirt-0294". |
imageLink |
g:image_link |
Primary image URL. Always required. Example: "https://scene.example.com/image/image.jpg". |
availability |
g:availability |
Product availability. Always required. Must be "in stock" (default), "out of stock" or "preorder". |
price |
g:price |
ISO 4217 price specification. Always required. |
Optional fields
These fields are optional and can be used to enrich the product with additional information.
| Field name | XML Element | Description |
|---|---|---|
additionalImageLink |
g:additional_image_link |
Comma-separated list of additional images for your product. A new pin will be created for each additional image link. |
mobileLink |
g:mobile_link |
The mobile-optimized version of your landing page. |
salePrice |
sale_price |
The discounted price of the product. Must be lower than the regular price. |
productType |
g:product_type |
The categorization of your product based on your custom product taxonomy. Up to five subcategories must be sent separated by >. The > must be wrapped by spaces. |
brand |
brand |
The brand of the product. |
condition |
g:condition |
The condition of the product. |
googleProductCategory |
g:google_product_category |
The categorization of the product based on the standardized Google Product Taxonomy. |
softwarepunt/pinterest-xml-catalog 适用场景与选型建议
softwarepunt/pinterest-xml-catalog 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 03 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 softwarepunt/pinterest-xml-catalog 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 softwarepunt/pinterest-xml-catalog 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-31