我想在magento admin.i上对magento捆绑产品选择排序顺序进行排序已更改下面的代码文件但没有发生任何事情。我不知道从哪里收集产品集合所以我可以按名称设置顺序。我已经在这个函数上按名称设置了顺序,但没有任何改变。
Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option
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;
}
请帮助
答案 0 :(得分:1)
要修改/扩展的类是Mage_Bundle_Model_Product_Type
,然后是函数getSelectionsCollection
。
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);
}
答案 1 :(得分:0)
这有帮助吗? Magento: how to load product along its all data as it is used in admin
您可以通过调用某些PHP函数并按字母顺序对其进行排序来修改$selectionRawData
。