Ejemplo n.º 1
0
 /**
  * copy all properties and create duplicate payment
  * 
  * @param object $payment
  * @return boolean
  */
 protected function moptDuplicatePayment($payment)
 {
     $duplicatedPayment = new \Shopware\Models\Payment\Payment();
     $duplicatedPayment->setName($this->moptCreateUniquePaymentName($payment->getName()));
     $duplicatedPayment->setDescription($payment->getDescription());
     $duplicatedPayment->setTemplate($payment->getTemplate());
     $duplicatedPayment->setAdditionalDescription($payment->getAdditionalDescription());
     $duplicatedPayment->setPosition(200);
     $duplicatedPayment->setActive(false);
     $duplicatedPayment->setAction($payment->getAction());
     $duplicatedPayment->setPluginId($payment->getPluginId());
     $duplicatedPayment->setSource(1);
     try {
         Shopware()->Models()->persist($duplicatedPayment);
         Shopware()->Models()->flush();
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Create a new payment instance
  *
  * @param   array $options
  * @param   null $description
  * @param   null $action
  * @return  \Shopware\Models\Payment\Payment
  */
 public function createPayment($options, $description = null, $action = null)
 {
     if(is_string($options)) {
         $options = array('name' => $options);
     }
     $payment = $this->Payments()->findOneBy(array(
         'name' => $options['name']
     ));
     if($payment === null) {
         $payment = new \Shopware\Models\Payment\Payment();
         $payment->setName($options['name']);
         $this->Application()->Models()->persist($payment);
     }
     $payment->fromArray($options);
     if($description !== null) {
         $payment->setDescription($description);
     }
     if($action !== null) {
         $payment->setAction($action);
     }
     $plugin = $this->Plugin();
     $plugin->getPayments()->add($payment);
     $payment->setPlugin($plugin);
     Shopware()->Models()->flush($payment);
     return $payment;
 }