コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function removeCategoryFromProduct(ProductInterface $product, CategoryInterface $category)
 {
     if (!($productCategory = $this->findOneBy(array('category' => $category, 'product' => $product)))) {
         return;
     }
     $product->removeProductCategory($productCategory);
     $this->delete($productCategory);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function removeCollectionFromProduct(ProductInterface $product, CollectionInterface $collection)
 {
     if (!($productCollection = $this->findOneBy(array('collection' => $collection, 'product' => $product)))) {
         return;
     }
     $product->removeProductCollection($productCollection);
     $this->delete($productCollection);
 }
コード例 #3
0
ファイル: Facebook.php プロジェクト: Dicoding/ecommerce
 /**
  * @param SeoPageInterface $seoPage
  * @param ProductInterface $product
  */
 public function alterPage(SeoPageInterface $seoPage, ProductInterface $product)
 {
     $this->registerHeaders($seoPage);
     $seoPage->addMeta('property', 'og:type', 'og:product')->addMeta('property', 'og:title', $product->getName())->addMeta('property', 'og:description', $product->getDescription())->addMeta('property', 'og:url', $this->domain)->addMeta('property', 'product:price:amount', $this->numberHelper->formatDecimal($product->getPrice()))->addMeta('property', 'product:price:currency', $this->currencyDetector->getCurrency());
     // If a media is available, we add the opengraph image data
     if ($image = $product->getImage()) {
         $this->addImageInfo($image, $seoPage);
     }
 }
コード例 #4
0
ファイル: Facebook.php プロジェクト: sonata-project/ecommerce
 /**
  * @param SeoPageInterface $seoPage
  * @param ProductInterface $product
  */
 public function alterPage(SeoPageInterface $seoPage, ProductInterface $product)
 {
     $this->registerHeaders($seoPage);
     $seoPage->addMeta('property', 'og:type', 'og:product')->addMeta('property', 'og:title', $product->getName())->addMeta('property', 'og:description', $product->getDescription())->addMeta('property', 'og:url', $this->router->generate('sonata_product_view', array('slug' => $product->getSlug(), 'productId' => $product->getId()), UrlGeneratorInterface::ABSOLUTE_URL))->addMeta('property', 'product:price:amount', $this->numberHelper->formatDecimal($product->getPrice()))->addMeta('property', 'product:price:currency', $this->currencyDetector->getCurrency());
     // If a media is available, we add the opengraph image data
     if ($image = $product->getImage()) {
         $this->addImageInfo($image, $seoPage);
     }
 }
コード例 #5
0
ファイル: Twitter.php プロジェクト: kinkinweb/lhvb
 /**
  * Add the meta information.
  *
  * @param SeoPageInterface $seoPage
  * @param ProductInterface $product
  */
 public function alterPage(SeoPageInterface $seoPage, ProductInterface $product)
 {
     $seoPage->addMeta('name', 'twitter:card', 'product')->addMeta('name', 'twitter:title', $product->getName())->addMeta('name', 'twitter:description', substr($product->getDescription(), 0, 200))->addMeta('name', 'twitter:label1', 'Price')->addMeta('name', 'twitter:data1', $this->numberHelper->formatCurrency($product->getPrice(), $this->currencyDetector->getCurrency()))->addMeta('name', 'twitter:label2', 'SKU')->addMeta('name', 'twitter:data2', $product->getSku())->addMeta('name', 'twitter:site', $this->site)->addMeta('name', 'twitter:creator', $this->creator)->addMeta('name', 'twitter:domain', $this->domain);
     if ($image = $product->getImage()) {
         $provider = $this->mediaPool->getProvider($image->getProviderName());
         $seoPage->addMeta('property', 'twitter:image:src', $provider->generatePublicUrl($image, $this->mediaFormat));
     }
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function getPrice(ProductInterface $product, CurrencyInterface $currency, $vat = false)
 {
     $price = $product->getPrice();
     if ($vat && false === $product->isPriceIncludingVat()) {
         $price = $price * (1 + $product->getVatRate() / 100);
     }
     if (!$vat && true === $product->isPriceIncludingVat()) {
         $price = $price * (1 - $product->getVatRate() / 100);
     }
     return $price;
 }
コード例 #7
0
ファイル: BasketElement.php プロジェクト: lzdv/ecommerce
 /**
  * {@inheritdoc}
  */
 public function setProduct($productCode, ProductInterface $product)
 {
     $this->product = $product;
     $this->productId = $product->getId();
     $this->productCode = $productCode;
     $this->name = $product->getName();
     $this->price = $product->getPrice();
     $this->options = $product->getOptions();
 }
コード例 #8
0
 /**
  * {@inheritdoc}
  */
 public function addVariation(ProductInterface $variation)
 {
     $variation->setParent($this);
     $this->variations->add($variation);
 }
コード例 #9
0
 /**
  * @param ProductInterface $product
  * @param string|null      $currency
  */
 protected function updateSeoMeta(ProductInterface $product, $currency = null)
 {
     $seoPage = $this->get('sonata.seo.page');
     $seoPage->setTitle($product->getName());
     $this->get('sonata.product.seo.facebook')->alterPage($seoPage, $product, $currency);
     $this->get('sonata.product.seo.twitter')->alterPage($seoPage, $product, $currency);
 }
コード例 #10
0
ファイル: Basket.php プロジェクト: Dicoding/ecommerce
 /**
  * {@inheritdoc}
  */
 public function hasProduct(ProductInterface $product)
 {
     if (!array_key_exists($product->getId(), $this->positions)) {
         return false;
     }
     $pos = $this->positions[$product->getId()];
     foreach ($this->getBasketElements() as $basketElement) {
         if ($pos == $basketElement->getPosition()) {
             return true;
         }
     }
     return false;
 }
コード例 #11
0
ファイル: AddBasket.php プロジェクト: lzdv/ecommerce
 /**
  * Set the related product
  *
  * @param ProductInterface $product
  */
 public function setProduct(ProductInterface $product)
 {
     $this->productId = $product->getId();
     $this->product = $product;
 }
コード例 #12
0
 public function __construct(ProductInterface $product, CurrencyInterface $currency)
 {
     parent::__construct(sprintf("Product '%s' is not available for currency '%s'", $product->getName(), $currency->getLabel()));
 }
コード例 #13
0
 /**
  * {@inheritdoc}
  */
 public function getStockAvailable(ProductInterface $product)
 {
     return $product->getStock();
 }
コード例 #14
0
ファイル: Paypal.php プロジェクト: sonata-project/ecommerce
 /**
  * {@inheritdoc}
  */
 public function isAddableProduct(BasketInterface $basket, ProductInterface $product)
 {
     if (!$product->isRecurrentPayment()) {
         return true;
     }
     return false;
 }
コード例 #15
0
ファイル: LoadProductData.php プロジェクト: plusteams/xxxx
 /**
  * @param ProductInterface $product
  *
  * @return object|\Sonata\MediaBundle\Model\MediaInterface
  */
 protected function getGalleryForProduct(ProductInterface $product)
 {
     $galleryReference = sprintf("gallery_%s", $product->getSku());
     if ($this->hasReference($galleryReference)) {
         return $this->getReference($galleryReference);
     }
     $gallery = $this->getGalleryManager()->create();
     $gallery->setName($product->getSlug());
     $gallery->setEnabled(true);
     $gallery->setDefaultFormat('product_catalog_preview');
     $gallery->setContext('product_catalog');
     $this->setReference($galleryReference, $gallery);
     $this->getGalleryManager()->update($gallery);
     $product->setGallery($gallery);
     return $gallery;
 }