Example #1
0
 /**
  * Post-validate new entity
  *
  * @param \XLite\Model\AEntity $entity Entity
  *
  * @return boolean
  */
 protected function prevalidateNewEntity(\XLite\Model\AEntity $entity)
 {
     $result = parent::prevalidateNewEntity($entity);
     if ($result && $entity->getRepository()->findOneSimilarDiscount($entity)) {
         $this->errorMessages[] = static::t('Could not add the discount because another discount already exists for the specified subtotal range and membership level');
         $result = false;
     } else {
         $this->discountKeys[] = $entity->getFingerprint();
     }
     return $result;
 }
Example #2
0
 /**
  * Post-validate new entity
  *
  * @param \XLite\Model\AEntity $entity Entity
  *
  * @return boolean
  */
 protected function prevalidateNewEntity(\XLite\Model\AEntity $entity)
 {
     $result = parent::prevalidateNewEntity($entity);
     if ($result) {
         $attrValues = $entity->getValues();
         if ($attrValues) {
             $ids = array();
             $str = array();
             foreach ($attrValues as $av) {
                 $ids[$av->getAttribute()->getId()] = $av->getId();
                 $str[] = sprintf('%s: %s', $av->getAttribute()->getName(), $av->asString());
             }
             // Search for the same variant
             $sameVariants = $this->getProduct()->getVariantByAttributeValuesIds($ids, false);
             if (1 < count($sameVariants)) {
                 $this->errorMessages[] = static::t('Variant with specified attribute values already exists', array('list' => implode(', ', $str)));
                 $result = false;
             }
         }
     }
     return $result;
 }
Example #3
0
 /**
  * Post-validate new entity
  *
  * @param \XLite\Model\AEntity $entity Entity
  *
  * @return boolean
  */
 protected function prevalidateEntity(\XLite\Model\AEntity $entity)
 {
     $result = parent::prevalidateNewEntity($entity);
     if (in_array($entity->getServiceName(), $this->getForbiddenServiceNames())) {
         $result = false;
         $this->errorMessages[] = static::t('The service name X is reserved and cannot be used for an address field.', array('value' => $entity->getServiceName()));
     }
     return $result;
 }