Magento 更改所选捆绑产品项目的排序顺序
我想在magento admin上对magento bundle产品所选的排序顺序进行排序。我已更改了下面的代码文件,但未发生任何更改。我不知道从何处收集产品集合,以便按名称设置顺序。我已经按名称设置了此函数的顺序,但没有任何更改 Mage\u Bundle\u Block\u Adminhtml\u Catalog\u Product\u Edit\u Tab\u Bundle\u选项Magento 更改所选捆绑产品项目的排序顺序,magento,collections,magento-1.7,bundle,Magento,Collections,Magento 1.7,Bundle,我想在magento admin上对magento bundle产品所选的排序顺序进行排序。我已更改了下面的代码文件,但未发生任何更改。我不知道从何处收集产品集合,以便按名称设置顺序。我已经按名称设置了此函数的顺序,但没有任何更改 Mage\u Bundle\u Block\u Adminhtml\u Catalog\u Product\u Edit\u Tab\u Bundle\u选项 public function getOptions() { if (!$this->_opt
public function getOptions()
{
if (!$this->_options) {
$this->getProduct()->getTypeInstance(true)->setStoreFilter($this->getProduct()->getStoreId(),
$this->getProduct());
$optionCollection = $this->getProduct()->getTypeInstance(true)->getOptionsCollection($this->getProduct());
$selectionCollection = $this->getProduct()->getTypeInstance(true)->getSelectionsCollection(
$this->getProduct()->getTypeInstance(true)->getOptionsIds($this->getProduct()),
$this->getProduct()
);
$this->_options = $optionCollection->appendSelections($selectionCollection);
if ($this->getCanReadPrice() === false) {
foreach ($this->_options as $option) {
if ($option->getSelections()) {
foreach ($option->getSelections() as $selection) {
$selection->setCanReadPrice($this->getCanReadPrice());
$selection->setCanEditPrice($this->getCanEditPrice());
}
}
}
}
}
return $this->_options;
}
请帮忙这有帮助吗
您可以通过调用一些PHP函数并按字母顺序排序来修改
$selectionRawData
。要修改/扩展的类是Mage\u Bundle\u Model\u Product\u Type
,然后是getselectionscolection
public function getSelectionsCollection($optionIds, $product = null)
{
$keyOptionIds = (is_array($optionIds) ? implode('_', $optionIds) : '');
$key = $this->_keySelectionsCollection . $keyOptionIds;
if (!$this->getProduct($product)->hasData($key)) {
$storeId = $this->getProduct($product)->getStoreId();
$selectionsCollection = Mage::getResourceModel('bundle/selection_collection')
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
->addAttributeToSelect('tax_class_id') //used for calculation item taxes in Bundle with Dynamic Price
->setFlag('require_stock_items', true)
->setFlag('product_children', true)
//->setPositionOrder() //comment this line
->setOrder('name', 'asc') //add this line
->addStoreFilter($this->getStoreFilter($product))
->setStoreId($storeId)
->addFilterByRequiredOptions()
->setOptionIdsFilter($optionIds);
if (!Mage::helper('catalog')->isPriceGlobal() && $storeId) {
$websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
$selectionsCollection->joinPrices($websiteId);
}
$this->getProduct($product)->setData($key, $selectionsCollection);
}
return $this->getProduct($product)->getData($key);
}
任何人请帮助我…发到magento.stackexchange.com获取答案。。Magento现在有自己的网站。或者,你可以在
位置
栏中排名来实现这一点。我知道位置是一种方式,但我们必须手动下订单,所以这不是一种好方式。我希望在设置收藏时按名称排序。谢谢兄弟,你是我的英雄。