S
S
Sergey Bard2018-03-21 14:21:31
Yii
Sergey Bard, 2018-03-21 14:21:31

How to enable the sitemap module?

Hello. I want to install this extension , I installed it via composer, I connected it to console\config\main in components

'components' => [
        'log' => [
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
    'sitemap' =>[
            'class' => '\zhelyabuzhsky\sitemap\components\Sitemap',
            'maxUrlsCountInFile' => 10000,
            'sitemapDirectory' => 'frontend/web',
            'optionalAttributes' => ['changefreq', 'lastmod', 'priority'],
            'maxFileSize' => '10M',
    ],
    ],

further in console\controllers I created SitemapController.php and added it with this content
namespace console\controllers;

use yii\console\Controller;

class SitemapController extends Controller
{
    public function actionCreateSitemap()
  {
    \Yii::$app->sitemap
    ->addModel(\common\models\product\Product::className())
    ->create();
  }
}

what should I do next ?, when I write in the console ./yii, then there is nothing similar,
p3IlIj.jpg
please tell me what I did wrong or didn’t finish it?)
Ps yii I’m just studying, because of this I ask such stupid questions)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2018-03-21
@serg_small_developer

well, probably call the controller action that you created
./yii sitemap/create-sitemap

E
enchikiben, 2019-02-21
@EnChikiben

it's easier)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question