当前位置: 首页>>代码示例>>PHP>>正文


PHP Product::getStore方法代码示例

本文整理汇总了PHP中Magento\Catalog\Model\Product::getStore方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::getStore方法的具体用法?PHP Product::getStore怎么用?PHP Product::getStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Catalog\Model\Product的用法示例。


在下文中一共展示了Product::getStore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: afterLoad

 /**
  * Set inventory data to custom attribute
  *
  * @param Product $object
  * @return $this
  */
 public function afterLoad($object)
 {
     $stockItem = $this->stockRegistry->getStockItem($object->getId(), $object->getStore()->getWebsiteId());
     $object->setData($this->getAttribute()->getAttributeCode(), ['is_in_stock' => $stockItem->getIsInStock(), 'qty' => $stockItem->getQty()]);
     return parent::afterLoad($object);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:Stock.php

示例2: convertAttribute

 /**
  * Set current attribute to entry (for specified product)
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Framework\Gdata\Gshopping\Entry $entry
  * @return \Magento\Framework\Gdata\Gshopping\Entry
  */
 public function convertAttribute($product, $entry)
 {
     $url = $product->getProductUrl(false);
     if ($url) {
         $isStoreInUrl = $this->_scopeConfig->isSetFlag(\Magento\Store\Model\Store::XML_PATH_STORE_IN_URL, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
         if (!$isStoreInUrl) {
             $urlInfo = parse_url($url);
             $store = $product->getStore()->getCode();
             if (isset($urlInfo['query']) && $urlInfo['query'] != '') {
                 $url .= '&___store=' . $store;
             } else {
                 $url .= '?___store=' . $store;
             }
         }
         $links = $entry->getLink();
         if (!is_array($links)) {
             $links = [];
         }
         $link = $entry->getService()->newLink();
         $link->setHref($url);
         $link->setRel('alternate');
         $link->setType('text/html');
         if ($product->getName()) {
             $link->setTitle($product->getName());
         }
         $links[0] = $link;
         $entry->setLink($links);
     }
     return $entry;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:37,代码来源:Link.php

示例3: build

 /**
  * Copy product inventory data (used for product duplicate functionality)
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Catalog\Model\Product $duplicate
  * @return void
  */
 public function build(\Magento\Catalog\Model\Product $product, \Magento\Catalog\Model\Product $duplicate)
 {
     $stockData = ['use_config_min_qty' => 1, 'use_config_min_sale_qty' => 1, 'use_config_max_sale_qty' => 1, 'use_config_backorders' => 1, 'use_config_notify_stock_qty' => 1];
     $currentStockItemDo = $this->stockRegistry->getStockItem($product->getId(), $product->getStore()->getWebsiteId());
     if ($currentStockItemDo->getItemId()) {
         $stockData += ['use_config_enable_qty_inc' => $currentStockItemDo->getUseConfigEnableQtyInc(), 'enable_qty_increments' => $currentStockItemDo->getEnableQtyIncrements(), 'use_config_qty_increments' => $currentStockItemDo->getUseConfigQtyIncrements(), 'qty_increments' => $currentStockItemDo->getQtyIncrements()];
     }
     $duplicate->setStockData($stockData);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:CatalogInventory.php

示例4: assignStatusToProduct

 /**
  * Assign stock status information to product
  *
  * @param Product $product
  * @param int $stockStatus
  * @return void
  */
 public function assignStatusToProduct(Product $product, $stockStatus = null)
 {
     if ($stockStatus === null) {
         $websiteId = $product->getStore()->getWebsiteId();
         $stockStatus = $this->stockRegistryProvider->getStockStatus($product->getId(), $websiteId);
         $status = $stockStatus->getStockStatus();
     }
     $product->setIsSalable($status);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:Stock.php

示例5: getUrl

 /**
  * Returns url to product image
  *
  * @param  \Magento\Catalog\Model\Product $product
  *
  * @return string|false
  */
 public function getUrl($product)
 {
     $image = $product->getData($this->getAttribute()->getAttributeCode());
     $url = false;
     if (!empty($image)) {
         $url = $this->_storeManager->getStore($product->getStore())->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . 'catalog/product/' . $image;
     }
     return $url;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:Image.php

示例6: assignStatusToProduct

 /**
  * Assign stock status information to product
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param int $stockStatus
  * @return void
  */
 public function assignStatusToProduct(\Magento\Catalog\Model\Product $product, $stockStatus = null)
 {
     if ($stockStatus === null) {
         $websiteId = $product->getStore()->getWebsiteId();
         $stockStatus = $this->stockRegistry->getStockStatus($product->getId(), $websiteId);
         $status = $stockStatus->getStockStatus();
     }
     $product->setIsSalable($status);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:16,代码来源:Stock.php

示例7: getProductStockQty

 /**
  * Retrieve product stock qty
  *
  * @param Product $product
  * @return float
  */
 public function getProductStockQty($product)
 {
     return $this->stockState->getStockQty($product->getId(), $product->getStore()->getWebsiteId());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:AbstractStockqty.php

示例8: _applySpecialPrice

 /**
  * Apply special price for product if not return price that was before
  *
  * @param   Product $product
  * @param   float $finalPrice
  * @return  float
  */
 protected function _applySpecialPrice($product, $finalPrice)
 {
     return $this->calculateSpecialPrice($finalPrice, $product->getSpecialPrice(), $product->getSpecialFromDate(), $product->getSpecialToDate(), $product->getStore());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:11,代码来源:Price.php

示例9: getAmountForDisplay

    /**
     * Returns amount to display
     *
     * @param \Magento\Catalog\Model\Product $product
     * @return int
     */
    public function getAmountForDisplay($product)
    {
        /** @var \Magento\Store\Model\Store $store */
        $store = $product->getStore();

        if ($this->isEnabled($store)) {
            return $this->_weeeTax->getWeeeAmount($product, null, null, null, $this->typeOfDisplay(1));
        }
        return 0;
    }
开发者ID:nblair,项目名称:magescotch,代码行数:16,代码来源:Data.php

示例10: setDataToModel

 /**
  * @param ComponentInterface $model
  * @param array $data
  * @param Product $product
  * @return void
  */
 protected function setDataToModel(ComponentInterface $model, array $data, Product $product)
 {
     $model->setData($data)->setLinkType($data['type'])->setProductId($product->getData($this->metadataPool->getMetadata(ProductInterface::class)->getLinkField()))->setStoreId($product->getStoreId())->setWebsiteId($product->getStore()->getWebsiteId())->setProductWebsiteIds($product->getWebsiteIds());
     if (null === $model->getPrice()) {
         $model->setPrice(0);
     }
     if ($model->getIsUnlimited()) {
         $model->setNumberOfDownloads(0);
     }
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:16,代码来源:Link.php

示例11: getProductStockQty

 /**
  * @param Product $product
  * @return float
  */
 public function getProductStockQty(Product $product)
 {
     return $this->stockRegistry->getStockItem($product->getId(), $product->getStore()->getWebsiteId())->getQty();
 }
开发者ID:nja78,项目名称:magento2,代码行数:8,代码来源:Matrix.php

示例12: getLinks

 /**
  * Get downloadable product links
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return array
  */
 public function getLinks($product)
 {
     if (is_null($product->getDownloadableLinks())) {
         $_linkCollection = $this->_linksFactory->create()->addProductToFilter($product->getId())->addTitleToResult($product->getStoreId())->addPriceToResult($product->getStore()->getWebsiteId());
         $linksCollectionById = array();
         foreach ($_linkCollection as $link) {
             /* @var \Magento\Downloadable\Model\Link $link */
             $link->setProduct($product);
             $linksCollectionById[$link->getId()] = $link;
         }
         $product->setDownloadableLinks($linksCollectionById);
     }
     return $product->getDownloadableLinks();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:20,代码来源:Type.php

示例13: assignProduct

 /**
  * Assign Stock Status to Product
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param int $stockId
  * @param int $stockStatus
  * @return $this
  */
 public function assignProduct(\Magento\Catalog\Model\Product $product, $stockId = Stock::DEFAULT_STOCK_ID, $stockStatus = null)
 {
     if (is_null($stockStatus)) {
         $websiteId = $product->getStore()->getWebsiteId();
         $status = $this->getProductStockStatus($product->getId(), $websiteId, $stockId);
         $stockStatus = isset($status[$product->getId()]) ? $status[$product->getId()] : null;
     }
     $product->setIsSalable($stockStatus);
     return $this;
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:18,代码来源:Status.php

示例14: getLinks

 /**
  * Get downloadable product links
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return \Magento\Downloadable\Model\Link[]
  */
 public function getLinks($product)
 {
     if ($product->getDownloadableLinks() === null) {
         /** @var \Magento\Downloadable\Model\Resource\Link\Collection $linkCollection */
         $linkCollection = $this->_linksFactory->create()->addProductToFilter($product->getId())->addTitleToResult($product->getStoreId())->addPriceToResult($product->getStore()->getWebsiteId());
         $this->extensionAttributesJoinProcessor->process($linkCollection);
         $linksCollectionById = [];
         foreach ($linkCollection as $link) {
             /* @var \Magento\Downloadable\Model\Link $link */
             $link->setProduct($product);
             $linksCollectionById[$link->getId()] = $link;
         }
         $product->setDownloadableLinks($linksCollectionById);
     }
     return $product->getDownloadableLinks();
 }
开发者ID:nja78,项目名称:magento2,代码行数:22,代码来源:Type.php

示例15: handlePrice

 protected function handlePrice(Product &$product, $sub_products, &$customData)
 {
     $store = $product->getStore();
     $type = $product->getTypeId();
     $fields = $this->getFields($store);
     $customer_groups_enabled = $this->config->isCustomerGroupsEnabled($product->getStoreId());
     $currencies = $this->currencyHelper->getConfigAllowCurrencies();
     $baseCurrencyCode = $store->getBaseCurrencyCode();
     $groups = [];
     if ($customer_groups_enabled) {
         $groups = $this->objectManager->create('Magento\\Customer\\Model\\ResourceModel\\Group\\Collection');
     }
     foreach ($fields as $field => $with_tax) {
         $customData[$field] = [];
         foreach ($currencies as $currency_code) {
             $customData[$field][$currency_code] = [];
             $price = (double) $this->catalogHelper->getTaxPrice($product, $product->getPrice(), $with_tax, null, null, null, $product->getStore(), null);
             $price = $this->currencyDirectory->currencyConvert($price, $baseCurrencyCode, $currency_code);
             $customData[$field][$currency_code]['default'] = $price;
             $customData[$field][$currency_code]['default_formated'] = $this->formatPrice($price, false, $currency_code);
             $special_price = (double) $this->catalogHelper->getTaxPrice($product, $product->getFinalPrice(), $with_tax, null, null, null, $product->getStore(), null);
             $special_price = $this->currencyDirectory->currencyConvert($special_price, $baseCurrencyCode, $currency_code);
             if ($customer_groups_enabled) {
                 // If fetch special price for groups
                 foreach ($groups as $group) {
                     $group_id = (int) $group->getData('customer_group_id');
                     $product->setCustomerGroupId($group_id);
                     $discounted_price = $product->getPriceModel()->getFinalPrice(1, $product);
                     $discounted_price = $this->currencyDirectory->currencyConvert($discounted_price, $baseCurrencyCode, $currency_code);
                     if ($discounted_price !== false) {
                         $customData[$field][$currency_code]['group_' . $group_id] = (double) $this->catalogHelper->getTaxPrice($product, $discounted_price, $with_tax, null, null, null, $product->getStore(), null);
                         $customData[$field][$currency_code]['group_' . $group_id] = $this->currencyDirectory->currencyConvert($customData[$field][$currency_code]['group_' . $group_id], $baseCurrencyCode, $currency_code);
                         $customData[$field][$currency_code]['group_' . $group_id . '_formated'] = $this->formatPrice($customData[$field][$currency_code]['group_' . $group_id], false, $currency_code);
                     } else {
                         $customData[$field][$currency_code]['group_' . $group_id] = $customData[$field][$currency_code]['default'];
                         $customData[$field][$currency_code]['group_' . $group_id . '_formated'] = $customData[$field][$currency_code]['default_formated'];
                     }
                 }
                 $product->setCustomerGroupId(null);
             }
             $customData[$field][$currency_code]['special_from_date'] = strtotime($product->getSpecialFromDate());
             $customData[$field][$currency_code]['special_to_date'] = strtotime($product->getSpecialToDate());
             if ($customer_groups_enabled) {
                 foreach ($groups as $group) {
                     $group_id = (int) $group->getData('customer_group_id');
                     if ($special_price && $special_price < $customData[$field][$currency_code]['group_' . $group_id]) {
                         $customData[$field][$currency_code]['group_' . $group_id] = $special_price;
                         $customData[$field][$currency_code]['group_' . $group_id . '_formated'] = $this->formatPrice($special_price, false, $currency_code);
                     }
                 }
             } else {
                 if ($special_price && $special_price < $customData[$field][$currency_code]['default']) {
                     $customData[$field][$currency_code]['default_original_formated'] = $customData[$field][$currency_code]['default_formated'];
                     $customData[$field][$currency_code]['default'] = $special_price;
                     $customData[$field][$currency_code]['default_formated'] = $this->formatPrice($special_price, false, $currency_code);
                 }
             }
             if ($type == 'configurable' || $type == 'grouped' || $type == 'bundle') {
                 $min = PHP_INT_MAX;
                 $max = 0;
                 if ($type == 'bundle') {
                     $_priceModel = $product->getPriceModel();
                     list($min, $max) = $_priceModel->getTotalPrices($product, null, $with_tax, true);
                 }
                 if ($type == 'grouped' || $type == 'configurable') {
                     if (count($sub_products) > 0) {
                         foreach ($sub_products as $sub_product) {
                             $price = (double) $this->catalogHelper->getTaxPrice($product, $sub_product->getFinalPrice(), $with_tax, null, null, null, $product->getStore(), null);
                             $min = min($min, $price);
                             $max = max($max, $price);
                         }
                     } else {
                         $min = $max;
                     }
                     // avoid to have PHP_INT_MAX in case of no subproducts (Corner case of visibility and stock options)
                 }
                 if ($min != $max) {
                     $min = $this->currencyDirectory->currencyConvert($min, $baseCurrencyCode, $currency_code);
                     $max = $this->currencyDirectory->currencyConvert($max, $baseCurrencyCode, $currency_code);
                     $dashed_format = $this->formatPrice($min, false, $currency_code) . ' - ' . $this->formatPrice($max, false, $currency_code);
                     if (isset($customData[$field][$currency_code]['default_original_formated']) === false || $min <= $customData[$field][$currency_code]['default']) {
                         $customData[$field][$currency_code]['default_formated'] = $dashed_format;
                         //// Do not keep special price that is already taken into account in min max
                         unset($customData['price']['special_from_date']);
                         unset($customData['price']['special_to_date']);
                         unset($customData['price']['default_original_formated']);
                         $customData[$field][$currency_code]['default'] = 0;
                         // will be reset just after
                     }
                     if ($customer_groups_enabled) {
                         foreach ($groups as $group) {
                             $group_id = (int) $group->getData('customer_group_id');
                             if ($min != $max && $min <= $customData[$field][$currency_code]['group_' . $group_id]) {
                                 $customData[$field][$currency_code]['group_' . $group_id] = 0;
                                 $customData[$field][$currency_code]['group_' . $group_id . '_formated'] = $dashed_format;
                             }
                         }
                     }
                 }
                 if ($customData[$field][$currency_code]['default'] == 0) {
//.........这里部分代码省略.........
开发者ID:algolia,项目名称:algoliasearch-magento-2,代码行数:101,代码来源:ProductHelper.php


注:本文中的Magento\Catalog\Model\Product::getStore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。