/**
  * Generates the item price SOAP object
  *
  * @return PlentySoapObject_ItemPriceSet
  */
 protected function getObjectPriceSet()
 {
     //
     $MainDetail = $this->SHOPWARE_Article->getMainDetail();
     $Unit = $MainDetail->getUnit();
     $Tax = $this->SHOPWARE_Article->getTax();
     //
     $Object_ItemPriceSet = new PlentySoapObject_ItemPriceSet();
     $Object_ItemPriceSet->HeightInMM = $MainDetail->getHeight() * 100;
     // int
     $Object_ItemPriceSet->LengthInMM = $MainDetail->getLen() * 100;
     $Object_ItemPriceSet->Lot = $MainDetail->getPurchaseUnit();
     // float
     $Object_ItemPriceSet->PackagingUnit = $MainDetail->getReferenceUnit();
     $Object_ItemPriceSet->PurchasePriceNet = null;
     // float
     $Object_ItemPriceSet->TypeOfPackage = null;
     // int
     $Object_ItemPriceSet->Unit1 = $MainDetail->getPackUnit();
     $Object_ItemPriceSet->WeightInGramm = $MainDetail->getWeight() * 1000;
     $Object_ItemPriceSet->WidthInMM = $MainDetail->getWidth() * 100;
     // int
     if ($Unit instanceof \Shopware\Models\Article\Unit && $Unit->getId() > 0) {
         $Object_ItemPriceSet->Unit = PlentymarketsMappingController::getMeasureUnitByShopwareID($Unit->getId());
         // string
     }
     $prices = array();
     $ItemPrice = Shopware()->Models()->getRepository('Shopware\\Models\\Article\\Price');
     /** @var Shopware\Models\Article\Price $ItemPrice */
     foreach ($ItemPrice->findBy(array('customerGroupKey' => PlentymarketsConfig::getInstance()->getDefaultCustomerGroupKey(), 'articleDetailsId' => $MainDetail->getId())) as $ItemPrice) {
         $price = array();
         $price['to'] = $ItemPrice->getTo();
         $price['price'] = $ItemPrice->getPrice() * ($Tax->getTax() + 100) / 100;
         $price['rrp'] = $ItemPrice->getPseudoPrice() * ($Tax->getTax() + 100) / 100;
         $price['pp'] = $MainDetail->getPurchasePrice();
         $prices[$ItemPrice->getFrom()] = $price;
     }
     //
     ksort($prices);
     //
     $n = 0;
     foreach ($prices as $from => $p) {
         // The base price
         if ($from == 1) {
             $Object_ItemPriceSet->RRP = $p['rrp'];
             $Object_ItemPriceSet->Price = $p['price'];
             $Object_ItemPriceSet->PurchasePriceNet = $p['pp'];
         } else {
             $priceIndex = 'Price' . ($n + 5);
             $Object_ItemPriceSet->{$priceIndex} = $p['price'];
             $rebateLevel = 'RebateLevelPrice' . ($n + 5);
             $Object_ItemPriceSet->{$rebateLevel} = $from;
         }
         ++$n;
     }
     return $Object_ItemPriceSet;
 }
 public function testCanAssignOneToOneByInstance()
 {
     $article = new Article();
     $tax = new \Shopware\Models\Tax\Tax();
     $tax->setName('foobar');
     $attribute = new \Shopware\Models\Attribute\Article();
     $attribute->setAttr1('foo');
     $data = array('tax' => $tax, 'attribute' => $attribute);
     $article->fromArray($data);
     $this->assertSame($tax, $article->getTax());
     $this->assertSame($attribute, $article->getAttribute());
 }
Esempio n. 3
0
    /**
     * @param array $data
     * @param \Shopware\Models\Article\Article $article
     * @return array
     */
    protected function prepareMainPricesAssociatedData($data, ArticleModel $article)
    {
        if (empty($data['mainDetail']['prices'])) {
            return $data;
        }

        if (isset($data['tax'])) {
            $tax = $data['tax'];
        } else {
            $tax = $article->getTax();
        }

        $data['mainDetail']['prices'] = $this->preparePricesAssociatedData($data['mainDetail']['prices'], $article, $article->getMainDetail(), $tax);
        return $data;
    }
 /**
  * {@inheritDoc}
  */
 public function getTax()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getTax', array());
     return parent::getTax();
 }