Sonata\ProductBundle\Block\SimilarProductsBlockService::execute PHP Method

execute() public method

public execute ( Sonata\BlockBundle\Block\BlockContextInterface $blockContext, Response $response = null )
$blockContext Sonata\BlockBundle\Block\BlockContextInterface
$response Symfony\Component\HttpFoundation\Response
    public function execute(BlockContextInterface $blockContext, Response $response = null)
    {
        if (!($product = $this->getProductRepository()->findOneBy(array('id' => $blockContext->getSetting('base_product_id'))))) {
            return;
        }
        $products = $this->getProductFinder()->getCrossSellingSimilarParentProducts($product, $blockContext->getSetting('number'));
        $params = array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'products' => $products, 'currency' => $this->currencyDetector->getCurrency());
        return $this->renderResponse($blockContext->getTemplate(), $params, $response);
    }