Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cms pages datagrid not diplay any rows when Change locale #6703

Closed
ghena opened this issue Sep 9, 2022 · 5 comments
Closed

Cms pages datagrid not diplay any rows when Change locale #6703

ghena opened this issue Sep 9, 2022 · 5 comments
Labels
Bug Fixed When bug issue is fixed. Bug Something isn't working.
Milestone

Comments

@ghena
Copy link

ghena commented Sep 9, 2022

Changing env
APP_LOCALE=it
then clear cache configuration

then added a new translations for specific page: php artisan optimize:clear

The datagrid not diplay any rows
image

this is my db for cms_page_translations
image

this is the results of datagrid query
image

Please could you check ?
Regards.
g.

@Sanjaybhattwebkul Sanjaybhattwebkul self-assigned this Sep 10, 2022
@Sanjaybhattwebkul Sanjaybhattwebkul added the Help Wanted Extra attention is needed. label Sep 10, 2022
@Sanjaybhattwebkul
Copy link
Contributor

Hi there,
I guess you don't add the pages for the IT locale, please take a reference from Here. and the issue will be resolved.

@ghena
Copy link
Author

ghena commented Sep 12, 2022

I did a small video.

https://drive.google.com/file/d/1ZjT9fLxSK1AWOjuAiwMhPL0QT6Rb3Zfv/view

The problem is not solved.
.g

@ghena
Copy link
Author

ghena commented Sep 27, 2022

I investigate further and:

Request URL: http://127.0.0.1:8000/admin/cms?v=1&page=1
Request Method: GET
Status Code: 500 Internal Server Error
Remote Address: 127.0.0.1:8000
Referrer Policy: no-referrer-when-downgrade
Missing required parameter for [Route: shop.cms.page] [URI: page/{slug}] [Missing parameter: slug].

editing \packages\Webkul\Admin\src\DataGrids\CMSPageDataGrid.php

public function prepareActions()
{

    // $this->addAction([ 
    //     'title'  => trans('admin::app.datagrid.view'),
    //     'method' => 'GET',
    //     'route'  => 'shop.cms.page',
    //     'index'  => 'url_key',
    //     'target' => '_blank',
    //     'icon'   => 'icon eye-icon',
    // ]);

it works.
the problem seem that translation url-key not exists.
if not exists action url generator goes on error.

But is possible that a user not fill all data with a new locale.
So when change the locale it goes on error.

Please fix.

@HermesZum
Copy link

HermesZum commented Feb 23, 2023

It's not an optimal solution, because all translated pages appear in the list, but at least they appear when you use a local language in the Admin other than EN.

Try this:

packages/Webkul/Admin/src/DataGrids/CMSPageDataGrid.php

public function prepareQueryBuilder()
    {
        $queryBuilder = DB::table('cms_pages')
            ->select('cms_pages.id', 'cms_page_translations.page_title', 'cms_page_translations.url_key')
            ->leftJoin('cms_page_translations', function($leftJoin) {
                $leftJoin->on('cms_pages.id', '=', 'cms_page_translations.cms_page_id')
                         ->where('cms_page_translations.cms_page_id', app()->getLocale());
            });

        $this->addFilter('id', 'cms_pages.id');

        $this->setQueryBuilder($queryBuilder);
    }

remove the line:

->where('cms_page_translations.cms_page_id', app()->getLocale())

Will be like this:

public function prepareQueryBuilder()
    {
        $queryBuilder = DB::table('cms_pages')
            ->select('cms_pages.id', 'cms_page_translations.page_title', 'cms_page_translations.url_key')
            ->leftJoin('cms_page_translations', function($leftJoin) {
                $leftJoin->on('cms_pages.id', '=', 'cms_page_translations.cms_page_id');
            });

        $this->addFilter('id', 'cms_pages.id');

        $this->setQueryBuilder($queryBuilder);
    }

@devansh-webkul devansh-webkul added Bug Something isn't working. and removed Help Wanted Extra attention is needed. labels Apr 12, 2023
@devansh-webkul
Copy link
Member

This is a bug and I have added a PR for that. With that PR now you can able to filter the locale from the data grid itself.

@devansh-webkul devansh-webkul added the Fix Proposed A issue that has a PR related to it that provides a possible resolution but stil needs to be merged. label Apr 12, 2023
jitendra-webkul added a commit that referenced this issue Apr 13, 2023
@devansh-webkul devansh-webkul added Bug Fixed When bug issue is fixed. and removed Fix Proposed A issue that has a PR related to it that provides a possible resolution but stil needs to be merged. labels Apr 13, 2023
@shivendra-webkul shivendra-webkul added this to the 1.5.0 milestone Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fixed When bug issue is fixed. Bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

5 participants