/** * Remove the translation for a given locale * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * @param ConnectionInterface $con an optional connection object * * @return ChildCategory The current object (for fluent API support) */ public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildCategoryI18nQuery::create()->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))->delete($con); } if (isset($this->currentTranslations[$locale])) { unset($this->currentTranslations[$locale]); } foreach ($this->collCategoryI18ns as $key => $translation) { if ($translation->getLocale() == $locale) { unset($this->collCategoryI18ns[$key]); break; } } return $this; }
$stmt->execute(); echo "Clearing tables\n"; Model\ProductAssociatedContentQuery::create()->deleteAll(); Model\CategoryAssociatedContentQuery::create()->deleteAll(); Model\FeatureProductQuery::create()->deleteAll(); Model\AttributeCombinationQuery::create()->deleteAll(); Model\FeatureQuery::create()->deleteAll(); Model\FeatureI18nQuery::create()->deleteAll(); Model\FeatureAvQuery::create()->deleteAll(); Model\FeatureAvI18nQuery::create()->deleteAll(); Model\AttributeQuery::create()->deleteAll(); Model\AttributeI18nQuery::create()->deleteAll(); 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();
/** * Removes this object from datastore and sets delete attribute. * * @param ConnectionInterface $con * @return void * @throws PropelException * @see CategoryI18n::setDeleted() * @see CategoryI18n::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(CategoryI18nTableMap::DATABASE_NAME); } $con->beginTransaction(); try { $deleteQuery = ChildCategoryI18nQuery::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; } }
/** * Performs an INSERT on the database, given a CategoryI18n or Criteria object. * * @param mixed $criteria Criteria or CategoryI18n 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(CategoryI18nTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from CategoryI18n object } // Set the correct dbName $query = CategoryI18nQuery::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; }
/** * @return mixed|\Thelia\Core\HttpFoundation\Response * @throws \Propel\Runtime\Exception\PropelException */ public function searchAction() { if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), 'RewriteUrl', AccessManager::VIEW))) { return $response; } $search = '%' . $this->getRequest()->query->get('q') . '%'; $resultArray = array(); $categoriesI18n = CategoryI18nQuery::create()->filterByTitle($search)->limit(10); $contentsI18n = ContentI18nQuery::create()->filterByTitle($search)->limit(10); $foldersI18n = FolderI18nQuery::create()->filterByTitle($search)->limit(10); $brandsI18n = BrandI18nQuery::create()->filterByTitle($search)->limit(10); $productsI18n = ProductI18nQuery::create()->filterByTitle($search)->limit(10); $productsRef = ProductQuery::create()->filterByRef($search)->limit(10); /** @var \Thelia\Model\CategoryI18n $categoryI18n */ foreach ($categoriesI18n as $categoryI18n) { $category = $categoryI18n->getCategory(); $resultArray['category'][$category->getId()] = $categoryI18n->getTitle(); } /** @var \Thelia\Model\ContentI18n $contentI18n */ foreach ($contentsI18n as $contentI18n) { $content = $contentI18n->getContent(); $resultArray['content'][$content->getId()] = $contentI18n->getTitle(); } /** @var \Thelia\Model\FolderI18n $folderI18n */ foreach ($foldersI18n as $folderI18n) { $folder = $folderI18n->getFolder(); $resultArray['folder'][$folder->getId()] = $folderI18n->getTitle(); } /** @var \Thelia\Model\BrandI18n $brandI18n */ foreach ($brandsI18n as $brandI18n) { $brand = $brandI18n->getBrand(); $resultArray['brand'][$brand->getId()] = $brandI18n->getTitle(); } /** @var \Thelia\Model\ProductI18n $productI18n */ foreach ($productsI18n as $productI18n) { $product = $productI18n->getProduct(); $resultArray['product'][$product->getId()] = $productI18n->getTitle(); } /** @var \Thelia\Model\Product $product */ foreach ($productsRef as $product) { $productI18n = ProductI18nQuery::create()->filterByProduct($product)->findOne(); $resultArray['product'][$product->getId()] = $productI18n->getTitle(); } return $this->jsonResponse(json_encode($resultArray)); }