-
Notifications
You must be signed in to change notification settings - Fork 3
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
Много запросов в гриде #7
Comments
проблема в коде привязки поведения (метод behaviors() вашей модели) |
Код, как в доке public function behaviors()
{
return [
/** ... **/
'eav' => [
'class' => Entity::class,
'entity' => function () {
return new EntityModel([
'sets' => [
Set::findOne(['code' => 'product']), //product -- set from db
],
]);
},
],
];
} У вас должно быть тоже самое. Посмотрите в дебаг панель в гриде, где есть привязка EAV модуля. Вот про эту анонимку я имел ввиду в предыдущем issue |
В документации код для примера, нужно понимать, что метод behaviors вызывается для каждого екземпляра модели. Сделайте вместо: Set::findOne(['code' => 'product']), \nullref\useful\helpers\Memoize::call([Set::class, 'findOne'],[['code' => 'product']]), |
А так пропадают eav аттрибуты в гриде. |
в каком метода вы это сделали? |
В поведении 'entity' => function () {
return new Entity([
'sets' => Memoize::call([Set::class, 'findAll'], ['slug' => ['demo']]), // не работает
//'sets' => Set::findAll(['slug' => ['demo']]), // работает
]);
}, |
думаю, проблема в скобках, нужно: 'sets' => Memoize::call([Set::class, 'findAll'], [['slug' => ['demo']]]) |
Точно! Спасибо! |
После того, как привязал Eav к модели, независимо от того, вывожу я Eav-аттрибуты в гриде или нет, все равно идут однотипные запросы.
Сейчас у в гриде 4 записи => получаю 5 одинаковых запросов
The text was updated successfully, but these errors were encountered: