Questions tagged «magento-2.0»

表示与Magento CE / EE 2.0版相关的问题

6
Magento 2重新索引返回没有这样的实体
我已成功将目录从Magento 1.9.2.3迁移到Magento 2.0.2。迁移之后,我使用命令进行了重新索引php bin/magento indexer:reindex。 除索引catalog_category_product和catalog_product_category,No such entity.在shell中返回和Reindex Required在admin中返回通知外,所有索引均已成功重新索引。我检查了var/log/但没有错误。 结果,产品被添加到后端的类别中,但是类别在前端显示为空。 什么可能导致此问题?我该如何调试?

1
如何在Magento 2中调试布局文件处理?
根据有关布局文件处理的magento 2主题规范: Magento应用程序按以下顺序处理布局文件: 1 /从模块收集所有布局文件。该顺序由来自app / etc / config.php的模块列表中的模块顺序确定。 2. /确定继承主题[,...,]的顺序 3. /从上一个祖先到当前迭代一个主题序列: 一种。将所有扩展主题布局文件添加到列表中。 b。替换列表中被覆盖的布局文件。 4. /合并列表中的所有布局文件。 如何为该过程的每个步骤调试和查看布局文件?

2
Magento 2:什么是catalog_attributes.xml文件?
我注意到Magento 2 catalog_attributes.xml在以下文件夹中包含几个文件: app/code/Magento/Bundle/etc app/code/Magento/Catalog/etc app/code/Magento/CatalogSearch/etc app/code/Magento/CatalogUrlRewrite/etc app/code/Magento/Downloadable/etc app/code/Magento/GiftMessage/etc app/code/Magento/Msrp/etc app/code/Magento/Sales/etc app/code/Magento/Tax/etc app/code/Magento/Wishlist/etc 这些文件如下所示(该Sales文件的示例): <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/catalog_attributes.xsd"> <group name="quote_item"> <attribute name="sku"/> <attribute name="type_id"/> <attribute name="name"/> <attribute name="status"/> <attribute name="visibility"/> <attribute name="price"/> <attribute name="weight"/> <attribute name="url_path"/> <attribute name="url_key"/> <attribute name="thumbnail"/> <attribute name="small_image"/> <attribute name="tax_class_id"/> <attribute name="special_from_date"/> <attribute name="special_to_date"/> <attribute name="special_price"/> <attribute …

4
如何在Magento 2中以编程方式添加客户?
我需要在Magento 2中以编程方式创建一个客户,但是我并没有发现太多文档。基本上,我需要做的就是将以下代码转换为“ Magento 2”: $websiteId = Mage::app()->getWebsite()->getId(); $store = Mage::app()->getStore(); $customer = Mage::getModel("customer/customer"); $customer ->setWebsiteId($websiteId) ->setStore($store) ->setFirstname('John') ->setLastname('Doe') ->setEmail('jd1@ex.com') ->setPassword('somepassword'); try{ $customer->save(); }


4
常量名称是预期的。错误
我收到此错误: 消息为“常量名称”的未捕获异常“ InvalidArgumentException”是预期的。 php bin/magento setup:upgrade在命令行中运行时。 我收到此http://awesomescreenshot.com/0535zi4648错误。
12 error  magento-2.0  cli 


10
Magento 2:以编程方式更新库存
在以下代码中,我能够存储所有信息,但不包括库存数据。Magento 2有什么变化吗? public function __construct( ScopeConfigInterface $scopeConfig, CollectionFactory $product, Magento\Catalog\Api\ProductRepositoryInterface $productRepository ) { $this->scopeConfig = $scopeConfig; $this->product = $product; $this->productRepository = $productRepository; } public function update(\XXXXXX\XXXXXX\Api\Data\InventoryCollectionInterface $data) { foreach ($data['list'] as $d) { $product = $this->productRepository->getById($d['entity_id']); $product->setStatus(($d['quantity'] > 0 ? 1 : 0)); $product->setUpc($d['upc']); $product->setStockData(array( 'qty' => $d['quantity'], 'is_in_stock' => …

1
在已部署的生产系统上设置setup:cron:run和update / cron.php的原因来设置cronjob?
在Magento 2中,应将三个命令设置为cronjob * * * * * <path to php binary> <magento install dir>/bin/magento cron:run | grep -v "Ran jobs by schedule" >> <magento install dir>/var/log/magento.cron.log * * * * * <path to php binary> <magento install dir>/update/cron.php >> <magento install dir>/var/log/update.cron.log * * * * * <path to php …

1
我如何在adminhtml中的基因敲除渲染后触发代码运行
更新:您可以直接访问视图模型。如果需要触发代码以在渲染后运行,请使用MutationObserver。只要有一个好的示例,我就会发布我的代码。 原始问题: 我们有很多电话打入订单。我正在研究一个模块,该模块会使用webapi / jsonp调用自动在admin->客户->从我们的CRM解决方案中创建数据。这样,magento中的数据不会创建我们已经存储在“主数据库”中的数据重复项。 我剩下要做的一项任务是添加客户的地址。乍一看,这似乎很简单,直到我意识到基因敲除+ magentojs如何在客户表单上呈现一切时,才使我无法捕获模板化元素。在以编程方式删除所有地址并创建新地址之后,我想花些时间来尝试捕获字段集(输入元素)。 如果您想知道为什么要这样做,我的代码的一部分会弹出一个提示,然后说:“嘿,这个人已经存在。您要使用它们吗?” 它将删除您已经输入的所有内容,并以正确的信息替换它。然后呼叫中心对其进行验证,即yadda yadda。 我将分享到目前为止的代码,但是不能正常工作。仅供参考,它扩展了Abstract以捕获“ onUpdate”事件。不要因为试图访问某个收藏夹项目中的收藏夹而责备我。我无法提出一种更好的方法来捕获onUpdate事件并仍然查看所有字段。 我也完全理解哪里出了问题,我只是不知道如何解决它。问题是我假设由.activate()调用生成的元素将在下面立即可用 document.getElementsByClassName('admin__fieldset') 这只是错误的逻辑。理想情况下,我希望能够拉出字段集内容而不必求助于该UI技巧,然后,一旦我完成所有设置,就将其渲染出来。 我不想诉诸jQuery黑客来监视dom更新。 // jsonService variable is available here because it is in the php template render. see // Stti/Customer/view/adminhtml/templates/javascriptinject.phtml define(['ko','jquery','underscore','originalAbstract','uiElement', 'uiCollection'], function(ko, $, _, Abstract, Element, Collection) { "use strict"; var theArray = { formFields: [], …

4
Magento 2 Helper实例
当我认为我从Magento 2缠绕DI系统时,出现了一些问题,并将其解包。 我在核心代码中看到了访问助手的不同方式。 例如,Magento\Catalog\Controller\Category::_initCategory其中有: if (!$this->_objectManager->get('Magento\Catalog\Helper\Category')->canShow($category)) { return false; } 但是在Magento\Catalog\Block\Category\View帮助器中注入了构造函数 public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Catalog\Model\Layer\Category $catalogLayer, \Magento\Framework\Registry $registry, \Magento\Catalog\Helper\Category $categoryHelper, array $data = array() ) { $this->_categoryHelper = $categoryHelper; $this->_catalogLayer = $catalogLayer; $this->_coreRegistry = $registry; parent::__construct($context, $data); } 这使我认为应该在控制器和块(和模型)中以不同的方式访问帮助程序,但是随后我找到了一个在构造函数中注入了帮助程序的控制器Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute。 请为我清除雾气。 什么时候应该使用DI objectManager?什么时候应该使用DI ?为什么? 我已经读过这个问题:在Magento 2中实例化助手。这只是一个后续问题。



5
从可配置中获取简单的产品
我正在尝试以下代码来获取属于的子级的所有简单产品的ID $collection,我知道它们是可配置产品的集合。 foreach($collection as $_product) { $_children = $_product->getTypeInstance()->getUsedProductIds($_product); print_r($_children); } 但是,我得到的所有数组都是空的。难道我做错了什么?

2
Magento 2:如何创建自己的自定义缓存类型?
在Magento 1中,可以通过在您的中声明以下内容来创建自己的缓存类型config.xml: <global> <cache> <types> <custom translate="label,description" module="module"> <label>Custom Cache</label> <description>This is my custom cacge</description> <tags>CUSTOM_CACHE_TAG</tags> </custom > </types> </cache> </global> 这将导致在“ 系统”>“缓存管理”下将新的缓存类型添加到后端,因此,它将添加刷新与CUSTOM_CACHE_TAG缓存标签相关的缓存的功能。 在M2中有可能吗?如何实现?

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.