public function getVirtualDocumentListAjaxAction($productId, $pseId)
    {
        $this->checkAuth(AdminResources::PRODUCT, array(), AccessManager::VIEW);
        $this->checkXmlHttpRequest();

        $selectedId = \intval(MetaDataQuery::getVal('virtual', MetaData::PSE_KEY, $pseId));

        $documents = ProductDocumentQuery::create()
            ->filterByProductId($productId)
            ->filterByVisible(0)
            ->orderByPosition()
            ->find()
        ;

        $results = [];

        if (null !== $documents) {
            /** @var ProductDocument $document */
            foreach ($documents as $document) {
                $results[] = [
                    'id'       => $document->getId(),
                    'title'    => $document->getTitle(),
                    'file'     => $document->getFile(),
                    'selected' => ($document->getId() == $selectedId)
                ];
            }
        }

        return $this->jsonResponse(json_encode($results));
    }
public function getVirtualDocumentListAjaxAction($productId, $pseId)
    {
        $this->checkAuth(AdminResources::PRODUCT, array(), AccessManager::VIEW);
        $this->checkXmlHttpRequest();

        $selectedId = \intval(MetaDataQuery::getVal('virtual', MetaData::PSE_KEY, $pseId));

        $documents = ProductDocumentQuery::create()
            ->filterByProductId($productId)
            ->filterByVisible(0)
            ->orderByPosition()
            ->find()
        ;

        $results = [];

        if (null !== $documents) {
            /** @var ProductDocument $document */
            foreach ($documents as $document) {
                $results[] = [
                    'id'       => $document->getId(),
                    'title'    => $document->getTitle(),
                    'file'     => $document->getFile(),
                    'selected' => ($document->getId() == $selectedId)
                ];
            }
        }

        return $this->jsonResponse(json_encode($results));
    }
public function getVirtualDocumentListAjaxAction ( $ productId , $ pseId ) { $ this -> checkAuth ( AdminResources :: PRODUCT , array ( ) , AccessManager :: VIEW ) ; $ this -> checkXmlHttpRequest ( ) ; $ selectedId = \ intval ( MetaDataQuery :: getVal ( 'virtual' , MetaData :: PSE_KEY , $ pseId ) ) ; $ documents = ProductDocumentQuery :: create ( ) -> filterByProductId ( $ productId ) -> filterByVisible ( 0 ) -> orderByPosition ( ) -> find ( ) ; $ results = [ ] ; if ( null !== $ documents ) { /** @var ProductDocument $document */ foreach ( $ documents as $ document ) { $ results [ ] = [ 'id' => $ document -> getId ( ) , 'title' => $ document -> getTitle ( ) , 'file' => $ document -> getFile ( ) , 'selected' => ( $ document -> getId ( ) == $ selectedId ) ] ; } } return $ this -> jsonResponse ( json_encode ( $ results ) ) ; }
return a list of document which will be displayed in AJAX

@param $productId
@param $pseId

@return Response
return a list of document which will be displayed in AJAX