Magento的1.9.1不排序配置产品按位置属性下拉
新鲜安装Magento的1.9.1。
Fresh install of Magento 1.9.1.
Magento的被忽略目录 - 设置该属性的位置>属性 - >属性 - 管理>管理标签/可配置的产品选项下拉。相反,它是使用产品ID来确定列表顺序
Magento is ignoring the attribute position set in Catalogue->Attributes->Manage Attributes->Manage Labels/Options for a configurable product drop down. Instead it is using the Product ID to determine list order.
相比有以下文件/功能,并且除了小税计算,没有code的自1.7.0.2改变。
Have compared the following files/functions and, apart from a small tax calculation, none of the code has changed since 1.7.0.2.
法师/目录/型号/产品/类型/ Configuarable.php:
Mage/Catalog/Model/Product/Type/Configuarable.php:
public function getConfigurableAttributes($product = null)
法师/目录/型号/产品/ Option.php:
Mage/Catalog/Model/Product/Option.php:
public function getProductOptionCollection(Mage_Catalog_Model_Product $product)
法师/目录/座/产品/视图/类型/ Configuarable.php:
Mage/Catalog/Block/Product/View/Type/Configuarable.php:
public function getJsonConfig()
我还测试了现场直播的副本数据库和所有属性的排序是基于产品ID。
I have also tested on a copy database of a live site and all the attribute sorting is based on Product ID.
要复制。
-
创建一个属性 - 颜色
Create an attribute - Colour
添加标签 - 黑色,红色,绿色,蓝色
Add labels - Black, Red, Green, Blue
保存属性。
在上述顺序的属性创建配置和简单的相关产品。
Create configurable and simple associated products with the attributes in the above order.
编辑属性和更改标签位置。蓝0,绿1,红3,黑4
Edit attribute and change label positions. Blue 0, Green 1, Red 3, Black 4
在查看产品Magento的排序还是按产品ID属性,而忽略立场。
When viewing product Magento still sorts the attributes by Product ID and ignores positions.
由Meogi答案工作,但并不像它只能在前端的选项排序完美的答案。尝试了配置产品创建一个从管理面板的订单。你仍然会得到排序不正确的属性选项列表。
The answer by Meogi works but is not the perfect answer as it will only sort the options on the frontend. Try creating an order from the admin panel for a configurable product. You will still get the incorrectly sorted attribute option list.
相反,你可以应用/ code /核心/法师/目录/型号/资源/产品/型号/配置/属性/ Collection.php复制到本地文件夹的应用程序/ code /本地/法师/目录/型号/资源/产品/型号/配置/属性/ Collection.php和应用这个补丁:
Instead, you can copy app/code/core/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php to local folder app/code/local/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php and apply this patch:
Index: app/code/local/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php
===================================================================
--- app/code/local/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php
+++ app/code/local/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php
@@ -301,7 +301,28 @@
}
}
}
+ /**
+ * Mage 1.9+ fix for configurable attribute options not sorting to position
+ * @author Harshit <support@cubixws.co.uk>
+ */
+ $sortOrder = 1;
+ foreach ($this->_items as $item) {
+ $productAttribute = $item->getProductAttribute();
+ if (!($productAttribute instanceof Mage_Eav_Model_Entity_Attribute_Abstract)) {
+ continue;
+ }
+ $options = $productAttribute->getFrontend()->getSelectOptions();
+ foreach ($options as $option) {
+ if (!$option['value']) {
continue;
}
+ if (isset($values[$item->getId() . ':' . $option['value']])) {
+ $values[$item->getId() . ':' . $option['value']]['order'] = $sortOrder++;
+ }
+ }
+ }
+ usort($values, function ($a, $b) {
+ return $a['order'] - $b['order'];
+ });
+
foreach ($values as $data) {
$this->getItemById($data['product_super_attribute_id'])->addPrice($data);
}
如果您在核心文件下载到本地文件夹都在犹豫复制的话,我可以创造一个快速的模块,&LT;改写&GT;
此Collection.php文件,只是覆盖_loadPrices()函数,并介绍此修复程序。
If you are hesitant of copying across a core file to local folder then I can create a quick module, <rewrite>
this Collection.php file and just override the _loadPrices() function and introduce this fix.