Make sure your entity is using the custom Repository
/**
* @ORM\Entity(repositoryClass="Sylius\...\ProductRepository")
**/
class Product { ... }
Also try clearing your cache
I would suggest not making a custom twig function. Call this function in the controller and pass the results to twig