コード例 #1
0
 /**
  * get or create attribute data for given object
  *
  * @param Shipping $object
  * @return \Shopware\Models\Attribute\CustomerShipping
  * @throws Exception 
  */
 public function getOrCreateShippingAttribute($object)
 {
     if ($attribute = $object->getAttribute()) {
         return $attribute;
     }
     if ($object instanceof Shopware\Models\Customer\Shipping) {
         if (!($attribute = Shopware()->Models()->getRepository('Shopware\\Models\\Attribute\\CustomerShipping')->findOneBy(array('customerShippingId' => $object->getId())))) {
             $attribute = new Shopware\Models\Attribute\CustomerShipping();
         }
     } else {
         throw new Exception('Unknown attribute base class');
     }
     $object->setAttribute($attribute);
     return $attribute;
 }