<commit_before><?php
namespace Shop\Controller;

class ProductController extends \Zend\Mvc\Controller\AbstractActionController {
    
    public function indexAction() {
        $aResponse = array(
            'datagrid' => array(),
            'columnDefs' => array(
                array('field' => "p_id", 'displayName' => "ID", 'width' => 30, 'pinned' => true),
                array('field' => "p_category_name", 'displayName' => "Category", 'width' => 100),
                array('field' => "p_ref", 'displayName' => "Reference", 'width' => 100),
                array('field' => "p_description", 'displayName' => "Description", 'width' => 150),
                array('field' => "p_long_description", 'displayName' => "Long Description", 'width' => 200),
                array('field' => "p_price", 'displayName' => "Price", 'width' => 50),
            )
        );
        
        $oDataFunctionGateway = $this->serviceLocator->get('Datainterface\Model\DataFunctionGateway');
        $oResultSet = $oDataFunctionGateway->getDataRecordSet('IPYME_FINAL', 'get_product', array(':id' => null));
            
        foreach($oResultSet as $aProduct) {
            $aProduct['grid_id'] = $aProduct['p_id'];
            $aProduct['p_price'] = number_format($aProduct['p_price'],2);
            $aResponse['datagrid'][] = $aProduct;
        }

        return new \Zend\View\Model\JsonModel($aResponse);
    }
    public function getDisplayedProductsByCategoryAction() {
        $oDataFunctionGateway = $this->serviceLocator->get('Datainterface\Model\DataFunctionGateway');
        $nProductCategoryId =  $this->getEvent()->getRouteMatch()->getParam('id');
        $oResultSet = $oDataFunctionGateway->getDataRecordSet('IPYME_FINAL', 'get_product_by_category', array(':pc_id' => $nProductCategoryId));
        
        $aResponse = array('success' =>1, 'displayedProducts' => array());
        foreach($oResultSet as $aProduct) {
            $aResponse['displayedProducts'][] = array('id'              => $aProduct['p_id']
                                                    , 'image_path'      => $aProduct['p_image_path']
                                                    , 'description'     => $aProduct['p_description']
                                                    , 'longDescription' => $aProduct['p_long_description']
                                                    , 'price'           => number_format($aProduct['p_price'],2)
                                                    , 'currency'        => $aProduct['c_name']
                                                    , 'category'        => $aProduct['p_category']
                                                    , 'category_name'   => $aProduct['p_category_name']
                                                    , 'quantity'        => 1);
        }
                                    
        return new \Zend\View\Model\JsonModel($aResponse);
    }<commit_msg>shop attributes working<commit_after><?php
namespace Shop\Controller;

class ProductController extends \Zend\Mvc\Controller\AbstractActionController {
    
    public function indexAction() {
        $aResponse = array(
            'datagrid' => array(),
            'columnDefs' => array(
                array('field' => "p_id", 'displayName' => "ID", 'width' => 30, 'pinned' => true),
                array('field' => "p_category_name", 'displayName' => "Category", 'width' => 100),
                array('field' => "p_ref", 'displayName' => "Reference", 'width' => 100),
                array('field' => "p_description", 'displayName' => "Description", 'width' => 150),
                array('field' => "p_long_description", 'displayName' => "Long Description", 'width' => 200),
                array('field' => "p_price", 'displayName' => "Price", 'width' => 50),
            )
        );
        
        $oDataFunctionGateway = $this->serviceLocator->get('Datainterface\Model\DataFunctionGateway');
        $oResultSet = $oDataFunctionGateway->getDataRecordSet('IPYME_FINAL', 'get_product', array(':id' => null));
            
        foreach($oResultSet as $aProduct) {
            $aProduct['grid_id'] = $aProduct['p_id'];
            $aProduct['p_price'] = number_format($aProduct['p_price'],2);
            $aResponse['datagrid'][] = $aProduct;
        }

        return new \Zend\View\Model\JsonModel($aResponse);
    }
    
    
    public function getDisplayedProductsByCategoryAction() {
        $oDataFunctionGateway = $this->serviceLocator->get('Datainterface\Model\DataFunctionGateway');
        $nProductCategoryId =  $this->getEvent()->getRouteMatch()->getParam('id');
        $oResultSet = $oDataFunctionGateway->getDataRecordSet('IPYME_FINAL', 'get_product_by_category', array(':pc_id' => $nProductCategoryId));
        
        $aResponse = array('success' =>1, 'displayedProducts' => array());
        foreach($oResultSet as $aProduct) {
            $aResponse['displayedProducts'][] = array('id'              => $aProduct['p_id']
                                                    , 'image_path'      => $aProduct['p_image_path']
                                                    , 'description'     => $aProduct['p_description']
                                                    , 'longDescription' => $aProduct['p_long_description']
                                                    , 'price'           => number_format($aProduct['p_price'],2)
                                                    , 'currency'        => $aProduct['c_name']
                                                    , 'category'        => $aProduct['p_category']
                                                    , 'category_name'   => $aProduct['p_category_name']
                                                    , 'quantity'        => 1);
        }
                                    
        return new \Zend\View\Model\JsonModel($aResponse);
    }
    
    public function getDisplayedProductsByAttributeValueAction() {
        if ($this->getRequest()->isXmlHttpRequest()) {
            $sJSONDataRequest = $this->getRequest()->getContent();
            $aRequest = (array)json_decode($sJSONDataRequest, true);
            
            $oDataFunctionGateway = $this->serviceLocator->get('Datainterface\Model\DataFunctionGateway');
            $oResultSet = $oDataFunctionGateway->getDataRecordSet(
                    'IPYME_FINAL'
                    , 'get_product_by_attribute_value'
                    , array(':p_pav_product_category_attribute' => $aRequest['category_attribute_id']
                           ,':p_pav_value' => $aRequest['category_attribute_value']));
            
            

            $aResponse = array('success' =>1, 'displayedProducts' => array());
            foreach($oResultSet as $aProduct) {
                $aResponse['displayedProducts'][] = array('id'              => $aProduct['p_id']
                                                        , 'image_path'      => $aProduct['p_image_path']
                                                        , 'description'     => $aProduct['p_description']
                                                        , 'longDescription' => $aProduct['p_long_description']
                                                        , 'price'           => number_format($aProduct['p_price'],2)
                                                        , 'currency'        => $aProduct['c_name']
                                                        , 'category'        => $aProduct['p_category']
                                                        , 'category_name'   => $aProduct['p_category_name']
                                                        , 'quantity'        => 1);
            }
        }
        else {
            $aResponse = array('success' => 0);
        }
                                    
        return new \Zend\View\Model\JsonModel($aResponse);
    }
    
    
{'fraction_non_alphanumeric': 0.1389309127584468, 'fraction_numerical': 0.005547150781643974, 'mean_word_length': 1.5773229369720598, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 110, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 51, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4259639', 'n_tokens_mistral': 1995, 'n_tokens_neox': 1947, 'n_words': 288}