magento2 eav模型的添加删除修改操作怎么做啊?

查看:178
本文介绍了magento2 eav模型的添加删除修改操作怎么做啊?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

magento2 eav模型的添加删除修改操作怎么做啊?
是否有大神有相关例子可以给我参考一下,现在正在学习,求分享

解决方案

对product eav的属性读写操作:

$product = $objectManager->create('Magento\Catalog\Model\ProductRepository')->getById($id);
/* @var \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency */
$priceCurrency = $objectManager->get('Magento\Framework\Pricing\PriceCurrencyInterface');
$priceCurrency->format($product->getData('price'));
$product->getResource()->getAttribute('color')->getDefaultFrontendLabel();
$product->getAttributeText('color');
$this->helper('Magento\Catalog\Helper\Output')->productAttribute($product, $product->getData('color'), 'color');
$product->getResource()->getAttribute('color')->getSource()->getAllOptions();
$product->setWeight(1.99)->getResource()->saveAttribute($product, 'weight');

但如果要用eav添加完整的product我就不清楚。EAV比较复杂,如果是自己开发module不建议用EAV。

这篇关于magento2 eav模型的添加删除修改操作怎么做啊?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆