Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function getBreadcrumb(Router $router, ContainerInterface $container, $tab, $locale)
 {
     $breadcrumb = [Translator::getInstance()->trans('Home') => $router->generate('admin.home.view', [], Router::ABSOLUTE_URL), Translator::getInstance()->trans('Brand') => $router->generate('admin.brand.default', [], Router::ABSOLUTE_URL)];
     if (null !== ($brand = BrandQuery::create()->findPk($this->getBrandId()))) {
         $breadcrumb[$brand->setLocale($locale)->getTitle()] = sprintf("%s?current_tab=%s", $router->generate('admin.brand.update', ['brand_id' => $brand->getId()], Router::ABSOLUTE_URL), $tab);
     }
     return $breadcrumb;
 }
Ejemplo n.º 2
0
 protected function getBrand($locale = 'en_US')
 {
     $brand = BrandQuery::create()->joinBrandI18n("brand_i18n_join", Criteria::INNER_JOIN)->addJoinCondition('brand_i18n_join', "locale = ?", $locale, null, \PDO::PARAM_STR)->findOne();
     if (null === $brand) {
         $this->markTestSkipped(sprintf("You must have at least one brand with an i18n that has the '%s' locale", $locale));
     }
     return $brand;
 }
Ejemplo n.º 3
0
 public function testSearchById()
 {
     $brand = BrandQuery::create()->findOne();
     if (null === $brand) {
         $brand = new \Thelia\Model\Brand();
         $brand->setVisible(1);
         $brand->setTitle('foo');
         $brand->save();
     }
     $otherParameters = array("visible" => "*");
     $this->baseTestSearchById($brand->getId(), $otherParameters);
 }
Ejemplo n.º 4
0
 public function buildModelCriteria()
 {
     $search = BrandQuery::create();
     /* manage translations */
     $this->configureI18nProcessing($search, array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORDS'));
     $id = $this->getId();
     if (!is_null($id)) {
         $search->filterById($id, Criteria::IN);
     }
     $product = $this->getProduct();
     if (!is_null($product) && null !== ($productObj = ProductQuery::create()->findPk($product))) {
         $search->filterByProduct($productObj);
     }
     $visible = $this->getVisible();
     if ($visible !== BooleanOrBothType::ANY) {
         $search->filterByVisible($visible ? 1 : 0);
     }
     $title = $this->getTitle();
     if (!is_null($title)) {
         $search->where("CASE WHEN NOT ISNULL(`requested_locale_i18n`.ID) THEN `requested_locale_i18n`.`TITLE` ELSE `default_locale_i18n`.`TITLE` END " . Criteria::LIKE . " ?", "%" . $title . "%", \PDO::PARAM_STR);
     }
     $current = $this->getCurrent();
     if ($current === true) {
         $search->filterById($this->request->get("brand_id"));
     } elseif ($current === false) {
         $search->filterById($this->request->get("brand_id"), Criteria::NOT_IN);
     }
     $orders = $this->getOrder();
     foreach ($orders as $order) {
         switch ($order) {
             case 'id':
                 $search->orderById(Criteria::ASC);
                 break;
             case 'id-reverse':
                 $search->orderById(Criteria::DESC);
                 break;
             case "alpha":
                 $search->addAscendingOrderByColumn('i18n_TITLE');
                 break;
             case "alpha-reverse":
                 $search->addDescendingOrderByColumn('i18n_TITLE');
                 break;
             case "manual":
                 $search->orderByPosition(Criteria::ASC);
                 break;
             case "manual-reverse":
                 $search->orderByPosition(Criteria::DESC);
                 break;
             case "random":
                 $search->clearOrderByColumns();
                 $search->addAscendingOrderByColumn('RAND()');
                 break 2;
             case "created":
                 $search->addAscendingOrderByColumn('created_at');
                 break;
             case "created-reverse":
                 $search->addDescendingOrderByColumn('created_at');
                 break;
             case "updated":
                 $search->addAscendingOrderByColumn('updated_at');
                 break;
             case "updated-reverse":
                 $search->addDescendingOrderByColumn('updated_at');
                 break;
         }
     }
     $exclude = $this->getExclude();
     if (!is_null($exclude)) {
         $search->filterById($exclude, Criteria::NOT_IN);
     }
     return $search;
 }
Ejemplo n.º 5
0
 public function parseResults(LoopResult $loopResult)
 {
     /** @var \Thelia\Model\Brand $brand */
     foreach ($loopResult->getResultDataCollection() as $brand) {
         $loopResultRow = new LoopResultRow($brand);
         $loopResultRow->set("ID", $brand->getId())->set("IS_TRANSLATED", $brand->getVirtualColumn('IS_TRANSLATED'))->set("LOCALE", $this->locale)->set("TITLE", $brand->getVirtualColumn('i18n_TITLE'))->set("CHAPO", $brand->getVirtualColumn('i18n_CHAPO'))->set("DESCRIPTION", $brand->getVirtualColumn('i18n_DESCRIPTION'))->set("POSTSCRIPTUM", $brand->getVirtualColumn('i18n_POSTSCRIPTUM'))->set("URL", $this->getReturnUrl() ? $brand->getUrl($this->locale) : null)->set("META_TITLE", $brand->getVirtualColumn('i18n_META_TITLE'))->set("META_DESCRIPTION", $brand->getVirtualColumn('i18n_META_DESCRIPTION'))->set("META_KEYWORDS", $brand->getVirtualColumn('i18n_META_KEYWORDS'))->set("POSITION", $brand->getPosition())->set("VISIBLE", $brand->getVisible())->set("LOGO_IMAGE_ID", $brand->getLogoImageId() ?: 0);
         $isBackendContext = $this->getBackendContext();
         if ($this->getWithPrevNextInfo()) {
             // Find previous and next category
             $previousQuery = BrandQuery::create()->filterByPosition($brand->getPosition(), Criteria::LESS_THAN);
             if (!$isBackendContext) {
                 $previousQuery->filterByVisible(true);
             }
             $previous = $previousQuery->orderByPosition(Criteria::DESC)->findOne();
             $nextQuery = BrandQuery::create()->filterByPosition($brand->getPosition(), Criteria::GREATER_THAN);
             if (!$isBackendContext) {
                 $nextQuery->filterByVisible(true);
             }
             $next = $nextQuery->orderByPosition(Criteria::ASC)->findOne();
             $loopResultRow->set("HAS_PREVIOUS", $previous != null ? 1 : 0)->set("HAS_NEXT", $next != null ? 1 : 0)->set("PREVIOUS", $previous != null ? $previous->getId() : -1)->set("NEXT", $next != null ? $next->getId() : -1);
         }
         $this->addOutputFields($loopResultRow, $brand);
         $loopResult->addRow($loopResultRow);
     }
     return $loopResult;
 }
Ejemplo n.º 6
0
 Model\AttributeAvQuery::create()->deleteAll();
 Model\AttributeAvI18nQuery::create()->deleteAll();
 Model\CategoryQuery::create()->deleteAll();
 Model\CategoryI18nQuery::create()->deleteAll();
 Model\ProductQuery::create()->deleteAll();
 Model\ProductI18nQuery::create()->deleteAll();
 Model\CustomerQuery::create()->deleteAll();
 Model\AdminQuery::create()->deleteAll();
 Model\FolderQuery::create()->deleteAll();
 Model\FolderI18nQuery::create()->deleteAll();
 Model\ContentQuery::create()->deleteAll();
 Model\ContentI18nQuery::create()->deleteAll();
 Model\AccessoryQuery::create()->deleteAll();
 Model\ProductSaleElementsQuery::create()->deleteAll();
 Model\ProductPriceQuery::create()->deleteAll();
 Model\BrandQuery::create()->deleteAll();
 Model\BrandI18nQuery::create()->deleteAll();
 Model\ProductImageQuery::create()->deleteAll();
 Model\CategoryImageQuery::create()->deleteAll();
 Model\FolderImageQuery::create()->deleteAll();
 Model\ContentImageQuery::create()->deleteAll();
 Model\BrandImageQuery::create()->deleteAll();
 Model\ProductDocumentQuery::create()->deleteAll();
 Model\CategoryDocumentQuery::create()->deleteAll();
 Model\FolderDocumentQuery::create()->deleteAll();
 Model\ContentDocumentQuery::create()->deleteAll();
 Model\BrandDocumentQuery::create()->deleteAll();
 Model\CouponQuery::create()->deleteAll();
 Model\OrderQuery::create()->deleteAll();
 Model\SaleQuery::create()->deleteAll();
 Model\SaleProductQuery::create()->deleteAll();
Ejemplo n.º 7
0
 /**
  * @return \Thelia\Model\Brand
  */
 protected function getRandomBrand()
 {
     $brand = BrandQuery::create()->addAscendingOrderByColumn('RAND()')->findOne();
     if (null === $brand) {
         $this->fail('use fixtures before launching test, there is no brand in database');
     }
     return $brand;
 }
Ejemplo n.º 8
0
 /**
  * Get the associated ChildBrand object
  *
  * @param      ConnectionInterface $con Optional Connection object.
  * @return                 ChildBrand The associated ChildBrand object.
  * @throws PropelException
  */
 public function getBrand(ConnectionInterface $con = null)
 {
     if ($this->aBrand === null && $this->brand_id !== null) {
         $this->aBrand = ChildBrandQuery::create()->findPk($this->brand_id, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aBrand->addBrandDocuments($this);
            */
     }
     return $this->aBrand;
 }
Ejemplo n.º 9
0
 /**
  * @depends testCreate
  */
 public function testUpdate(ProductModel $product)
 {
     $event = new ProductUpdateEvent($product->getId());
     $defaultCategory = CategoryQuery::create()->select('id')->addAscendingOrderByColumn('RAND()')->findOne();
     $brandId = BrandQuery::create()->findOne()->getId();
     $event->setLocale('fr_FR')->setTitle('test MAJ titre en français')->setDescription('test description fr')->setChapo('test chapo fr')->setPostscriptum('test postscriptum fr')->setVisible(1)->setDefaultCategory($defaultCategory)->setBrandId($brandId)->setRef($product->getRef())->setDispatcher($this->getDispatcher());
     $action = new Product();
     $action->update($event);
     $updatedProduct = $event->getProduct();
     $this->assertInstanceOf('Thelia\\Model\\Product', $updatedProduct);
     $updatedProduct->setLocale('fr_FR');
     $this->assertEquals('test MAJ titre en français', $updatedProduct->getTitle());
     $this->assertEquals('test description fr', $updatedProduct->getDescription());
     $this->assertEquals('test chapo fr', $updatedProduct->getChapo());
     $this->assertEquals('test postscriptum fr', $updatedProduct->getPostscriptum());
     $this->assertEquals(1, $updatedProduct->getVisible());
     $this->assertEquals($defaultCategory, $updatedProduct->getDefaultCategoryId());
     $PSE = $updatedProduct->getProductSaleElementss();
     $this->assertEquals(1, count($PSE));
     return $updatedProduct;
 }
 /**
  * @param string $view
  * @param int $id
  * @return bool
  */
 private function textExist($view, $id)
 {
     $test = null;
     if ($view == 'product') {
         $test = ProductQuery::create()->findPk($id);
     } else {
         if ($view == 'brand') {
             $test = BrandQuery::create()->findPk($id);
         } else {
             if ($view == 'category') {
                 $test = CategoryQuery::create()->findPk($id);
             } else {
                 if ($view == 'folder') {
                     $test = FolderQuery::create()->findPk($id);
                 } else {
                     if ($view == 'content') {
                         $test = ContentQuery::create()->findPk($id);
                     }
                 }
             }
         }
     }
     if ($test !== null) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 11
0
 /**
  * Check if the element exists and is visible
  *
  * @param $context string   catalog or content
  * @param $id string        id of the element
  * @return bool
  */
 private function checkId($context, $id)
 {
     $ret = false;
     if (is_numeric($id)) {
         if ("catalog" === $context) {
             $cat = CategoryQuery::create()->findPk($id);
             $ret = null !== $cat && $cat->getVisible();
         } elseif ("brand" === $context) {
             $brand = BrandQuery::create()->findPk($id);
             $ret = null !== $brand && $brand->getVisible();
         } else {
             $folder = FolderQuery::create()->findPk($id);
             $ret = null !== $folder && $folder->getVisible();
         }
     }
     return $ret;
 }
Ejemplo n.º 12
0
 public function updatePosition(UpdatePositionEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     $this->genericUpdatePosition(BrandQuery::create(), $event, $dispatcher);
 }
Ejemplo n.º 13
0
 public function updatePosition(UpdatePositionEvent $event)
 {
     $this->genericUpdatePosition(BrandQuery::create(), $event);
 }
Ejemplo n.º 14
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      ConnectionInterface $con
  * @return void
  * @throws PropelException
  * @see Brand::setDeleted()
  * @see Brand::isDeleted()
  */
 public function delete(ConnectionInterface $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getServiceContainer()->getWriteConnection(BrandTableMap::DATABASE_NAME);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = ChildBrandQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
Ejemplo n.º 15
0
 /**
  * Returns the number of related Brand objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      ConnectionInterface $con
  * @return int             Count of related Brand objects.
  * @throws PropelException
  */
 public function countBrandsRelatedByLogoImageId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
 {
     $partial = $this->collBrandsRelatedByLogoImageIdPartial && !$this->isNew();
     if (null === $this->collBrandsRelatedByLogoImageId || null !== $criteria || $partial) {
         if ($this->isNew() && null === $this->collBrandsRelatedByLogoImageId) {
             return 0;
         }
         if ($partial && !$criteria) {
             return count($this->getBrandsRelatedByLogoImageId());
         }
         $query = ChildBrandQuery::create(null, $criteria);
         if ($distinct) {
             $query->distinct();
         }
         return $query->filterByBrandImageRelatedByLogoImageId($this)->count($con);
     }
     return count($this->collBrandsRelatedByLogoImageId);
 }
Ejemplo n.º 16
0
 /**
  * Load an existing object from the database
  *
  * @return \Thelia\Model\Brand
  */
 protected function getExistingObject()
 {
     $brand = BrandQuery::create()->findOneById($this->getRequest()->get('brand_id', 0));
     if (null !== $brand) {
         $brand->setLocale($this->getCurrentEditionLocale());
     }
     return $brand;
 }
Ejemplo n.º 17
0
 public function testDeleteFileBrandImage()
 {
     $this->doTestDeleteFile(new BrandImage(), BrandQuery::create()->findOne(), 'images', 'brand');
 }
Ejemplo n.º 18
0
 /**
  * Performs an INSERT on the database, given a Brand or Criteria object.
  *
  * @param mixed               $criteria Criteria or Brand object containing data that is used to create the INSERT statement.
  * @param ConnectionInterface $con the ConnectionInterface connection to use
  * @return mixed           The new primary key.
  * @throws PropelException Any exceptions caught during processing will be
  *         rethrown wrapped into a PropelException.
  */
 public static function doInsert($criteria, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(BrandTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from Brand object
     }
     if ($criteria->containsKey(BrandTableMap::ID) && $criteria->keyContainsValue(BrandTableMap::ID)) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . BrandTableMap::ID . ')');
     }
     // Set the correct dbName
     $query = BrandQuery::create()->mergeWith($criteria);
     try {
         // use transaction because $criteria could contain info
         // for more than one table (I guess, conceivably)
         $con->beginTransaction();
         $pk = $query->doInsert($con);
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
     return $pk;
 }