/**
  * Generate RSS feed for all categories.
  *
  * @param ZenMagick\Http\Request request The current request.
  * @param boolean full Indicates whether to generate a full feed or not; default is <code>false</code>.
  * @return RssFeed The feed.
  */
 protected function getCategoriesFeed($request, $full)
 {
     $settingsService = $this->container->get('settingsService');
     $translator = $this->container->get('translator');
     $router = $this->container->get('router');
     $channel = new RssChannel();
     $channel->setTitle($translator->trans('Categories at %store_name%', array('%store_name%' => $settingsService->get('storeName'))));
     $channel->setLink($router->generate('index', array(), true));
     $channel->setDescription($translator->trans('All categories at %store_name%', array('%store_name%' => $settingsService->get('storeName'))));
     $channel->setLastBuildDate($lastPubDate);
     $feed = new RssFeed();
     $feed->setChannel($channel);
     // set up item iterator
     $languageId = $request->getSession()->getLanguageId();
     $categoryService = $this->container->get('categoryService');
     //TODO: $categoryService->setCache(null);
     $categoryInfo = array();
     foreach ($categoryService->getAllCategories($languageId) as $category) {
         if ($category->isActive()) {
             $categoryInfo[] = array('id' => $category->getId(), 'url' => $router->generate('category', array('cPath' => implode('_', $category->getPath()))));
         }
     }
     $itemIterator = new CatalogCategoryRssItemIterator($categoryInfo, $languageId, $this->fullFeed);
     $itemIterator->setContainer($this->container);
     $feed->setItems($itemIterator);
     return $feed;
 }
 /**
  * Generate RSS feed for products.
  *
  * @param ZenMagick\Http\Request request The current request.
  * @param string key Optional key value for various product types; supported: 'new'
  * @return RssFeed The feed data.
  */
 protected function getProductsFeed($request, $key = null)
 {
     if ('new' != $key) {
         return null;
     }
     $toolbox = $this->container->get('toolbox');
     $translator = $this->container->get('translator');
     $lastPubDate = null;
     $items = array();
     $products = array_slice(array_reverse($this->container->get('productService')->getNewProducts()), 0, 20);
     foreach ($products as $product) {
         $item = new RssItem();
         $item->setTitle($product->getName());
         $url = $router->generate('product_info', array('productId' => $productId), true);
         $item->setLink($url);
         $item->setDescription($toolbox->html->more($toolbox->html->strip($product->getDescription()), 60));
         $item->setPubDate($product->getDateAdded());
         $items[] = $item;
         if (null === $lastPubDate) {
             $lastPubDate = $product->getDateAdded();
         }
     }
     $settingsService = $this->container->get('settingsService');
     $router = $this->container->get('router');
     $channel = new RssChannel();
     $channel->setTitle($translator->trans('New Products at %store_name%', array('%store_name%' => $settingsService->get('storeName'))));
     $channel->setLink($router->generate('index', array(), true));
     $channel->setDescription($translator->trans("The latest updates to %store_name%'s product list", array('%store_name%' => $settingsService->get('storeName'))));
     $channel->setLastBuildDate($lastPubDate);
     $feed = new RssFeed();
     $feed->setChannel($channel);
     $feed->setItems(new \ArrayIterator($items));
     return $feed;
 }