Magento

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

3
Mage :: log写入屏幕
我有一个开发系统,display_errors打开,Magento处于开发人员模式,我试图 Mage::log($layered_navigation_filter_block); // Mage_Catalog_Block_Layer_Filter_Attribute 而且所有内容都被写入屏幕,而不是日志文件,为什么? 看起来像这种情况: // app/Mage.php:837 if (is_array($message) || is_object($message)) { $message = print_r($message, true); } 但是print_r的第二个参数被忽略: Mage_Catalog_Block_Layer_Filter_Category Object ( [_filter:protected] => ... [28-Jan-2013 22:48:43 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 241434624 bytes) in /var/www/app/code/local/MyCompany/Motif/Model/Observer.php on line 47 [28-Jan-2013 22:48:43 …
21 debugging 

6
Amazon S3中的Magento媒体资产
我被问到如何将所有magento媒体资产保存在Amazon S3中。我考虑过使用像这样的PHP Stream Wrapper:https : //github.com/punkave/aS3StreamWrapper,只是将媒体文件夹设置为s3:\ mybucket \ mediaFolder 有人对此有经验吗? 或者更好地使用类似这样的东西:https : //github.com/sstoiana/magento-s3 但是这个扩展看起来并不好。还有其他建议吗?

1
如何使用Composer安装特定的Magento 2版本?
我想在Composer中安装Magento 2.1.7版,我在可在require:中使用的文档中找到了该文件"magento/product-community-edition": "2.1.7",但composer说找不到所需的软件包。 我还发现我可以做到: composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <installation directory name> 但这不允许版本号吗?

2
Magento 2-使用/避免使用吸气剂的良好实践?
Varien_Object(M1)和DataObject(M2)上的魔术吸气剂是常见的做法,但是使用Magento 2时,使用它会感到错误。 好: 容易读/写 坏 在键中使用数字时会引起问题(请参阅:Magento 2:使用驼峰式大小写的不同方式获取集合的字段或获取自定义产品属性) 代码分析工具抱怨不存在的方法 题 使用Magento 2,我们有两种新方法: getDataByKey($key) getDataByPath($path) 是否有充分的理由继续使用getData($key)或使用任何吸气剂? 编辑: @Vinai谢谢。我没有提及该@method方法,因为我的方法大不相同。 它仅对IDE有帮助,对其他方面没有影响。 有几个mergedf PR是“微优化”的,例如在循环外(甚至对于小型阵列)强制转换为数组大小或(int)替代intval()数组大小。 另一方面,有 神奇的吸气剂,正如马吕斯(Marius)所说的那样有些“开销”。 strtolower(trim(preg_replace('/([A-Z]|[0-9]+)/', "_$1", $name), '_')); getData($key) Mehtods还必须额外进行2-3次检查... if ('' === $key) { if (strpos($key, '/')) { if ($index !== null) { 对于自己的代码,完全同意倾向于使用实际方法,但是在相同情况下,这是不可能的...例如,您创建了一个自定义事件... $value = $observer->getVar_1(); $value = $observer->getData('var_1'); $value = …


2
Magento 2结帐-在送货地址和送货方式之间添加自定义字段
我正在尝试在送货地址和送货方式部分之间添加自定义字段。而且我想这个字段的值存储在这两个quote和sales_order表大势所趋。这类似于添加“订单注释”字段,但是此字段应出现在“收货地址”部分之后和“送货方式”部分之前。 我浏览了Magento开发人员指南,了解如何在结帐中添加自定义字段和自定义表单,并在一定程度上实现了解决方案。 到目前为止,我所做的是: 更新了checkout_index_index.xml布局,uiComponent在“ shippingAddress”项下添加了一个新的(容器)。 在容器内添加了我需要的元素(字段)。 在我的自定义模块中覆盖/js/view/shipping.js和shipping.phtml。 shipping.phtml在结帐送货地址和送货方式之间调用上述制成的容器(类似于添加新的静态表格) 现在,我想要的字段正被呈现在一页结帐上,正是我想要的位置。但是我遇到了以下问题。 如何访问我在上面添加的自定义字段的值?我正在尝试将值保存到shippingAddress扩展属性。我在setShippingInformationAction里面添加了一个mixin ,尝试执行以下操作 shippingAddress['extension_attributes']['custom_field'] = shippingAddress.customAttributes['custom_field']; 但是上述代码实际上失败了,因为该元素不在中shipping-address-fieldset。我也许能够通过window元素获取值。但是有没有办法通过Magento来访问它呢? 有没有一种方法可以将该元素的值保存在本地缓存存储(Magento_Checkout/js/checkout-data)中,这样即使在刷新页面后该值也将保持不变?


7
运行安装程序时出现奇怪错误:模块安装后升级
我尝试安装wyomind google shopping,并且在运行bin / magento setup:upgrade时遇到以下错误。 [UnexpectedValueException] Unable to retrieve deployment version of static files from the file system. [Magento\Framework\Exception\FileSystemException] Cannot read contents from file "/var/www/vanillamage2/public_html/pub/stati c/deployed_version.txt" Warning!file_get_contents(/var/www/vanillamage2/pub lic_html/pub/static/deployed_version.txt): failed to open stream: No such f ile or directory 我已经在2个单独的服务器和3个Magento 2.1.7的单独安装上进行了尝试,但是每次都收到相同的问题。我在这里看到了类似的问题: https://github.com/magento/magento2/issues/6426 和 http://olivernam.com/magento2-frontpage-error-after-deploying-static-files 因此,尝试了这里提到的许多解决方案,包括重新部署静态文件,重置权限,删除静态内容,放置空的deployment_version.txt等,但是没有任何运气。我什至将文件设置为777,拥有正确的所有者,并且可以肯定这不是问题,因为下面的解决方案不会更改此文件的权限。 我只有两种获取设置的方法:运行升级。 禁用插件。 将app / code …

3
致命错误:无法在Magento 2中实例化接口?
作为在Magento 2中以编程方式创建捆绑产品的一部分,我遇到了错误。甚至我删除了var / cache和generation。 这可能是一个重复的问题,但没有一个答案可解决此问题。 致命错误:无法在第73行的\ ObjectManager \ Factory \ Dynamic \ Developer.php中实例化接口Magento \ Catalog \ Api \ Data \ ProductExtensionInterface 下面的代码用作链接的参考 $productExtension = $objectManager->create(\Magento\Catalog\Api\Data\ProductExtensionInterface::class); $option = $objectManager->create(\Magento\Bundle\Api\Data\OptionInterface::class); $option->setTitle('Size'); $option->setType('radio'); $option->setRequired(true); $option->setPosition(1); //$option->setProductLinks($links); $productExtension->setBundleOptions([$option]); $_product->setExtensionAttributes($productExtension); 我将对象管理器用于临时/快速用途,会将对象管理器转换为构造函数指令。 任何人都可以帮助我解决这个问题。

5
在Magento2中的购物车中获取产品属性
我正在尝试在购物车模板中获取产品属性。但是我就是行不通!该属性在“店面”的“目录页面”上设置为“可见” =是,并在“产品列表”中使用=“是” 我使用自定义模块来覆盖以下模板: /vendor/magento/module-checkout/view/frontend/templates/cart/item/default.phtml 我有产品: $_item = $block->getItem(); $product = $_item->getProduct(); 通常,我希望具有“ sample_attr”属性代码的自定义属性(在这种情况下为文本区域类型)可用于以下其中一项: $product->getData('sample_attr'); 要么 $product->getSampleAttr(); 使用此属性可以使用某些属性(SKU,重量,价格..),但是对于自定义属性均无效。包含的帮助器(\ Magento \ Msrp \ Helper \ Data)也没有属性方法。 我可以使用以下方法获取所有属性代码: $attributes = $product->getAttributes(); foreach($attributes as $a) { var_dump($a->getName()); } 我也尝试过: $attribute = $product->getResource()->getAttribute('sample_attr'); var_dump($attribute->getFrontend()->getValue($product)); 但这返回null。 那么如何获取属性的值? 我尝试了以下方法: 在目录页面上获取每种产品的特定属性 在目录list.phtml中输出自定义文本属性(Magento 2)

3
Magento 2:模块开发人员应如何读取自己的配置文件
场景:我是Magento 2模块开发人员。我想在中创建配置文件app/etc。我希望此文件按区域“范围” app/etc/my_file.xml app/etc/frontend/my_file.xml app/etc/adminhtml/my_file.xml 在Magento 1中,我只创建一个config.xml并继续使用。区域范围界定发生在XML文件本身中。但是,Magento 2的处理方式却大不相同 在Magento 2中,我应该创建什么类文件来读取这些作用域配置文件。从Magento 2来源尚不清楚实现此目的的“正确”方法是什么。核心代码采用多种方法,并且都没有用@api方法标记。这使得很难知道如何继续执行此通用模块开发人员任务。作为次要的副作用,这也使得很难知道Magento模块开发人员应如何从核心配置文件读取。 一方面,看起来“正确”的事情是创建文件系统读取器对象。例如,Magento似乎import.xml使用以下内容加载文件 #File: vendor/magento/module-import-export/Model/Import/Config/Reader.php namespace Magento\ImportExport\Model\Import\Config; class Reader extends \Magento\Framework\Config\Reader\Filesystem { public function __construct( //... $fileName = 'import.xml', //... ) { parent::__construct( $fileResolver, $converter, $schemaLocator, $validationState, $fileName, $idAttributes, $domDocumentClass, $defaultScope ); } //... } 基Magento\Framework\Config\Reader\Filesystem类看起来像具有解决区域范围的代码。 但是,某些Magento配置文件似乎避开了这种模​​式。尽管有这些文件的阅读器(event.xml在此示例中) vendor/magento/framework/Event/Config/Reader.php 还有使用这些阅读器的“作用域数据”类。 #File: vendor/magento/framework/Event/Config/Data.php …

3
Magento 2自定义网格列排序顺序
我使用UI组件在Magento管理员中创建了一个自定义网格。基本上,除了未正确显示的列顺序之外,其他所有程序都工作正常。 如您所见,“操作”列位于开头,而选定的列位于结尾 当我在XML中创建列时,我考虑了sortOrder每一列的属性,但是某种程度上,顺序并不是我将其设置为 来自的代码listing.xml如下 <columns name="inactive_columns" class="Module\MyModule\Ui\Component\Listing\Columns"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">inactive_listing.inactive_listing.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current</item> </item> <item name="editorConfig" xsi:type="array"> <item name="selectProvider" xsi:type="string">inactive_listing.inactive_listing.inactive_columns.ids</item> <item name="enabled" xsi:type="boolean">true</item> <item name="indexField" xsi:type="string">entity_id</item> <item name="clientConfig" xsi:type="array"> <item name="saveUrl" xsi:type="url" path="customer/index/inlineEdit"/> <item name="validateBeforeSave" xsi:type="boolean">false</item> </item> </item> <item name="childDefaults" xsi:type="array"> …
20 magento2  admin  grid  sort 

4
如何在Magento 1.7中启用开发人员模式
我正在尝试在使用Magento 1.7的站点上启用开发人员模式。到目前为止,我已经添加了: SetEnv MAGE_IS_DEVELOPER_MODE "true" 到.htaccess文件和: ... if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) { Mage::setIsDeveloperMode(true); } ... 到这里index.php描述的文件。我什至删除了该子句,只留下了:If ... Mage::setIsDeveloperMode(true); ... 在index.php文件中。但是仍然没有运气。我想念什么?我应该怎么做才能启用开发人员模式?

3
将链接添加到类别菜单
我知道这是一个有很多答案的老问题,其中大多数建议编辑菜单模板,但这对我不起作用。无需解释为什么,让我有点强迫症,以“正确”的方式做事。 这个问题可以作为有需要的其他人的材料。开始。 从Magento 1.7开始,使用以下事件构建顶部菜单:page_block_html_topmenu_gethtml_before。Mage_Catalog模块使用它来添加类别。我想用那个。为此,我在模块中创建了一个观察者,如下所示: <global> <events> <page_block_html_topmenu_gethtml_before> <observers> <my_observer> <class>mymodule/observer</class> <method>addItemsToTopmenuItems</method> </my_observer> </observers> </page_block_html_topmenu_gethtml_before> </events> </global> 在Observer.php课堂上我有 public function addItemsToTopmenuItems($observer){ //get the menu object: //Type Varien_Data_Tree_Node $menu = $observer->getMenu(); //get the tree object in the menu //type Varien_Data_Tree $tree = $menu->getTree(); //get current page handler $action = Mage::app()->getFrontController()->getAction()->getFullActionName(); $brandNodeId = …
20 magento-1.7  menu 

5
在Magento集合中使用“具有”问题
我正在尝试在Magento管理模块中为网格构建自定义集合。我创建了一个名为“ addAttributeHaving”的新收集方法,该方法仅执行以下操作: public function addAttributeHaving($value) { $this->getSelect()->having($value); return $this; } 请参阅收集代码: $collection->addFieldToSelect( array( 'entity_id', 'created_at', 'increment_id', 'customer_email', 'customer_firstname', 'customer_lastname', 'grand_total', 'status' ) ); $collection->getSelect()->joinLeft(array('sfop' => 'sales_flat_order_payment'), 'main_table.entity_id = sfop.parent_id', 'sfop.amount_authorized'); $collection->getSelect()->columns('sum(sfop.amount_authorized) AS AUTHD'); $collection->getSelect()->columns('grand_total - sum(sfop.amount_authorized) AS DIF_AU'); $collection->addFieldToFilter('main_table.state', array('in' => array('new','payment_review'))); $collection->addFieldToFilter('main_table.sd_order_type', array('neq' => 7)); $collection->addFieldToFilter('sfop.method', array('neq' => 'giftcard')); …

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.