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


PHP Product::setStoreId方法代码示例

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


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

示例1: testGetStoreId

 public function testGetStoreId()
 {
     $this->model->setStoreId(3);
     $this->assertEquals(3, $this->model->getStoreId());
     $this->model->unsStoreId();
     $this->store->expects($this->once())->method('getId')->will($this->returnValue(5));
     $this->assertEquals(5, $this->model->getStoreId());
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:8,代码来源:ProductTest.php

示例2: prepareProducts

 protected function prepareProducts()
 {
     $product = $this->product->loadByAttribute('sku', 'simple');
     $product->load($product->getId());
     $this->product = $product;
     $this->product->setStoreId(0)->setData('test_attribute', 'test_attribute_value')->save();
     $this->productSecond = clone $this->product;
     $this->productSecond->setId(null)->setUrlKey('product-second')->save();
     $this->productThird = clone $this->product;
     $this->productThird->setId(null)->setUrlKey('product-third')->setData('test_attribute', 'NO_test_attribute_value')->save();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:11,代码来源:IndexerBuilderTest.php

示例3: _fillSimpleProductData

 /**
  * Fill simple product data during generation
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Catalog\Model\Product $parentProduct
  * @param array $postData
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _fillSimpleProductData(\Magento\Catalog\Model\Product $product, \Magento\Catalog\Model\Product $parentProduct, $postData)
 {
     $product->setStoreId(\Magento\Store\Model\Store::DEFAULT_STORE_ID)->setTypeId($postData['weight'] ? \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE : \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL)->setAttributeSetId($parentProduct->getNewVariationsAttributeSetId());
     foreach ($product->getTypeInstance()->getEditableAttributes($product) as $attribute) {
         if ($attribute->getIsUnique() || $attribute->getAttributeCode() == 'url_key' || $attribute->getFrontend()->getInputType() == 'gallery' || $attribute->getFrontend()->getInputType() == 'media_image' || !$attribute->getIsVisible()) {
             continue;
         }
         $product->setData($attribute->getAttributeCode(), $parentProduct->getData($attribute->getAttributeCode()));
     }
     $postData['stock_data'] = $parentProduct->getStockData();
     $postData['stock_data']['manage_stock'] = $postData['quantity_and_stock_status']['qty'] === '' ? 0 : 1;
     if (!isset($postData['stock_data']['is_in_stock'])) {
         $stockStatus = $parentProduct->getQuantityAndStockStatus();
         $postData['stock_data']['is_in_stock'] = $stockStatus['is_in_stock'];
     }
     $configDefaultValue = $this->stockConfiguration->getManageStock($product->getStoreId());
     $postData['stock_data']['use_config_manage_stock'] = $postData['stock_data']['manage_stock'] == $configDefaultValue ? 1 : 0;
     if (!empty($postData['image'])) {
         $postData['small_image'] = $postData['thumbnail'] = $postData['image'];
         $postData['media_gallery']['images'][] = ['position' => 1, 'file' => $postData['image'], 'disabled' => 0, 'label' => ''];
     }
     $product->addData($postData)->setWebsiteIds($parentProduct->getWebsiteIds())->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_NOT_VISIBLE);
 }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:32,代码来源:Configurable.php

示例4: setProduct

 /**
  * Setup product for quote item
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return $this
  */
 public function setProduct($product)
 {
     if ($this->getQuote()) {
         $product->setStoreId($this->getQuote()->getStoreId());
         $product->setCustomerGroupId($this->getQuote()->getCustomerGroupId());
     }
     $this->setData('product', $product)->setProductId($product->getId())->setProductType($product->getTypeId())->setSku($this->getProduct()->getSku())->setName($product->getName())->setWeight($this->getProduct()->getWeight())->setTaxClassId($product->getTaxClassId())->setBaseCost($product->getCost());
     $stockItem = $this->stockRegistry->getStockItem($product->getId(), $product->getStore()->getWebsiteId());
     $this->setIsQtyDecimal($stockItem->getIsQtyDecimal());
     $this->_eventManager->dispatch('sales_quote_item_set_product', ['product' => $product, 'quote_item' => $this]);
     return $this;
 }
开发者ID:uibar,项目名称:lavinia2,代码行数:18,代码来源:Item.php

示例5: fillSimpleProductData

 /**
  * Fill simple product data during generation
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Catalog\Model\Product $parentProduct
  * @param array $postData
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  *
  * @return void
  */
 protected function fillSimpleProductData(\Magento\Catalog\Model\Product $product, \Magento\Catalog\Model\Product $parentProduct, $postData)
 {
     $product->setStoreId(\Magento\Store\Model\Store::DEFAULT_STORE_ID)->setTypeId($postData['weight'] ? ProductType::TYPE_SIMPLE : ProductType::TYPE_VIRTUAL)->setAttributeSetId($parentProduct->getNewVariationsAttributeSetId());
     foreach ($product->getTypeInstance()->getSetAttributes($product) as $attribute) {
         if ($attribute->getIsUnique() || $attribute->getAttributeCode() == 'url_key' || $attribute->getFrontend()->getInputType() == 'gallery' || $attribute->getFrontend()->getInputType() == 'media_image' || !$attribute->getIsVisible()) {
             continue;
         }
         $product->setData($attribute->getAttributeCode(), $parentProduct->getData($attribute->getAttributeCode()));
     }
     $keysFilter = ['item_id', 'product_id', 'stock_id', 'type_id', 'website_id'];
     $postData['stock_data'] = array_diff_key((array) $parentProduct->getStockData(), array_flip($keysFilter));
     if (!isset($postData['stock_data']['is_in_stock'])) {
         $stockStatus = $parentProduct->getQuantityAndStockStatus();
         $postData['stock_data']['is_in_stock'] = $stockStatus['is_in_stock'];
     }
     $postData = $this->processMediaGallery($product, $postData);
     $postData['status'] = isset($postData['status']) ? $postData['status'] : \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED;
     $product->addData($postData)->setWebsiteIds($parentProduct->getWebsiteIds())->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_NOT_VISIBLE);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:30,代码来源:VariationHandler.php

示例6: setStoreId

 /**
  * {@inheritdoc}
  */
 public function setStoreId($storeId)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'setStoreId');
     if (!$pluginInfo) {
         return parent::setStoreId($storeId);
     } else {
         return $this->___callPlugins('setStoreId', func_get_args(), $pluginInfo);
     }
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:12,代码来源:Interceptor.php

示例7: setProduct

 /**
  * Setup product for quote item
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return $this
  */
 public function setProduct($product)
 {
     if ($this->getQuote()) {
         $product->setStoreId($this->getQuote()->getStoreId());
         $product->setCustomerGroupId($this->getQuote()->getCustomerGroupId());
     }
     $this->setData('product', $product)->setProductId($product->getId())->setProductType($product->getTypeId())->setSku($this->getProduct()->getSku())->setName($product->getName())->setWeight($this->getProduct()->getWeight())->setTaxClassId($product->getTaxClassId())->setBaseCost($product->getCost());
     /** @var \Magento\CatalogInventory\Service\V1\Data\StockItem $stockItemDo */
     $stockItemDo = $this->stockItemService->getStockItem($product->getId());
     if ($stockItemDo->getStockId()) {
         $this->setIsQtyDecimal($stockItemDo->getIsQtyDecimal());
     }
     $this->_eventManager->dispatch('sales_quote_item_set_product', array('product' => $product, 'quote_item' => $this));
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:21,代码来源:Item.php

示例8: setStoreToProduct

 /**
  * @param \Magento\Catalog\Model\Product $product
  * @param array $rowData
  * @return void
  */
 protected function setStoreToProduct(\Magento\Catalog\Model\Product $product, array $rowData)
 {
     if (!empty($rowData[ImportProduct::COL_STORE]) && ($storeId = $this->import->getStoreIdByCode($rowData[ImportProduct::COL_STORE]))) {
         $product->setStoreId($storeId);
     } elseif (!$product->hasData(\Magento\Catalog\Model\Product::STORE_ID)) {
         $product->setStoreId(Store::DEFAULT_STORE_ID);
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:AfterImportDataObserver.php


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