Magento

Magento电子商务平台用户的问答

1
何时以及如何在view_preprocessed中生成phtml模板?
我看到了在var/view_preprocessed/html中从核心模块以及自定义模块生成的许多phtml文件。看起来这些都是带空格的已使用模板。 艾伦·肯特(Alan Kent)在“ 如何在Grunt中更新Magento 2 phtml文件”中写道?: 您无需“部署” PHTML文件。它们由布局文件中的块引用,并在服务器端进行处理。因此,“咕gr声”在这里不相关,并且静态内容部署同样不相关。 在分析静态内容部署和繁琐的工作流程时,我没有发现与模板相关的任何内容,因此我认为这仍然成立。 但是何时生成这些文件?那里到底发生了什么,为什么?

2
Magento 2中的pub目录有什么好处
也许我只是没有得到它,但是如果我的文件已经被缓存了,那么Magento 2中的pub目录的用途是什么?我唯一有根据的猜测是,可以通过拥有一组已知的主题文件来减轻回退机制的使用。 通过阅读文档,尽管我感到自己对动态,静态和缓存文件有很强的把握,但我对这个好处并不清楚。 据我了解,缓存只是资产的已定义的已知位置,这使我猜测pub目录是一种标准化文件位置的机制,以减少回退机制上使用的资源。
11 magento2 


1
Magento 2:模块序列会影响布局处理XML加载顺序吗?
文件中的<sequence/>标签是否module.xml会影响Magento处理布局处理XML文件的顺序?我的初步研究说没有,但似乎错了,所以我在寻找的确认/证明,他们没有(其中布局处理XML文件路径生成和加载证明==源代码分) 如果序列标签不影响布局句柄XML文件的加载顺序,是否可以更改这些文件的加载顺序? 我要解决的特定问题是在容器实际添加到页面之前是否加载了以下内容 <referenceContainer name="product.info.media"> <action method="unsetChild"> <argument name="block" xsi:type="string">product.info.media.image</argument> </action> </referenceContainer> Magento Barfs。



6
Magento 2安装问题:尝试加载管理页面时出现404错误
我已经在wamp服务器上成功安装了Magento 2,但是在加载管理页面时却遇到了一个小问题,因为它为我提供了404。此外,在加载其主页时,默认情况下我使用的亮度主题不适用而是给我以下错误: Failed to load resource: the server responded with a status of 404 (Not Found) http://127.0.0.1/test1/pub/static/frontend/Magento/luma/en_US/mage/calendar.css Failed to load resource: the server responded with a status of 404 (Not Found) http://127.0.0.1/test1/pub/static/frontend/Magento/luma/en_US/css/styles-m.css Failed to load resource: the server responded with a status of 404 (Not Found) http://127.0.0.1/test1/pub/static/frontend/Magento/luma/en_US/css/styles-l.css Failed to load …

6
在Magento 2中找出参考的“名称”
我想从页面中删除一些块。举例来说,我要删除徽标容器。 然后/app/design/frontend/MYVENDORNAME/MYTHEMENAME/Magento_Theme/layout/default.xml用以下代码创建: <page layout="3columns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <referenceBlock name="logo" remove="true"/> </page> 在这种情况下,我通过搜索基本主题中的文件来设法找出此参考块的名称(名称=“徽标”)。 问题是:是否有更好的方法来找出块的名称。我认为必须在Magento的XMl文件中使用的所有名称都有一个列表吗?还是某种参考? 举例来说,我要删除菜单(<div class="sections nav-sections">...</div>)。我怎么知道那个名字
11 magento2  layout  xml 



4
Magento 2:如何通过商店ID筛选产品集合
使用产品工厂对象,我可以创建产品,获取产品集合并获取该集合的第一项 /* var $productFactory \Magento\Catalog\Model\ProductFactory */ $product = $this->productFactory->create()->getCollection()->getFirstItem(); 但是,如果我尝试将store_id添加到集合的过滤器中 $product = $this->productFactory ->create() ->getCollection() ->addFieldToFilter('store_id', 1) ->getFirstItem(); 我收到以下错误 Invalid attribute name: store_id #0 /Users/alanstorm/Sites/magento-2-dev-docs.dev/magento2/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php(1434): Magento\Eav\Model\Entity\Collection\AbstractCollection->_addAttributeJoin('store_id', 'inner') #1 /Users/alanstorm/Sites/magento-2-dev-docs.dev/magento2/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php(359): Magento\Eav\Model\Entity\Collection\AbstractCollection->_getAttributeConditionSql('store_id', 1, 'inner') #2 /Users/alanstorm/Sites/magento-2-dev-docs.dev/magento2/app/code/Magento/Catalog/Model/Resource/Product/Collection.php(1489): Magento\Eav\Model\Entity\Collection\AbstractCollection->addAttributeToFilter('store_id', 1, 'inner') #3 /Users/alanstorm/Sites/magento-2-dev-docs.dev/magento2/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php(382): Magento\Catalog\Model\Resource\Product\Collection->addAttributeToFilter('store_id', 1) ... #63 {main} 如果我尝试使用产品存储库按store_id进行过滤,也会发生相同的事情(存储库使用幕后的集合)。 这是一个错误吗?还是在Magento 2中更改了商店,网站和产品之间的关系,以使其不再是合法查询?都?都不行 还有吗

1
选择要基于Magento版本通过Composer安装的文件
在安装者的模块中包含多个版本的代码,并让安装者根据要安装的Magento版本确定要部署的版本,将非常方便。 例如,对于Magento> 1.7,请使用system.xml,其中包括tooltip,嵌套group功能和其他现代功能,但对于较旧版本的Magento,请使用文件的精简版本,其中不包含那些(破坏性)声明。 这种方法也可以用于标准模块结构中的许多其他文件。 对于作曲家部署的选项map,modman或package.xml据我所知,没有一个是有关于目标系统的任何情报。该package.xml选项不太可能更改,但map可以... 在我看来,将有许多扩展程序开发人员将从这种降级方法中受益。有没有人找到解决方法?

3
添加新的页面布局选项Magento
我想在Magento中添加新的页面布局,这是可以在CMS页面中选择的选项。我已经复制了1-column.phtml代码并对其进行了少许修改,并将其更改为1-column-version2.phtml. 我想知道如何处理新文件,以便它出现在CMS页面布局选项中。 。

1
表catalog_product_index_price中缺少某些产品!
任何人都可以帮助我阐明Magento中的价格指数吗?我正在使用1.9版。 我的任务:将特色产品渲染到主页中。 我的解决方案:而不是创建名为“特色产品”的类别。我创建了一个属性“ is_featured”,因此只过滤该属性为true的产品即可获得预期的结果。 基于内置的小部件Mage_Catalog_Block_Product_Widget_New,我的函数用于获取定义的产品集合: protected function _getProductCollection() { /** @var $collection Mage_Catalog_Model_Resource_Product_Collection */ $collection = Mage::getResourceModel('catalog/product_collection'); $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds()); $collection = $this->_addProductAttributesAndPrices($collection) ->addStoreFilter() ->addAttributeToFilter('is_featured', array('eq' => true)) ->setPageSize($this->getProductsCount()) ->setCurPage(1); return $collection; } 结果:出现了一些产品,但缺少其他一些产品。在进行SQL调试时,我看到: SELECT `e`.*, `cat_index`.`position` AS `cat_index_position`, `price_index`.`price`, `price_index`.`tax_class_id`, `price_index`.`final_price`, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS `minimal_price`, `price_index`.`min_price`, …

5
得到此错误消息:dbModel读取资源未实现Zend_Db_Adapter_Abstract
我把我的magento项目放在Linux服务器上。首先显示错误日志消息,但是缺少文件夹var。然后,我创建了var文件夹,并赋予它777权限,并与缓存,报告,会话相同。在报告文件夹的错误文件中,我收到以下消息: a:5:{i:0;s:65:"dbModel read resource does not implement Zend_Db_Adapter_Abstract";i:1;s:3543:"#0 /home/myfolder/public_html/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php(134): Varien_Data_Collection_Db->setConnection(false) #1 /public_html/app/code/core/Mage/Core/Model/Config.php(1348): Mage_Core_Model_Resource_Db_Collection_Abstract->__construct(Object(MKleine_LanguageRoutes_Model_Resource_Languageroute)) #2 /public_html/app/code/core/Mage/Core/Model/Config.php(1380): Mage_Core_Model_Config->getModelInstance('mk_languagerout...', Object(MKleine_LanguageRoutes_Model_Resource_Languageroute)) #3 /public_html/app/Mage.php(491): Mage_Core_Model_Config->getResourceModelInstance('mk_languagerout...', Object(MKleine_LanguageRoutes_Model_Resource_Languageroute)) #4 /public_html/app/code/core/Mage/Core/Model/Abstract.php(208): Mage::getResourceModel('mk_languagerout...', Object(MKleine_LanguageRoutes_Model_Resource_Languageroute)) #5 /public_html/app/code/core/Mage/Core/Model/Abstract.php(213): Mage_Core_Model_Abstract->getResourceCollection() #6 /public_html/app/code/community/MKleine/LanguageRoutes/Model/Translation.php(150): Mage_Core_Model_Abstract->getCollection() #7 /public_html/app/code/community/MKleine/LanguageRoutes/Model/Translation.php(129): MKleine_LanguageRoutes_Model_Translation->getRouteCollection(1) #8 /public_html/app/code/community/MKleine/LanguageRoutes/Model/Translation.php(91): MKleine_LanguageRoutes_Model_Translation->translateToFront('install', 1) #9 /public_html/app/code/community/MKleine/LanguageRoutes/Model/Core/Url.php(75): MKleine_LanguageRoutes_Model_Translation->translateRouteToFront('install') #10 /public_html/app/code/core/Mage/Core/Model/Url.php(398): MKleine_LanguageRoutes_Model_Core_Url->getRouteFrontName() #11 /public_html/app/code/core/Mage/Core/Model/Url.php(763): Mage_Core_Model_Url->getBaseUrl() #12 /public_html/app/code/core/Mage/Core/Model/Url.php(995): Mage_Core_Model_Url->getRouteUrl('install', …
11 database  error 

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.