1

I have this code in a SOAP call:

private function doSearchResults($terms)
{
    try {
        $collection = Mage::getResourceModel('catalogsearch/fulltext_collection')
            ->addAttributeToSelect('*')
            ->addSearchFilter($terms);
        return $collection->getSelect();
        $collection = $collection
            ->setStore(1)
            ->addMinimalPrice()
            ->addFinalPrice()
            ->addTaxPercents()
            ->addStoreFilter()
            ->addUrlRewrite();
        Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
        Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
    } catch (Exception $e) {
        return $e->getMessage();
    }

    //$collection->load();
    //return $collection;
}

Notice that, to narrow the problem, I put a return sentence in the middle.

If I call this inside a custom controller, it works. If I call this inside a SOAP call, it returns the following error message:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS `query_id`, `s`.`product_id` FROM `catalogsearch_fulltext` AS `s`
 INNER JOIN' at line 1

edit: How do I know that the failing method is that? Because the former code I tested was:

private function doSearchResults($terms)
{
    try {
        $collection = Mage::getResourceModel('catalogsearch/fulltext_collection')
            ->addAttributeToSelect('*');
        return $collection->getSelect();
        $collection = $collection
            ->addSearchFilter($terms)
            ->setStore(1)
            ->addMinimalPrice()
            ->addFinalPrice()
            ->addTaxPercents()
            ->addStoreFilter()
            ->addUrlRewrite();
        Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
        Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
    } catch (Exception $e) {
        return $e->getMessage();
    }

    //$collection->load();
    //return $collection;
}

And it worked : I debugged the select object. The text in "terms" is always set.

My question is: why does it work in a controller but not in soap?

My SOAP user has access to every resource.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.