Example #1
0
 protected function getPSEVirtualDocument(ProductSaleElementsModel $pse)
 {
     /**
      * Compute documents with the associated loop
      */
     $documentLoop = new Document($this->container);
     // select only not visible documents
     $documentLoop->initializeArgs(["product" => $pse->getProductId(), "visible" => 0]);
     $documents = $documentLoop->exec($documentPagination);
     $documentId = intval(MetaDataQuery::getVal("virtual", "pse", $pse->getId()));
     $data = [];
     /** @var \Thelia\Core\Template\Element\LoopResultRow $document */
     for ($documents->rewind(); $documents->valid(); $documents->next()) {
         $document = $documents->current();
         $data[] = ["id" => $document->get("ID"), "url" => $document->get("DOCUMENT_URL"), "title" => $document->get("TITLE"), "is_associated" => $documentId === $document->get("ID"), "filename" => $document->model->getFile()];
     }
     return $data;
 }
Example #2
0
 /**
  * Filter the query by a related \Thelia\Model\ProductSaleElements object
  *
  * @param \Thelia\Model\ProductSaleElements|ObjectCollection $productSaleElements  the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildProductQuery The current query, for fluid interface
  */
 public function filterByProductSaleElements($productSaleElements, $comparison = null)
 {
     if ($productSaleElements instanceof \Thelia\Model\ProductSaleElements) {
         return $this->addUsingAlias(ProductTableMap::ID, $productSaleElements->getProductId(), $comparison);
     } elseif ($productSaleElements instanceof ObjectCollection) {
         return $this->useProductSaleElementsQuery()->filterByPrimaryKeys($productSaleElements->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByProductSaleElements() only accepts arguments of type \\Thelia\\Model\\ProductSaleElements or Collection');
     }
 }