Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function generate()
 {
     $products = $this->productRepository->findAll();
     foreach ($products as $product) {
         $productUrl = $this->sitemapUrlFactory->createNew();
         $localization = $this->router->generate('sylius_shop_product_show', ['slug' => $product->getSlug()], true);
         $productUrl->setLastModification($product->getUpdatedAt());
         $productUrl->setLocalization($localization);
         $productUrl->setChangeFrequency(ChangeFrequency::always());
         $productUrl->setPriority(0.5);
         $this->urls[] = $productUrl;
     }
     return $this->urls;
 }
Пример #2
0
 function it_generates_urls($repository, $router, $sitemapUrlFactory, Collection $products, \Iterator $iterator, ProductInterface $product, SitemapUrlInterface $sitemapUrl, \DateTime $now)
 {
     $repository->findAll()->willReturn($products);
     $products->getIterator()->willReturn($iterator);
     $iterator->valid()->willReturn(true, false);
     $iterator->next()->shouldBeCalled();
     $iterator->rewind()->shouldBeCalled();
     $iterator->current()->willReturn($product);
     $product->getUpdatedAt()->willReturn($now);
     $router->generate($product, [], true)->willReturn('http://sylius.org/t-shirt');
     $sitemapUrlFactory->createNew()->willReturn($sitemapUrl);
     $sitemapUrl->setLocalization('http://sylius.org/t-shirt')->shouldBeCalled();
     $sitemapUrl->setLastModification($now)->shouldBeCalled();
     $sitemapUrl->setChangeFrequency(ChangeFrequency::always())->shouldBeCalled();
     $sitemapUrl->setPriority(0.5)->shouldBeCalled();
     $this->generate();
 }
Пример #3
0
 function it_has_change_frequency()
 {
     $this->setChangeFrequency(ChangeFrequency::always());
     $this->getChangeFrequency()->shouldReturn('always');
 }