1

I got the next code:

public function getProductCollection()
{
    if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) {
        $collection = $this->_productCollections[$this->getCurrentCategory()->getId()];
    } else {
        $collection = $this->collectionProvider->getCollection($this->getCurrentCategory());
        $this->prepareProductCollection($collection);
        $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection;
    }
    echo "Collection count".$collection->count();
    return $collection;
}

When I tried to echo collection count - it always equals 0, but when I delete this string - everything is okay count equals 16. How?

0

I think you are supposed to append the string in the return

//echo "Collection count".$collection->count();
$collection->count();
return "Collection count ".$collection;

Your Answer

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

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