0
use Magento\Framework\App\ObjectManager;
use Magento\Framework\DataObject;
class Sitemap extends \Magento\Sitemap\Model\Sitemap
{
   
    public function getCustomurlCollection()
    {
        $siteMapcollection = array();
        /* if want to add multiple url then load your custom collection and set  */

           /*foreach ($siteMapcollection as $custom) { */
        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface');
        $baseurl = $storeManager->getStore()->getBaseUrl();

                    $siteMapcollection[] = new DataObject([
                        'id'         => "test",
                        // 'url'        => $baseurl,
                        'updated_at' => date("Y-m-d h:i:s"),
                    ]);
             /*     } */
            return $siteMapcollection;

    }
    public function _initSitemapItems()
    {
        parent::_initSitemapItems(); 

        array_unshift($this->_sitemapItems,$this->_sitemapItems[] = new DataObject([
            'changefreq' => 'daily',
            'priority' => '0.1',
            'collection' => $this->getCustomurlCollection(),
        ]));
        



       
    }


}

1 Answer 1

0

replace 'changefreq' => 'daily' with 'change_frequency' => 'daily'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.