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


PHP Product::unsetData方法代码示例

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


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

示例1: getSelectionFinalPrice

 /**
  * Obtain final price of selection in a bundle product
  *
  * @param ItemInterface $item
  * @param \Magento\Catalog\Model\Product $selectionProduct
  * @return float
  */
 public function getSelectionFinalPrice(ItemInterface $item, \Magento\Catalog\Model\Product $selectionProduct)
 {
     $selectionProduct->unsetData('final_price');
     $product = $item->getProduct();
     /** @var \Magento\Bundle\Model\Product\Price $price */
     $price = $product->getPriceModel();
     return $price->getSelectionFinalTotalPrice($product, $selectionProduct, $item->getQty(), $this->getSelectionQty($product, $selectionProduct->getSelectionId()), false, true);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Configuration.php

示例2: beforeSave

 /**
  * Prepare inventory data from custom attribute
  *
  * @param Product $object
  * @return void
  */
 public function beforeSave($object)
 {
     $stockData = $object->getData($this->getAttribute()->getAttributeCode());
     if (isset($stockData['qty']) && $stockData['qty'] === '') {
         $stockData['qty'] = null;
     }
     if ($object->getStockData() !== null || $stockData !== null) {
         $object->setStockData(array_replace((array) $object->getStockData(), (array) $stockData));
     }
     $object->unsetData($this->getAttribute()->getAttributeCode());
     parent::beforeSave($object);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:Stock.php

示例3: beforeInitializeLinks

 /**
  * Initialize grouped product links
  *
  * @param \Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks $subject
  * @param \Magento\Catalog\Model\Product $product
  * @param array $links
  *
  * @return \Magento\Catalog\Model\Product
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function beforeInitializeLinks(\Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks $subject, \Magento\Catalog\Model\Product $product, array $links)
 {
     if ($product->getTypeId() == TypeGrouped::TYPE_CODE && !$product->getGroupedReadonly()) {
         $links = isset($links[self::TYPE_NAME]) ? $links[self::TYPE_NAME] : $product->getGroupedLinkData();
         if ($product->getGroupedLinkData()) {
             $links = array_merge($links, $product->getGroupedLinkData());
         }
         $newLinks = [];
         $existingLinks = $product->getProductLinks();
         $product->unsetData('_cache_instance_associated_products');
         if ($links) {
             foreach ($links as $linkId => $linkRaw) {
                 /** @var \Magento\Catalog\Api\Data\ProductLinkInterface $productLink */
                 $productLink = $this->productLinkFactory->create();
                 if (isset($linkRaw['id'])) {
                     $productId = $linkRaw['id'];
                 } else {
                     $productId = $linkId;
                 }
                 $linkedProduct = $this->productRepository->getById($productId);
                 $productLink->setSku($product->getSku())->setLinkType(self::TYPE_NAME)->setLinkedProductSku($linkedProduct->getSku())->setLinkedProductType($linkedProduct->getTypeId())->setPosition($linkRaw['position'])->getExtensionAttributes()->setQty($linkRaw['qty']);
                 if (isset($linkRaw['custom_attributes'])) {
                     $productLinkExtension = $productLink->getExtensionAttributes();
                     if ($productLinkExtension === null) {
                         $productLinkExtension = $this->productLinkExtensionFactory->create();
                     }
                     foreach ($linkRaw['custom_attributes'] as $option) {
                         $name = $option['attribute_code'];
                         $value = $option['value'];
                         $setterName = 'set' . ucfirst($name);
                         // Check if setter exists
                         if (method_exists($productLinkExtension, $setterName)) {
                             call_user_func([$productLinkExtension, $setterName], $value);
                         }
                     }
                     $productLink->setExtensionAttributes($productLinkExtension);
                 }
                 $newLinks[] = $productLink;
             }
         }
         $existingLinks = $this->removeUnExistingLinks($existingLinks, $newLinks);
         $product->setProductLinks(array_merge($existingLinks, $newLinks));
     }
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:55,代码来源:Grouped.php

示例4: testIsSalable

 public function testIsSalable()
 {
     $this->_product->unsetData('is_salable');
     $this->assertTrue($this->_model->isSalable($this->_product));
 }
开发者ID:nja78,项目名称:magento2,代码行数:5,代码来源:ConfigurableTest.php

示例5: resetConfigurableAttributes

 /**
  * Reset the cached configurable attributes of a product
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return $this
  */
 public function resetConfigurableAttributes($product)
 {
     $product->unsetData($this->_configurableAttributes);
     return $this;
 }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:11,代码来源:Configurable.php

示例6: dropRelationProductsCache

 /**
  * @param \Magento\Catalog\Model\Product $product
  * @return void
  */
 private function dropRelationProductsCache(\Magento\Catalog\Model\Product $product)
 {
     $product->unsetData('up_sell_products');
     $product->unsetData('up_sell_products_ids');
     $product->unsetData('related_products');
     $product->unsetData('related_products_ids');
     $product->unsetData('cross_sell_products');
     $product->unsetData('cross_sell_products_ids');
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:13,代码来源:Helper.php

示例7: unsetData

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

示例8: resetConfigurableAttributes

 /**
  * Reset the cached configurable attributes of a product
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return $this
  */
 public function resetConfigurableAttributes($product)
 {
     $metadata = $this->getMetadataPool()->getMetadata(ProductInterface::class);
     $productId = $product->getData($metadata->getLinkField());
     $product->unsetData($this->_configurableAttributes);
     $cacheId = __CLASS__ . $productId . '_' . $product->getStoreId();
     $this->getCache()->remove($cacheId);
     $this->getCache()->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [self::TYPE_CODE . '_' . $productId]);
     return $this;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:Configurable.php


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