예제 #1
0
 /**
  * Retrieve websites
  *
  * @param ProductInterface $product
  * @param EavAttribute $eavAttribute
  * @return array
  */
 public function getWebsites(ProductInterface $product, EavAttribute $eavAttribute)
 {
     if (null !== $this->websites) {
         return $this->websites;
     }
     $websites = [['value' => 0, 'label' => $this->formatLabel(__('All Websites'), $this->directoryHelper->getBaseCurrencyCode())]];
     if ($this->storeManager->hasSingleStore() || $eavAttribute->getEntityAttribute() && $eavAttribute->getEntityAttribute()->isScopeGlobal()) {
         return $this->websites = $websites;
     }
     if ($storeId = $this->locator->getStore()->getId()) {
         /** @var WebsiteInterface $website */
         $website = $this->storeManager->getStore($storeId)->getWebsite();
         $websites[$website->getId()] = ['value' => $website->getId(), 'label' => $this->formatLabel($website->getName(), $website->getConfig(Currency::XML_PATH_CURRENCY_BASE))];
     } else {
         /** @var WebsiteInterface $website */
         foreach ($this->storeManager->getWebsites() as $website) {
             if (!in_array($website->getId(), $product->getWebsiteIds())) {
                 continue;
             }
             $websites[$website->getId()] = ['value' => $website->getId(), 'label' => $this->formatLabel($website->getName(), $website->getConfig(Currency::XML_PATH_CURRENCY_BASE))];
         }
     }
     return $this->websites = $websites;
 }