コード例 #1
0
ファイル: Article.php プロジェクト: GerDner/luck-docker
 /**
  * @param \Shopware\Models\Article\Detail|array|null $mainDetail
  * @return \Shopware\Models\Article\Detail
  */
 public function setMainDetail($mainDetail)
 {
     $return = $this->setOneToOne($mainDetail, '\\Shopware\\Models\\Article\\Detail', 'mainDetail', 'article');
     if ($this->mainDetail instanceof \Shopware\Models\Article\Detail) {
         $this->mainDetail->setKind(1);
     }
     return $return;
 }
コード例 #2
0
ファイル: Article.php プロジェクト: nhp/shopware-4
    /**
     * @param array $variantData
     * @param \Shopware\Models\Article\Article $article
     * @param \Shopware\Models\Article\Detail $variant
     * @throws \Shopware\Components\Api\Exception\CustomValidationException
     * @return array
     */
    protected function prepareVariantAttributeAssociatedData($variantData, ArticleModel $article, \Shopware\Models\Article\Detail $variant)
    {
        if (!$variant->getAttribute()) {
            $variantData['attribute']['article'] = $article;
        }

        if (!isset($variantData['attribute'])) {
            return $variantData;
        }

        $variantData['attribute']['article'] = $article;
        return $variantData;
    }
コード例 #3
0
ファイル: Article.php プロジェクト: Goucher/shopware
 /**
  * Helper method which swaps the translations of the newMainDetail and the oldMainDetail
  * Needed because mainDetails' translations are stored for the article, not for the variant itself
  * @param \Shopware\Models\Article\Detail $newMainDetail
  * @param \Shopware\Models\Article\Detail $oldMainDetail
  */
 private function swapDetailTranslations($newMainDetail, $oldMainDetail)
 {
     $articleId = $oldMainDetail->getArticle()->getId();
     // Get available translations for the old mainDetail (stored on the article)
     $sql = "\n            SELECT objectlanguage, objectdata\n            FROM s_core_translations\n            WHERE objecttype = 'article' AND objectkey = ?\n        ";
     $oldTranslations = Shopware()->Db()->fetchAssoc($sql, array($articleId));
     // Get available translations for the new mainDetail (stored for the detail)
     $sql = "\n            SELECT objectlanguage, objectdata\n            FROM s_core_translations\n            WHERE objecttype='variant' AND objectkey = ?\n        ";
     $newTranslations = Shopware()->Db()->fetchAssoc($sql, array($newMainDetail->getId()));
     // We need to determine which of the old article translations can be used for the translation of the
     // variant which was the mainDetail before.
     // We'll get a list of translatable variant fields from the variant which is going to become the new mainDetail
     $translatedFields = array();
     foreach ($newTranslations as $values) {
         $data = $values['objectdata'];
         foreach (unserialize($data) as $field => $translation) {
             if (!array_key_exists($field, $translatedFields)) {
                 $translatedFields[$field] = true;
             }
         }
     }
     // Save the old article translation as new variant translations
     foreach ($oldTranslations as $language => $values) {
         $data = unserialize($values['objectdata']);
         $newData = array_intersect_key($data, $translatedFields);
         $this->getTranslationComponent()->write($language, 'variant', $oldMainDetail->getId(), $newData, false);
     }
     // Save the new mainDetail translations as article translations
     foreach ($newTranslations as $language => $values) {
         $data = unserialize($values['objectdata']);
         $newData = array_intersect_key($data, $translatedFields);
         // We need to check and include old translations, as an article
         // translation is a superset of a variant translation
         if ($oldValues = $oldTranslations[$language]) {
             $oldData = unserialize($oldValues['objectdata']);
             $newData = array_merge($oldData, $newData);
         }
         $this->getTranslationComponent()->write($language, 'article', $articleId, $newData, false);
     }
 }
コード例 #4
0
 /**
  * {@inheritDoc}
  */
 public function setManyToOne($data, $model, $property)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setManyToOne', array($data, $model, $property));
     return parent::setManyToOne($data, $model, $property);
 }
コード例 #5
0
ファイル: CanceledOrder.php プロジェクト: GerDner/luck-docker
 /**
  * @param \Shopware\Models\Article\Detail $variant
  * @param Order $order
  * @return null|\Shopware\Models\Order\Detail
  */
 private function getOrderPositionByProduct(\Shopware\Models\Article\Detail $variant, Order $order)
 {
     /**@var $detail \Shopware\Models\Order\Detail*/
     foreach ($order->getDetails() as $detail) {
         if (!$this->isProductPosition($detail)) {
             continue;
         }
         if ($detail->getArticleNumber() === $variant->getNumber()) {
             return $detail;
         }
     }
     return null;
 }
コード例 #6
0
ファイル: SoapApi.php プロジェクト: Goucher/shopware
 /**
  * @param Detail $articleDetailModel
  * @return bool
  */
 private function deleteDetail(Detail $articleDetailModel)
 {
     $ordernumber = $articleDetailModel->getNumber();
     $sql = "DELETE FROM s_articles_details WHERE ordernumber = :num";
     try {
         $this->db->query($sql, array('num' => $ordernumber));
     } catch (\Exception $ex) {
         return false;
     }
     return true;
 }
コード例 #7
0
ファイル: Variant.php プロジェクト: ClaudioThomas/shopware-4
 /**
  * @param $data
  * @param ArticleModel $article
  * @param Detail $variant
  * @return mixed
  */
 protected function prepareAttributeAssociation($data, ArticleModel $article, Detail $variant)
 {
     if (!$variant->getAttribute()) {
         $data['attribute']['article'] = $article;
     }
     if (!isset($data['attribute'])) {
         return $data;
     }
     $data['attribute']['article'] = $article;
     return $data;
 }
コード例 #8
0
ファイル: Esd.php プロジェクト: ClaudioThomas/shopware-4
 /**
  * @param \Shopware\Models\Article\Detail $articleDetail
  */
 public function setArticleDetail(\Shopware\Models\Article\Detail $articleDetail)
 {
     $this->articleDetail = $articleDetail;
     $this->article = $articleDetail->getArticle();
 }
コード例 #9
0
ファイル: Article.php プロジェクト: GerDner/luck-docker
 /**
  * Checks if the passed article image is already created
  * as variant image.
  *
  * @param Detail $variant
  * @param Image $image
  * @return bool
  */
 protected function isVariantImageExist(Detail $variant, Image $image)
 {
     /**@var $variantImage Image */
     foreach ($variant->getImages() as $variantImage) {
         if ($variantImage->getParent()->getId() == $image->getId()) {
             return true;
         }
     }
     return false;
 }