<?php

namespace OfficeBrain\Bundle\ProductBundle\Helper;

use Doctrine\Bundle\DoctrineBundle\Registry;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Query\ResultSetMapping;

/**
 * Product Detail Helper class
 *
 * @author OfficeBrain 4014 <info@officebrain.com>
 * Description : This class having common function which are available globally
 */
class ProductDetailHelper
{
    protected $productApi;
    
    public function __construct($productApi)
    {
        $this->productApi = $productApi;
    }
    
    public function __destruct()
    {
    }
     /**
     *  @author 4532
     *   Get Product Detail through API
     *
     *  @param string ProductSlug
     *  @param string culture
     *
     *  @return array if found product then array of that product else null
     */
    
    public function getProductDetailInfo($product_slug, $culture)
    {
        $data = array();
        $this->productApi = $this->get('office_brain_product_api');
        $this->productApi->init('view_product');
        $this->productApi->setCallParameters(array('product_slug'=>$product_slug));
        $this->productApi->setCulture($culture);
        $this->productApi->doProcess();
        if ($this->productApi->isSuccess()) {
            $data = $this->productApi->getResultArray();
        }
       
        return $data;
    }
}
