コード例 #1
0
 public function deleteTaxonomy()
 {
     if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('GoogleShopping'), AccessManager::DELETE))) {
         return $response;
     }
     $categoryId = $this->getRequest()->request->get('category_id');
     $langId = $this->getRequest()->request->get('lang_id');
     $taxonomy = GoogleshoppingTaxonomyQuery::create()->filterByTheliaCategoryId($categoryId)->filterByLangId($langId)->findOne();
     if (null !== $taxonomy) {
         $taxonomy->delete();
     }
     return new JsonResponse(["message" => "Category association deleted with success !"], 200);
 }
コード例 #2
0
 public function categoryManagementView($id, $langId)
 {
     if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), 'GoogleShopping', AccessManager::VIEW))) {
         return $response;
     }
     $isAssociatedCategory = GoogleshoppingTaxonomyQuery::create()->filterByTheliaCategoryId($id)->filterByLangId($langId)->findOne();
     if (null === $isAssociatedCategory) {
         throw new \Exception("This category is not associated with a Google's one in this language");
     }
     $params = ["categoryId" => $id, "langId" => $langId];
     $defaultGoogleAccount = GoogleshoppingAccountQuery::create()->filterByIsDefault(true)->findOne();
     if ($defaultGoogleAccount !== null) {
         $params['merchantId'] = $defaultGoogleAccount->getMerchantId();
         $params['countryId'] = $defaultGoogleAccount->getDefaultCountryId();
         $params['currencyId'] = $defaultGoogleAccount->getDefaultCurrencyId();
     }
     return $this->render("google-shopping/category-management", $params);
 }
コード例 #3
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      ConnectionInterface $con
  * @return void
  * @throws PropelException
  * @see GoogleshoppingTaxonomy::setDeleted()
  * @see GoogleshoppingTaxonomy::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(GoogleshoppingTaxonomyTableMap::DATABASE_NAME);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = ChildGoogleshoppingTaxonomyQuery::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;
     }
 }
コード例 #4
0
 public function normalParseResults(LoopResult $loopResult)
 {
     $colorAttributeId = GoogleShopping::getConfigValue('attribute_color');
     $sizeAttributeId = GoogleShopping::getConfigValue('attribute_size');
     /** @var Product $product */
     foreach ($loopResult->getResultDataCollection() as $product) {
         $checkEan = $this->checkEan($product, $colorAttributeId, $sizeAttributeId);
         $isCategoryAssociated = GoogleshoppingTaxonomyQuery::create()->findOneByTheliaCategoryId($product->getDefaultCategoryId()) !== null ? true : false;
         $loopResultRow = new LoopResultRow();
         $loopResultRow->set("ID", $product->getId());
         $loopResultRow->set("REF", $product->getRef());
         $loopResultRow->set("TITLE", $product->getTitle());
         $loopResultRow->set("CATEGORY_ASSOCIATED", $isCategoryAssociated);
         $loopResultRow->set("VALID_EAN", $checkEan);
         $loopResult->addRow($loopResultRow);
     }
     return $loopResult;
 }
コード例 #5
0
 /**
  * Performs an INSERT on the database, given a GoogleshoppingTaxonomy or Criteria object.
  *
  * @param mixed               $criteria Criteria or GoogleshoppingTaxonomy 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(GoogleshoppingTaxonomyTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from GoogleshoppingTaxonomy object
     }
     if ($criteria->containsKey(GoogleshoppingTaxonomyTableMap::ID) && $criteria->keyContainsValue(GoogleshoppingTaxonomyTableMap::ID)) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . GoogleshoppingTaxonomyTableMap::ID . ')');
     }
     // Set the correct dbName
     $query = GoogleshoppingTaxonomyQuery::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;
 }