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


PHP Product::setTypeId方法代码示例

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


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

示例1: testGetPriceModel

 public function testGetPriceModel()
 {
     $this->_model->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE);
     $type = $this->_model->getPriceModel();
     $this->assertInstanceOf('Magento\\Bundle\\Model\\Product\\Price', $type);
     $this->assertSame($type, $this->_model->getPriceModel());
 }
开发者ID:aiesh,项目名称:magento2,代码行数:7,代码来源:ProductTest.php

示例2: testGetTypeId

 public function testGetTypeId()
 {
     $productType = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Type\\Virtual')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->productTypeInstanceMock->expects($this->exactly(2))->method('factory')->will($this->returnValue($productType));
     $this->model->getTypeInstance();
     $this->model->setTypeId('typeId');
     $this->model->getTypeInstance();
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:8,代码来源:ProductTest.php

示例3: processProduct

 /**
  * Process given product and change its type if needed
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return void
  */
 public function processProduct(Product $product)
 {
     if (in_array($product->getTypeId(), $this->compatibleTypes)) {
         $product->setTypeInstance(null);
         $productTypeId = $product->hasIsVirtual() ? \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL : \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE;
         $product->setTypeId($productTypeId);
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:TypeTransitionManager.php

示例4: aroundProcessProduct

 /**
  * Change product type to configurable if needed
  *
  * @param \Magento\Catalog\Model\Product\TypeTransitionManager $subject
  * @param Closure $proceed
  * @param \Magento\Catalog\Model\Product $product
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundProcessProduct(\Magento\Catalog\Model\Product\TypeTransitionManager $subject, Closure $proceed, \Magento\Catalog\Model\Product $product)
 {
     $attributes = $this->request->getParam('attributes');
     if (!empty($attributes)) {
         $product->setTypeId(\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE);
         return;
     }
     $proceed($product);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:Configurable.php

示例5: testValidateUniqueInputAttributeValue

 /**
  * @magentoDbIsolation enabled
  * @magentoDataFixture Magento/Catalog/_files/products_with_unique_input_attribute.php
  */
 public function testValidateUniqueInputAttributeValue()
 {
     /** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
     $attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute')->loadByCode(\Magento\Catalog\Model\Product::ENTITY, 'unique_input_attribute');
     $this->_model->setTypeId('simple')->setAttributeSetId(4)->setName('Simple Product with non-unique value')->setSku('some product SKU')->setPrice(10)->setMetaTitle('meta title')->setData($attribute->getAttributeCode(), 'unique value')->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)->setCollectExceptionMessages(true);
     $validationResult = $this->_model->validate();
     $this->assertCount(1, $validationResult);
     $this->assertContains('The value of attribute "' . $attribute->getDefaultFrontendLabel() . '" must be unique', $validationResult);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:ProductTest.php

示例6: testValidate

 public function testValidate()
 {
     $this->_model->setTypeId('simple')->setAttributeSetId(4)->setName('Simple Product')->setSku(uniqid('', true) . uniqid('', true) . uniqid('', true))->setPrice(10)->setMetaTitle('meta title')->setMetaKeyword('meta keyword')->setMetaDescription('meta description')->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)->setCollectExceptionMessages(true);
     $validationResult = $this->_model->validate();
     $this->assertEquals('SKU length should be 64 characters maximum.', $validationResult['sku']);
     unset($validationResult['sku']);
     foreach ($validationResult as $error) {
         $this->assertTrue($error);
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:ProductTest.php

示例7: aroundProcessProduct

 /**
  * Change product type to downloadable if needed
  *
  * @param \Magento\Catalog\Model\Product\TypeTransitionManager $subject
  * @param Closure $proceed
  * @param \Magento\Catalog\Model\Product $product
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundProcessProduct(\Magento\Catalog\Model\Product\TypeTransitionManager $subject, Closure $proceed, \Magento\Catalog\Model\Product $product)
 {
     $isTypeCompatible = in_array($product->getTypeId(), array(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL, \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE));
     $hasDownloadableData = $this->request->getPost('downloadable');
     if ($isTypeCompatible && $hasDownloadableData && $product->hasIsVirtual()) {
         $product->setTypeId(\Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE);
         return;
     }
     $proceed($product);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:19,代码来源:Downloadable.php

示例8: aroundValidate

 /**
  * Validate product data
  *
  * @param Product\Validator $subject
  * @param Closure $proceed
  * @param Product $product
  * @param RequestInterface $request
  * @param \Magento\Framework\DataObject $response
  * @return bool
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundValidate(\Magento\Catalog\Model\Product\Validator $subject, Closure $proceed, \Magento\Catalog\Model\Product $product, \Magento\Framework\App\RequestInterface $request, \Magento\Framework\DataObject $response)
 {
     if ($request->has('attributes')) {
         $product->setTypeId(\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE);
     }
     $result = $proceed($product, $request, $response);
     $variationProducts = (array) $request->getPost('variations-matrix');
     if ($variationProducts) {
         $validationResult = $this->_validateProductVariations($product, $variationProducts, $request);
         if (!empty($validationResult)) {
             $response->setError(true)->setMessage(__('Some product variations fields are not valid.'))->setAttributes($validationResult);
         }
     }
     return $result;
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:26,代码来源:Plugin.php

示例9: aroundProcessProduct

 /**
  * Change product type to downloadable if needed
  *
  * @param \Magento\Catalog\Model\Product\TypeTransitionManager $subject
  * @param Closure $proceed
  * @param \Magento\Catalog\Model\Product $product
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundProcessProduct(\Magento\Catalog\Model\Product\TypeTransitionManager $subject, Closure $proceed, \Magento\Catalog\Model\Product $product)
 {
     $isTypeCompatible = in_array($product->getTypeId(), [\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL, \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE]);
     $downloadableData = $this->request->getPost('downloadable');
     $hasDownloadableData = false;
     if (isset($downloadableData)) {
         foreach ($downloadableData as $data) {
             foreach ($data as $rowData) {
                 if (empty($rowData['is_delete'])) {
                     $hasDownloadableData = true;
                     break;
                 }
             }
         }
     }
     if ($isTypeCompatible && $hasDownloadableData && $product->hasIsVirtual()) {
         $product->setTypeId(\Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE);
         return;
     }
     $proceed($product);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:30,代码来源:Downloadable.php

示例10: testGetTypeId

 public function testGetTypeId()
 {
     $this->assertEmpty($this->_model->getTypeId());
     $this->_model->setTypeId('simple');
     $this->assertEquals('simple', $this->_model->getTypeId());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:6,代码来源:ProductGettersTest.php

示例11: setTypeId

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


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