Overview

Namespaces

  • Inteve
    • FeedGenerator
      • Feeds
        • GoogleMerchant
        • Heureka
        • PostFeed
        • Zbozi
      • Outputs
      • Responses
      • Utils

Classes

  • Inteve\FeedGenerator\Feed
  • Inteve\FeedGenerator\Feeds\GoogleMerchant\GoogleMerchantFeed
  • Inteve\FeedGenerator\Feeds\GoogleMerchant\GoogleMerchantItem
  • Inteve\FeedGenerator\Feeds\Heureka\HeurekaFeed
  • Inteve\FeedGenerator\Feeds\Heureka\HeurekaItem
  • Inteve\FeedGenerator\Feeds\Heureka\HeurekaItemParameter
  • Inteve\FeedGenerator\Feeds\PostFeed\PostFeed
  • Inteve\FeedGenerator\Feeds\PostFeed\PostFeedItem
  • Inteve\FeedGenerator\Feeds\Zbozi\ZboziFeed
  • Inteve\FeedGenerator\Feeds\Zbozi\ZboziItem
  • Inteve\FeedGenerator\Feeds\Zbozi\ZboziItemParameter
  • Inteve\FeedGenerator\Outputs\DirectOutput
  • Inteve\FeedGenerator\Outputs\FileOutput
  • Inteve\FeedGenerator\Outputs\MemoryOutput
  • Inteve\FeedGenerator\Responses\NetteDownloadResponse
  • Inteve\FeedGenerator\Utils\Helpers

Interfaces

  • Inteve\FeedGenerator\IFeed
  • Inteve\FeedGenerator\IFeedItem
  • Inteve\FeedGenerator\IOutput

Exceptions

  • Inteve\FeedGenerator\AssertException
  • Inteve\FeedGenerator\FeedGeneratorException
  • Inteve\FeedGenerator\FileSystemException
  • Inteve\FeedGenerator\InvalidArgumentException
  • Inteve\FeedGenerator\InvalidItemException
  • Inteve\FeedGenerator\OutputException
  • Inteve\FeedGenerator\StaticClassException
  • Overview
  • Namespace
  • Class
 1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 
<?php

    namespace Inteve\FeedGenerator\Feeds\Zbozi;

    use Inteve\FeedGenerator\Feed;
    use Inteve\FeedGenerator\InvalidItemException;
    use Inteve\FeedGenerator\IOutput;
    use Inteve\FeedGenerator\Utils\Helpers;


    class ZboziFeed extends Feed
    {
        /**
         * @return string
         */
        public function getContentType()
        {
            return 'text/xml';
        }


        /**
         * @return void
         * @throws InvalidItemException
         */
        public function generate(IOutput $output)
        {
            // https://napoveda.seznam.cz/cz/zbozi/specifikace-xml-pro-obchody/specifikace-xml-feedu/
            $output->open();
            $output->output('<?xml version="1.0" encoding="utf-8"?>');
            $output->output("\n");
            $output->output('<SHOP xmlns="http://www.zbozi.cz/ns/offer/1.0">');
            $output->output("\n");

            foreach ($this->items as $item) {
                if (!($item instanceof ZboziItem)) {
                    throw new InvalidItemException('Feed item must be instance of ZboziItem.');
                }

                $item->validate();

                $output->output("<SHOPITEM>\n");

                Helpers::writeXml($output, array(
                    'ITEM_ID' => $item->getId(),
                    'PRODUCTNAME' => $item->getProductName(),
                    'DESCRIPTION' => $item->getDescription(),
                    'URL' => $item->getUrl(),
                    'IMGURL' => $item->getImageUrl(),

                    // price & availability
                    'PRICE_VAT' => $item->getPrice(),
                    'DELIVERY_DATE' => $item->getDeliveryDate(),

                    // group ID
                    'ITEMGROUP_ID' => $item->getGroupId(),
                ));

                foreach ($item->getParameters() as $parameter) {
                    Helpers::writeXml($output, array(
                        'PARAM' => array(
                            'content' => array(
                                'PARAM_NAME' => $parameter->getName(),
                                'VAL' => $parameter->getValue(),
                                'UNIT' => $parameter->getUnit(),
                            ),
                        ),
                    ));
                }

                $output->output("</SHOPITEM>\n");
            }

            $output->output('</SHOP>');
            $output->output("\n");
            $output->close();
        }
    }
inteve/feed-generator v1.2.0 API documentation API documentation generated by ApiGen