Questions tagged «di.xml»

6
当前区域禁止删除操作
我想为sku创建用于简单产品的删除操作的命令。我收到以下错误。如何设置管理区域? [Magento \ Framework \ Exception \ LocalizedException] 当前区域禁止删除操作 <?php namespace Sivakumar\Sample\Console; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputOption; class DeleteSimpleProduct extends Command { protected $_product; public function __construct(\Magento\Catalog\Model\Product $_product) { $this->_product =$_product; parent::__construct(); } /** * {@inheritdoc} */ protected function configure() { $this->setName('delete_simple_product') ->setDescription('Delete Simple Product') ->setDefinition($this->getOptionsList()); parent::configure(); …

3
将CLI命令添加到Magento 2的正确,受支持的方法
是否存在将您的CLI命令添加到Magento 2模块的正确且受官方支持的方法?根据我的收集,您的选择是 将命令类添加到via 文件的commands参数中Magento\Framework\Console\CommandListdi.xml 通过\Magento\Framework\Console\CommandLocator::register一个registration.php或多个cli_commands.php文件注册命令 这些选项都不是带有祝福的@api。尚不清楚,作为扩展开发人员,我们应该如何添加命令行脚本,以使它们在版本之间保持一致。 有人知道在Right™方法上是否有正式的Magento政策吗?

2
Magento 2 After参数插件
我正在尝试将插件插入以下方法。 public function getCategoryUrl($category) { if ($category instanceof ModelCategory) { return $category->getUrl(); } return $this->_categoryFactory->create()->setData($category->getData())->getUrl(); } 请注意$category传递给上述方法的参数。 作为解决方案,我实现了以下代码。 public function afterGetCategoryUrl(\Magento\Catalog\Helper\Category $subject, $result) { return $result; } 现在,我的问题是:如何获取$category通过父方法传递给插件的参数?我只想根据$category对象中的特定值修改结果。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.