Magento Collection模型过滤器修改
我的两个模块存在冲突,这导致了一个严重的问题,我对后端编程不太熟悉,所以我来这里希望有人可以帮助我。 PS我确实尝试自己解决这个问题至少一两个小时,学到了很多东西,但没有任何足够简单的东西来解决这个问题。
我需要修改以下函数,以便当以类似于下面示例的方式使用它时,它会从集合中排除 id_path 包含字符串“questions”的任何项目。
public function filterByIdPath($idPath)
{
$this->getSelect()
->where('id_path = ?', $idPath);
return $this;
}
$collection = Mage::getResourceModel('seosuite/core_url_rewrite_collection')
->filterAllByProductId($productId)
->sortByLength('ASC')
->addStoreFilter($storeId, false);
->filterByIdPath($idPath)
该函数所在的类是Mage_Core_Model_Mysql4_Url_Rewrite_Collection的扩展版本。如果 id_path 不合适,我们也可以访问 request_path。
以下是 id_paths 的一些示例:product/2/3/questions、product/5/3、category/3、product/3/3/questions。
Two of my modules are conflicting and it's causing a serious issue, I'm not all that familiar with back-end programming so I've come here hoping someone can help me out. P.S. I did try to solve this on my own for at least an hour or two, learned quite a bit but not anything that was straight forward enough to solve this.
I need to modify the following function so that when it is used in a manner similar to the example further below, it excludes from the collection any items where id_path contains the string 'questions'.
public function filterByIdPath($idPath)
{
$this->getSelect()
->where('id_path = ?', $idPath);
return $this;
}
$collection = Mage::getResourceModel('seosuite/core_url_rewrite_collection')
->filterAllByProductId($productId)
->sortByLength('ASC')
->addStoreFilter($storeId, false);
->filterByIdPath($idPath)
The class this function is located in is an extended version of Mage_Core_Model_Mysql4_Url_Rewrite_Collection. We also have access to request_path if id_path is not suitable.
Here are a few examples of id_paths: product/2/3/questions, product/5/3, category/3, product/3/3/questions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是未经测试的。
“nlike”表示“NOT LIKE”,“%”是通配符。想必您会调用类似
->filterByIdPath('questions')
的函数This is untested.
"nlike" means "NOT LIKE" and "%" is a wildcard. Presumably you would call the function like
->filterByIdPath('questions')