0
Magento 2.1의 백 앤드 컨트롤러에서 제품 속성을 제거하는 방법은 무엇입니까? 마 젠토 (1)에서removeAttribute magento 2
은 * 그것은이었다
$setup = Mage::getResourceModel('catalog/setup','catalog_setup');
$setup->removeAttribute('catalog_product','my_attribute');
이 편집 : 날/제거 방법을 설치 사용 제공하지 않습니다. 주의 질문을 읽어
편집 "을 했단 컨트롤러 속성을 제거"2 : 나는 당신은 설치 스크립트 이하로 사용하여 속성을 제거 할 수 있습니다
namespace Company\Module\Controller\Adminhtml\Shoptheme; //optional
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
class Removeattribute extends \Magento\Backend\App\Action {
private $dataSetup;
private $eavSetupFactory;
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\Setup\ModuleDataSetupInterface $dataSetup,
\Magento\Eav\Setup\EavSetupFactory $eavSetupFactory
) {
$this->dataSetup = $dataSetup;
$this->eavSetupFactory = $eavSetupFactory;
parent::__construct($context);
}
public function execute() {
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->dataSetup]);
$eavSetup->removeAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'prod_special_descr');
$this->messageManager->addSuccess('attribute removed');
$this->_redirect('admin/dashboard/');
}
}
당신은 삭제해야 설치 스크립트 메소드를 사용하는 속성 –