Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Produsele Out Of Stock sa fie intotdeauna ultimele in category product page
 
premyal
Jr. Member
 
Total Posts:  5
Joined:  2012-04-01
 

Salut,

Am codul acesta care l-am gasit dupa o cautare pe google.

Codul este adaugat in /app/code/core/Mage/Catalog/Block/Product/list.php

$this->_productCollection $layer->getProductCollection()
                    ->
joinField(
                        
'inventory_in_stock'
                        
'cataloginventory_stock_item'
                        
'is_in_stock'
                        
'product_id=entity_id',
                        
'is_in_stock>=0'
                        
'left')
                    ->
setOrder('inventory_in_stock','desc');

Deocamdata codul merge doar pentru sortarea dupa nume si pozitie. Daca incerc sa sortez dupa pret ( care este cel mai important ) produsele out of stock se sorteaza dupa pret in loc sa ramana ultimele. Din cate am inteles trebuie modificat ceva in baza de date, deoarece mai intai ia sortarea dupa pret si de aceea nu isi mai face efectul acest cod.

Daca aveti vreo idee va rog sa ma anuntati

 
Magento Community Magento Community
Magento Community
Magento Community
 
premyal
Jr. Member
 
Total Posts:  5
Joined:  2012-04-01
 

Am gasit solutia

Trebuie adaugat codul urmator :

$this->getSelect()->joinLeft(
                array(
'_inventory_table'=>$this->getTable('cataloginventory/stock_item')),
                
"_inventory_table.product_id = e.entity_id",
                array(
'is_in_stock''manage_stock')
            );
            
$this->addExpressionAttributeToSelect('on_top',
            
'(CASE WHEN (((_inventory_table.use_config_manage_stock = 1) AND (_inventory_table.is_in_stock = 1)) OR  ((_inventory_table.use_config_manage_stock = 0) AND (1 - _inventory_table.manage_stock + _inventory_table.is_in_stock >= 1))) THEN 1 ELSE 0 END)',
             array());
            
$this->getSelect()->order('on_top DESC');

inainte de linia

if ($attribute == 'price' && $storeId != 0{

in app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection

Sau in app/code/core/Mage/Catalog/Model/Product/Collection.php daca aveti Magento 1.7.0.0 +

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top