本文整理汇总了PHP中Magento\Catalog\Model\Product::getTypeId方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::getTypeId方法的具体用法?PHP Product::getTypeId怎么用?PHP Product::getTypeId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Model\Product
的用法示例。
在下文中一共展示了Product::getTypeId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canApplyToProduct
/**
* Check whether Msrp applied to product Product Type
*
* @param \Magento\Catalog\Model\Product $product
* @return bool
* @api
*/
public function canApplyToProduct($product)
{
if ($this->mapApplyToProductType === null) {
/** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
$attribute = $this->eavAttributeFactory->create()->loadByCode(Product::ENTITY, 'msrp');
$this->mapApplyToProductType = $attribute->getApplyTo();
}
return in_array($product->getTypeId(), $this->mapApplyToProductType);
}
示例2: getCatalogRegularPrice
/**
* Regular catalog price
*
* @param \Magento\Catalog\Model\Product $product
* @return float
* @throws \UnexpectedValueException
*/
public function getCatalogRegularPrice(\Magento\Catalog\Model\Product $product)
{
if (array_key_exists($product->getTypeId(), $this->priceModelPool)) {
$catalogPriceModel = $this->priceModelFactory->create($this->priceModelPool[$product->getTypeId()]);
return $catalogPriceModel->getCatalogRegularPrice($product);
}
return $product->getPrice();
}
示例3: afterGetMediaAttributes
/**
* Unset swatch image role if product is not simple
*
* @param \Magento\Catalog\Model\Product $product
* @param array|string $imageRoles
* @return array
*/
public function afterGetMediaAttributes(\Magento\Catalog\Model\Product $product, $imageRoles)
{
if ($product->getTypeId() !== \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE && $product->getTypeId() !== \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL) {
if (is_array($imageRoles)) {
unset($imageRoles[\Magento\Swatches\Model\Swatch::SWATCH_IMAGE_NAME]);
}
}
return $imageRoles;
}
示例4: aroundIsProductConfigured
/**
* Decide whether product has been configured for cart or not
*
* @param \Magento\Catalog\Model\Product\CartConfiguration $subject
* @param callable $proceed
* @param \Magento\Catalog\Model\Product $product
* @param array $config
*
* @return bool
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundIsProductConfigured(\Magento\Catalog\Model\Product\CartConfiguration $subject, \Closure $proceed, \Magento\Catalog\Model\Product $product, $config)
{
if ($product->getTypeId() == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) {
return isset($config['super_group']);
}
return $proceed($product, $config);
}
示例5: aroundIsProductConfigured
/**
* Decide whether product has been configured for cart or not
*
* @param \Magento\Catalog\Model\Product\CartConfiguration $subject
* @param callable $proceed
* @param \Magento\Catalog\Model\Product $product
* @param array $config
*
* @return bool
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundIsProductConfigured(\Magento\Catalog\Model\Product\CartConfiguration $subject, \Closure $proceed, \Magento\Catalog\Model\Product $product, $config)
{
if ($product->getTypeId() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) {
return isset($config['links']);
}
return $proceed($product, $config);
}
示例6: 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)
*/
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['associated']) ? $links['associated'] : $product->getGroupedLinkData();
$product->setGroupedLinkData((array) $links);
}
}
示例7: _getProductHelper
/**
* Returns helper for product type
*
* @param Product $product
* @return \Magento\Catalog\Helper\Product\Configuration\ConfigurationInterface
*/
protected function _getProductHelper($product)
{
// Retrieve whole array of renderers
$productHelpers = $this->getProductHelpers();
if (!is_array($productHelpers)) {
$column = $this->getColumn();
if ($column) {
$grid = $column->getGrid();
if ($grid) {
$productHelpers = $grid->getProductConfigurationHelpers();
$this->setProductHelpers($productHelpers ? $productHelpers : []);
}
}
}
// Check whether we have helper for our product
$productType = $product->getTypeId();
if (isset($productHelpers[$productType])) {
$helperName = $productHelpers[$productType];
} elseif (isset($productHelpers['default'])) {
$helperName = $productHelpers['default'];
} else {
$helperName = 'Magento\\Catalog\\Helper\\Product\\Configuration';
}
return $this->_productConfigPool->get($helperName);
}
示例8: aroundValidate
/**
* @param \Magento\Catalog\Model\Product\Attribute\Backend\Price $subject
* @param \Closure $proceed
* @param \Magento\Catalog\Model\Product|\Magento\Framework\Object $object
* @return bool
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundValidate(\Magento\Catalog\Model\Product\Attribute\Backend\Price $subject, \Closure $proceed, $object)
{
if ($object instanceof \Magento\Catalog\Model\Product && $object->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE && $object->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC) {
return true;
} else {
return $proceed($object);
}
}
示例9: 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 = $this->weightResolver->resolveProductHasWeight($product) ? Type::TYPE_SIMPLE : Type::TYPE_VIRTUAL;
$product->setTypeId($productTypeId);
}
}
示例10: 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);
}
}
示例11: aroundValidate
/**
* @param \Magento\Catalog\Model\Product\Attribute\Backend\Price $subject
* @param \Closure $proceed
* @param \Magento\Catalog\Model\Product|\Magento\Framework\DataObject $object
* @return bool
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundValidate(\Magento\Catalog\Model\Product\Attribute\Backend\Price $subject, \Closure $proceed, $object)
{
if ($object instanceof \Magento\Catalog\Model\Product && $object->getTypeId() == Configurable::TYPE_CODE) {
return true;
} else {
return $proceed($object);
}
}
示例12: getCanDisplayQty
/**
* Check if quantity can be displayed for tier price with msrp
*
* @param Product $product
* @return bool
* @SuppressWarnings(PHPMD.BooleanGetMethodName)
*/
public function getCanDisplayQty(Product $product)
{
//TODO Refactor - change to const similar to Model\Product\Type\Grouped::TYPE_CODE
if ($product->getTypeId() == 'grouped') {
return false;
}
return true;
}
示例13: 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);
}
示例14: testGetFinalPrice
public function testGetFinalPrice()
{
$finalPrice = 11;
$qty = 1;
$this->model->setQty($qty);
$productTypePriceMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Type\\Price', ['getFinalPrice'], [], '', false);
$productTypePriceMock->expects($this->any())->method('getFinalPrice')->with($qty, $this->model)->will($this->returnValue($finalPrice));
$this->productTypeInstanceMock->expects($this->any())->method('priceFactory')->with($this->model->getTypeId())->will($this->returnValue($productTypePriceMock));
$this->assertEquals($finalPrice, $this->model->getFinalPrice($qty));
$this->model->setFinalPrice(9.99);
}
示例15: isProductConfigured
/**
* Decide whether product has been configured for cart or not
*
* @param \Magento\Catalog\Model\Product $product
* @param array $config
* @return bool
*/
public function isProductConfigured(\Magento\Catalog\Model\Product $product, $config)
{
// If below POST fields were submitted - this is product's options, it has been already configured
switch ($product->getTypeId()) {
case \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE:
case \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL:
return isset($config['options']);
case \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE:
return isset($config['bundle_option']);
}
return false;
}