PHP code example of mysutka / product_feed_generator

1. Go to this page and download the library: Download mysutka/product_feed_generator 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/ */

    

mysutka / product_feed_generator example snippets


$generator = new \ProductFeedGenerator\Generator\GoogleShoppingGenerator();
$generator->exportTo("/path/to/public/web/directory/product_feeds/google_shopping.xml")

$generator = new \ProductFeedGenerator\Generator\HeurekaCzGenerator(null, [
  "fixed_values" => [
    "DELIVERY_DATE" => 25,
]);

$generator = new \ProductFeedGenerator\Generator\HeurekaCzGenerator(null, [
  "fixed_values" => [
    "EAN" => null,
]);

$eur_price_finder = PriceFinder::GetInstance(null, Currency::FindByCode("EUR"));
$generator = new \ProductFeedGenerator\Generator\HeurekaCzGenerator(null, [
  "price_finder" => $eur_price_finder,
]);

class LimitedEshopReader extends ProductFeedGenerator\Reader\Atk14EshopReader {

  function getObjectIds($options=[]) {
    $options += [ 
      "offset" => 0,
    ];
    $ids = $this->dbmole->selectIntoArray("SELECT distinct(id) FROM cards
      WHERE
        created_at>now() - interval '1 month' AND
        NOT deleted AND
        visible
      ORDER BY id
      LIMIT 100 OFFSET :offset", array(
        ":offset" => $options["offset"],
      ));
    return $ids;
  }
}

class OtherLimitedEshopReader extends ProductFeedGenerator\Reader\Atk14EshopReader {
  
  function itemToArray($product) {
      if (!$product->canBeOrdered()) {
          return null;
      }
  }
}

class CustomGoogleShoppingGenerator extends ProductFeedGenerator\Generator\GoogleShoppingGenerator {
  function getAttributesMap() {
    return parent::getAttributesMap() + [
      "g:availability" => "STOCKCOUNT",
    ];
  }

  function afterFilter($values) {
    $values["g:availability"] = ($values["g:availability"]) > 0 ? "in stock" : "out of stock";
    return $values;
  }
}