カスタムグリッドでデータをフィルタ処理する方法
-
13-12-2019 - |
質問
カスタムモジュールグリッドでグリッドシリアル化を使用しています。
student_ids
を使用してデータをフィルタリングしたいです。
現在の学生IDを持っています。
データベース内のstudent_ids exの複数の学生IDを保存します。1,2,3
今度は現在の学生IDがstudent_idsに存在したい。
私はこれを試しています
$currentStudentId = $this->getRequest()->getParam('id');
$collection = Mage::getModel('example/data')->getCollection()
->addFieldToFilter('student_ids',array('like' => '%,'.$currentStudentId));
.
しかし、この1,2,3
のような文字列はこのような多くの可能性が非常に多くの可能性であるため、適切なデータが得られませんので、これを使用できません。
[編集]
解決
$currentStudentId = $this->getRequest()->getParam('id');
$collection = Mage::getModel('example/data')->getCollection()
->addFieldToFilter('student_ids',array("finset"=>$currentStudentId);
.
基本的にこの句は、任意の属性に複数選択がある場合にマゼントで使用します。
あなたのために働くことを願っています。
所属していません magento.stackexchange