我正在使用Magento以下脚本将我们的目录导入Google购物:
<?php
define('SAVE_FEED_LOCATION','google_base_feed.txt');
set_time_limit(1800);
require_once '../app/Mage.php';
Mage::app('default');
try{
$handle = fopen(SAVE_FEED_LOCATION, 'w');
$heading = array('id','mpn', 'upc','title','description','link','image_link','price','brand','product_type','condition', 'google_product_category', 'manufacturer', 'availability');
$feed_line=implode("\t", $heading)."\r\n";
fwrite($handle, $feed_line);
$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToFilter('status', 1);
$products->addAttributeToFilter('visibility', 4);
$products->addAttributeToSelect('*');
$prodIds=$products->getAllIds();
$product = Mage::getModel('catalog/product');
$counter_test = 0;
foreach($prodIds as $productId) {
if (++$counter_test < 30000){
$product->load($productId);
$product_data = array();
$product_data['sku'] = $product->getSku();
$product_data['mpn'] = $product->getData('upc');
$product_data['upc'] = $product->getData('upc');
$title_temp = $product->getName();
if (strlen($title_temp) > 70){
$title_temp = str_replace("Supply", "", $title_temp);
$title_temp = str_replace(" ", " ", $title_temp);
}
$product_data['title'] …Run Code Online (Sandbox Code Playgroud) 我目前正在为电子商务网站构建 Schema.org 模板,目的是生成 Google 购物提要。
我正在努力理解定义销售价格的正确方法 - 即临时降价的产品。
我考虑过的选项是L
具有多个“PriceSpecification”项目的单个“Offer”
"offers": {
"@type": "Offer",
"url": "https://kx.com/url",
"itemCondition": "http://schema.org/UsedCondition",
"availability": "http://schema.org/InStock",
"PriceSpecification": [
{
"@type": "PriceSpecification",
"price": 15.00,
"priceCurrency": "USD"
},
{
"@type": "PriceSpecification",
"price": 15.00,
"priceCurrency": "USD",
"validFrom": "2020-01-01",
"validThrough": "2020-02-01",
}
],
},
Run Code Online (Sandbox Code Playgroud)
具有单个“价格规范”的多个“优惠”项目
"offers": [
{
"@type": "Offer",
"url": "https://kx.com/url",
"itemCondition": "http://schema.org/UsedCondition",
"availability": "http://schema.org/InStock",
"PriceSpecification": [
{
"@type": "PriceSpecification",
"price": 15.00,
"priceCurrency": "USD"
}
],
},
{
"@type": "Offer",
"url": "https://kx.com/url",
"itemCondition": "http://schema.org/UsedCondition",
"availability": "http://schema.org/InStock", …Run Code Online (Sandbox Code Playgroud)