PHP code example of sylapi / feed-compari
1. Go to this page and download the library: Download sylapi/feed-compari library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sylapi / feed-compari example snippets
ylapi\Feeds\FeedGenerator;
use Sylapi\Feeds\Compari\Feed;
use Sylapi\Feeds\Parameters;
use Sylapi\Feeds\Models\Product;
// Create feed generator
$feedGenerator = new FeedGenerator();
$feedGenerator->setFeed(new Feed(
Parameters::create([
'title' => 'My Store Products',
'description' => 'Product feed for Compari comparison shopping',
'link' => 'https://mystore.example.com/',
])
));
// Create and add products
$product = new Product();
$product->setName('Example Product')
->setPrice(99.99)
->setCurrency('PLN')
->setAvailability('in stock')
->setDescription('Product description...')
->setUrl('https://mystore.example.com/product/123')
->setImageUrl('https://mystore.example.com/images/product123.jpg');
$feedGenerator->appendProduct($product);
// Add more products...
// $feedGenerator->appendProduct($anotherProduct);
// Generate and save the feed
$feedGenerator->save();
echo "Feed saved to: " . $feedGenerator->filePath();