views:

23

answers:

1

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.

A: 

This is untested.

public function filterByIdPath($idPath)
{
    $this->addFieldToFilter('id_path', array('nlike'=>'%'.$idPath.'%'));
    return $this;
}

"nlike" means "NOT LIKE" and "%" is a wildcard. Presumably you would call the function like ->filterByIdPath('questions')

clockworkgeek