![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/app/code/Magefan/Blog/Model/Sitemap/ItemProvider/ |
<?php /** * Copyright © Magefan ([email protected]). All rights reserved. * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ namespace Magefan\Blog\Model\Sitemap\ItemProvider; use Magento\Sitemap\Model\SitemapItemInterfaceFactory; use Magento\Sitemap\Model\ItemProvider\ItemProviderInterface; use Magefan\Blog\Model\ResourceModel\Category\CollectionFactory; use Magefan\Blog\Api\SitemapConfigInterface; class Category implements ItemProviderInterface { /** * Sitemap config * * @var SitemapConfigInterface */ private $sitemapConfig; /** * Blog category collection factory * * @var CollectionFactory */ private $collectionFactory; /** * Sitemap item factory * * @var SitemapItemInterfaceFactory */ private $itemFactory; /** * @param SitemapConfigInterface $sitemapConfig * @param CollectionFactory $collectionFactory * @param SitemapItemInterfaceFactory $itemFactory */ public function __construct( SitemapConfigInterface $sitemapConfig, CollectionFactory $collectionFactory, SitemapItemInterfaceFactory $itemFactory ) { $this->sitemapConfig = $sitemapConfig; $this->collectionFactory = $collectionFactory; $this->itemFactory = $itemFactory; } /** * {@inheritdoc} */ public function getItems($storeId) { if (!$this->sitemapConfig->isEnabledSitemap(SitemapConfigInterface::CATEGORIES_PAGE, $storeId)) { return []; } $collection = $this->collectionFactory->create() ->addStoreFilter($storeId) ->addActiveFilter() ->getItems(); $items = array_map(function ($item) use ($storeId) { return $this->itemFactory->create([ 'url' => $item->getUrl(), 'updatedAt' => $item->getUpdatedAt(), 'priority' => $this->sitemapConfig->getPriority(SitemapConfigInterface::CATEGORIES_PAGE, $storeId), 'changeFrequency' => $this->sitemapConfig->getFrequency(SitemapConfigInterface::CATEGORIES_PAGE, $storeId), ]); }, $collection); return $items; } }