/**
  * Creates the update SEO event with the provided form data
  *
  * @param $formData
  * @return UpdateSeoEvent
  */
 protected function getUpdateSeoEvent($formData)
 {
     $updateSeoEvent = new UpdateSeoEvent($formData['id']);
     $updateSeoEvent->setLocale($formData['locale'])->setMetaTitle($formData['meta_title'])->setMetaDescription($formData['meta_description'])->setMetaKeywords($formData['meta_keywords'])->setUrl($formData['url']);
     // Create and dispatch the change event
     return $updateSeoEvent;
 }
 public function getUpdateSeoEvent(&$folder)
 {
     if (!$folder instanceof FolderModel) {
         $folder = $this->getRandomFolder();
     }
     $event = new UpdateSeoEvent($folder->getId());
     $event->setLocale($folder->getLocale())->setMetaTitle($folder->getMetaTitle())->setMetaDescription($folder->getMetaDescription())->setMetaKeywords($folder->getMetaKeywords());
     return $event;
 }
Exemple #3
0
 /**
  * Changes SEO Fields for an object.
  *
  * @param ModelCriteria  $query
  * @param UpdateSeoEvent $event
  *
  * @return mixed                   an SEOxxx object
  * @throws FormValidationException if a rewritten URL cannot be created
  */
 protected function genericUpdateSeo(ModelCriteria $query, UpdateSeoEvent $event)
 {
     if (null !== ($object = $query->findPk($event->getObjectId()))) {
         $object->setDispatcher($event->getDispatcher())->setLocale($event->getLocale())->setMetaTitle($event->getMetaTitle())->setMetaDescription($event->getMetaDescription())->setMetaKeywords($event->getMetaKeywords())->save();
         // Update the rewritten URL, if required
         try {
             $object->setRewrittenUrl($event->getLocale(), $event->getUrl());
         } catch (UrlRewritingException $e) {
             throw new FormValidationException($e->getMessage(), $e->getCode());
         }
         $event->setObject($object);
     }
     return $object;
 }
Exemple #4
0
 public function updateClone(ProductCloneEvent $event, $originalProductDefaultPrice)
 {
     // Get original product's I18ns
     $originalProductI18ns = ProductI18nQuery::create()->findById($event->getOriginalProduct()->getId());
     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());
         $event->getDispatcher()->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);
         $event->getDispatcher()->dispatch(TheliaEvents::PRODUCT_UPDATE_SEO, $clonedProductUpdateSeoEvent);
     }
     $event->setClonedProduct($clonedProductUpdateEvent->getProduct());
     // Set clone's template
     $clonedProductUpdateTemplateEvent = new ProductSetTemplateEvent($event->getClonedProduct(), $event->getOriginalProduct()->getTemplateId(), $originalProductDefaultPrice->getCurrencyId());
     $event->getDispatcher()->dispatch(TheliaEvents::PRODUCT_SET_TEMPLATE, $clonedProductUpdateTemplateEvent);
 }