Arquivos

Aqui aparecem os posts dos arquivos selecionados.

Arquivos do mês: julho 2016

Importar e exportar banco de dados MySQL

Olá,

Para importar o comando é:

mysql -u username -p database_name < arquivo.sql

 
Para exportar o comando é:

mysqldump database_name > arquivo.sql

 
'username' => Nome Usuário do Banco de dados
'database_name' => Nome do Banco de dados

Magento – Adicionando opções para ordenar na página de produtos

Olá,

1 – Abra o arquivo: app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php
2 – Na linha 232, vai encontrar:

 

if ($this->getCurrentOrder()) {
 $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
}
return $this;

 
3 – Acrescente o código e altere da forma que desejar:

 

if ($this->getCurrentOrder()) {
 if(($this->getCurrentOrder())=='recente'){
  $this->_collection->setOrder('entity_id','desc');
 }else {
  $this->_collection->setOrder($this->getCurrentOrder(),$this->getCurrentDirection());
 }
}
return $this;

 
4 – Agora na linha 391, procure a função:

 

public function setDefaultOrder($field){
 if (isset($this->_availableOrder[$field])) {
  $this->_orderField = $field;
 }
 return $this;
}

 
5 – Altere para esse código:

 

public function setDefaultOrder($field) {
 if (isset($this->_availableOrder[$field])) {
  $this->_availableOrder = array(
   'recente' => $this->__('Mais Recente'),
   'name' => $this->__('Name'),
   'price' => $this->__('Price'),
  );
  $this->_orderField = $field;
 }
 return $this;
}

Magento – Ordenar página de produtos pelo “id”

Olá,

para ordenar do produto mais recente:

 

/*   Copie o arquivo
*    app\code\core\Mage\Catalog\Block\Product\List.php
*    para
*    app\code\local\Mage\Catalog\Block\Product\List.php
*/

/* Procure pela função: */
public function _getProductCollection()

/* Altere de: */
$this->_productCollection =  $layer->getProductCollection()->addAttributeToSort($_GET['order'], $_GET['dir']);

/* Para: */
if($_GET['dir'] == NULL)
    $this->_productCollection =  $layer->getProductCollection()->addAttributeToSort('entity_id', 'desc');
else
    $this->_productCollection =  $layer->getProductCollection()->addAttributeToSort($_GET['order'], $_GET['dir']);