Ejemplo n.º 1
0
 /**
  * Filter the query by a related \Thelia\Model\ProductPrice object
  *
  * @param \Thelia\Model\ProductPrice|ObjectCollection $productPrice  the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildCurrencyQuery The current query, for fluid interface
  */
 public function filterByProductPrice($productPrice, $comparison = null)
 {
     if ($productPrice instanceof \Thelia\Model\ProductPrice) {
         return $this->addUsingAlias(CurrencyTableMap::ID, $productPrice->getCurrencyId(), $comparison);
     } elseif ($productPrice instanceof ObjectCollection) {
         return $this->useProductPriceQuery()->filterByPrimaryKeys($productPrice->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByProductPrice() only accepts arguments of type \\Thelia\\Model\\ProductPrice or Collection');
     }
 }
Ejemplo n.º 2
0
 public function updateClone(ProductCloneEvent $event, ProductPrice $originalProductDefaultPrice)
 {
     // Get original product's I18ns
     $originalProductI18ns = ProductI18nQuery::create()->findById($event->getOriginalProduct()->getId());
     /** @var ProductI18n $originalProductI18n */
     foreach ($originalProductI18ns as $originalProductI18n) {
         $clonedProductUpdateEvent = new ProductUpdateEvent($event->getClonedProduct()->getId());
         $clonedProductUpdateEvent->setRef($event->getClonedProduct()->getRef())->setVisible($event->getClonedProduct()->getVisible())->setVirtual($event->getClonedProduct()->getVirtual())->setLocale($originalProductI18n->getLocale())->setTitle($originalProductI18n->getTitle())->setChapo($originalProductI18n->getChapo())->setDescription($originalProductI18n->getDescription())->setPostscriptum($originalProductI18n->getPostscriptum())->setBasePrice($originalProductDefaultPrice->getPrice())->setCurrencyId($originalProductDefaultPrice->getCurrencyId())->setBaseWeight($event->getOriginalProduct()->getDefaultSaleElements()->getWeight())->setTaxRuleId($event->getOriginalProduct()->getTaxRuleId())->setBrandId($event->getOriginalProduct()->getBrandId())->setDefaultCategory($event->getOriginalProduct()->getDefaultCategoryId());
         $this->eventDispatcher->dispatch(TheliaEvents::PRODUCT_UPDATE, $clonedProductUpdateEvent);
         // SEO info
         $clonedProductUpdateSeoEvent = new UpdateSeoEvent($event->getClonedProduct()->getId());
         $clonedProductUpdateSeoEvent->setLocale($originalProductI18n->getLocale())->setMetaTitle($originalProductI18n->getMetaTitle())->setMetaDescription($originalProductI18n->getMetaDescription())->setMetaKeywords($originalProductI18n->getMetaKeywords())->setUrl(null);
         $this->eventDispatcher->dispatch(TheliaEvents::PRODUCT_UPDATE_SEO, $clonedProductUpdateSeoEvent);
     }
     $event->setClonedProduct($clonedProductUpdateEvent->getProduct());
     // Set clone's template
     $clonedProductUpdateTemplateEvent = new ProductSetTemplateEvent($event->getClonedProduct(), $event->getOriginalProduct()->getTemplateId(), $originalProductDefaultPrice->getCurrencyId());
     $this->eventDispatcher->dispatch(TheliaEvents::PRODUCT_SET_TEMPLATE, $clonedProductUpdateTemplateEvent);
 }
Ejemplo n.º 3
0
 /**
  * Exclude object from result
  *
  * @param   ChildProductPrice $productPrice Object to remove from the list of results
  *
  * @return ChildProductPriceQuery The current query, for fluid interface
  */
 public function prune($productPrice = null)
 {
     if ($productPrice) {
         $this->addCond('pruneCond0', $this->getAliasedColName(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID), $productPrice->getProductSaleElementsId(), Criteria::NOT_EQUAL);
         $this->addCond('pruneCond1', $this->getAliasedColName(ProductPriceTableMap::CURRENCY_ID), $productPrice->getCurrencyId(), Criteria::NOT_EQUAL);
         $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
     }
     return $this;
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database. In some cases you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by find*()
  * and findPk*() calls.
  *
  * @param \Thelia\Model\ProductPrice $obj A \Thelia\Model\ProductPrice object.
  * @param string $key             (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if (null === $key) {
             $key = serialize(array((string) $obj->getProductSaleElementsId(), (string) $obj->getCurrencyId()));
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }