2

Im constantly seeing the following error in system.log I've gone into the file but cant see anything wrong can any one help me?

Warning: strlen() expects parameter 1 to be string, array given in /app/code/core/Mage/Catalog/Model/Layer/Filter/Attribute.php on line 93

5
  • Do you use an old version of Amasty Order Attributes? :-) Upgrade the extension. Commented May 28, 2014 at 10:46
  • @FabianBlechschmidt Nope ive never used that module we have used the promo items though? Commented May 28, 2014 at 10:56
  • I know this error from the OrderAttributes extension, but maybe it happens there too... Commented May 28, 2014 at 12:15
  • Which concrete Magento version are you using? Commented Jan 21, 2019 at 17:43
  • @RaulSanchez it was some version of 1.9 probably 1.9.2.x any way onto M2 now Commented Jan 21, 2019 at 17:46

2 Answers 2

4

This is from my copy (1.7.0.2) of app/code/core/Mage/Catalog/Model/Layer/Filter/Attribute.php

_getOptionText is returning an array, not a string like the code is clearly expecting. I'd see what class getFrontend is returning and then see how that can be returning an array.

protected function _getOptionText($optionId)
{
    return $this->getAttributeModel()->getFrontend()->getOption($optionId);
}

/**
 * Apply attribute option filter to product collection
 *
 * @param   Zend_Controller_Request_Abstract $request
 * @param   Varien_Object $filterBlock
 * @return  Mage_Catalog_Model_Layer_Filter_Attribute
 */
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
{
    $filter = $request->getParam($this->_requestVar);
    if (is_array($filter)) {
        return $this;
    }
    $text = $this->_getOptionText($filter);
    if ($filter && strlen($text)) {
        $this->_getResource()->applyFilterToCollection($this, $filter);
        $this->getLayer()->getState()->addFilter($this->_createItem($text, $filter));
        $this->_items = array();
    }
    return $this;
}
0
-2

strlen() is a function which gives the length of the string you passed as a parameter.

The error is that you must be passing an array in the strlen(). Please check the value you are passing. It should be string.

Check your file "Attribute.php" at line no. 93.

2
  • 2
    downvoted - because stating the obvious and rewording the error in laymans terms doesn't really answer the question. I'm presuming the point of the question is more understanding why Magentos' Core is fragmented.
    – Ash
    Commented May 28, 2014 at 13:33
  • Upvote, I don't see why this answer couldn't be valid Commented Jan 21, 2019 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.