コード例 #1
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));
     }
 }
コード例 #2
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;
 }