Grid选择Select All显示几千条,执行后只有当前页改变。标准Mass Action不会把所有ID都放进selected参数。
解决记录
步骤1:检查请求中的selected、excluded、filters和namespace;全选依赖筛选条件和excluded列表。
步骤2:Controller使用MassAction Filter的getCollection应用UI筛选,不要只遍历request[selected]。
步骤3:primaryFieldName、requestFieldName和indexField必须对应真实主键。
步骤4:大批量改为分页或队列,并记录成功失败ID;执行前显示匹配总数避免误处理全表。
命令与数据检查
$collection = $this->filter->getCollection($this->collectionFactory->create());
foreach ($collection->getItems() as $item) { /* enqueue/process */ }上线前验收
当前页选择、跨页全选、排除3条及带筛选全选的处理数量都与界面一致。

