26 November 2011

Back Link & Date for Stock Movement Tab v1.0

Add a "Back to list" link & date column to BO stock movement tab.
#
#----------[ OPEN ]----------
#
admin/tabs/AdminStockMvt.php

#
#----------[ FIND ]----------
#
'employee' => array('title' => $this->l('Employee'), 'width' => 100, 'havingFilter' => true),

#
#----------[ AFTER, ADD ]----------
#
'date_add' => array('title' => $this->l('Date'), 'width' => 60, 'type' => 'datetime', 'align' => 'right'),

#
#----------[ FIND ]----------
#
public function viewstock_mvt()
 {
  global $cookie;

#
#----------[ REPLACE WITH ]----------
#
public function viewstock_mvt()
 {
  global $currentIndex, $cookie;

#
#----------[ FIND ]----------
#
echo '</table>';
 }
 
 public function display()

#
#----------[ REPLACE WITH ]----------
#
echo '</table>';
   echo '<div class="clear" style="height:20px;">&nbsp;</div>
   <br /><br /><a href="'.$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to list').'</a><br />';
 }
 
 public function display()

Back Link for Carts Tab v1.0

Add a "Back to list" link on the bottom of the cart detail page.
#
#----------[ OPEN ]----------
#
admin/tabs/AdminCarts.php

#
#----------[ FIND ]----------
#
    // Cancel product
    echo '
   </fieldset>
  <div class="clear" style="height:20px;">&nbsp;</div>';

#
#----------[ AFTER, ADD ]----------
#
  echo '<br /><br /><a href="'.$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" alt="" /> '.$this->l('Back to cart list').'</a><br />';

25 November 2011

Enhanced Product Details Statistics Module v1.0

Adds a table of sold attributes grouped by quantity to the BO product details statistics module.
#  
#----------[ OPEN ]----------  
#  
modules\statsproduct\statsproduct.php  
   
#  
#----------[ FIND ]----------  
#  
      public function hookAdminStatsModules($params)  
   
#  
#----------[ BEFORE, ADD ]----------  
#  
      private function getBestAttributes($id_product)  
      {  
           return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('  
           SELECT od.product_name, SUM(od.product_quantity) as pqty  
           FROM `'._DB_PREFIX_.'orders` o  
           LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order  
           WHERE o.date_add BETWEEN '.$this->getDate().'   
           AND o.valid = 1  
           AND od.product_id = '.(int)($id_product).'  
           GROUP BY od.product_attribute_id  
           ORDER BY pqty DESC');  
      }  
   
#  
#----------[ FIND ]----------  
#  
                     $this->_html .= '<h3 class="space">'.$this->l('Attribute sales distribution').'</h3><center>'.ModuleGraph::engine(array('type' => 'pie', 'option' => '3-'.$id_product)).'</center><br />  
                <p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=2"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p><br />';  
   
#  
#----------[ REPLACE WITH ]----------  
#  
                {  
                     $this->_html .= '<h3 class="space">'.$this->l('Attribute sales distribution').'</h3><center>'.ModuleGraph::engine(array('type' => 'pie', 'option' => '3-'.$id_product)).'</center><br />  
                    <p><a href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&export=1&exportType=2"><img src="../img/admin/asterisk.gif" />'.$this->l('CSV Export').'</a></p><br />';  
                     $top_attributes = $this->getBestAttributes($id_product);  
                     $this->_html .= '<br class="clear" />  
                     <h3>'.$this->l('Best attribute sales').'</h3>  
                     <div style="overflow-y: scroll; height: '.min(200, (count($top_attributes)+1)*32).'px;">  
                     <table class="table" border="0" cellspacing="0" cellspacing="0">  
                     <thead>  
                          <tr>  
                               <th>'.$this->l('Attribute').'</th>  
                               <th>'.$this->l('Qty').'</th>  
                          </tr>  
                     </thead><tbody>';       
                     foreach ($top_attributes as $attribute)  
                          $this->_html .= '  
                          <tr>  
                               <td>'.$attribute['product_name'].'</td>  
                               <td align="right">'.(int)($attribute['pqty']).'</td>  
                          </tr>';                                     
                     $this->_html .= '</tbody></table></div>';  
                }

18 November 2011

Link Product Accessories to Product Page v1.0

Slight improvement to link a product accessory to it's product page in BO. Very useful to check if the accessory is linked back to the main product.
#  
#----------[ OPEN ]----------  
#  
admin/tabs/AdminProduct.php

#  
#----------[ FIND ]----------  
#  
echo htmlentities($accessory['name'], ENT_COMPAT, 'UTF-8').(!empty($accessory['reference']) ? ' ('.$accessory['reference'].')' : '').' <span onclick="delAccessory('.$accessory['id_product'].');" style="cursor: pointer;"><img src="../img/admin/delete.gif" class="middle" alt="" /></span><br />';

#  
#----------[ REPLACE WITH ]----------  
#  
echo '<a href="index.php?tab=AdminCatalog&id_product='.$accessory['id_product'].'&updateproduct&token='.$this->token.'">'.htmlentities($accessory['name'], ENT_COMPAT, 'UTF-8').(!empty($accessory['reference']) ? ' ('.$accessory['reference'].')' : '').'</a> <span onclick="delAccessory('.$accessory['id_product'].');" style="cursor: pointer;"><img src="../img/admin/delete.gif" class="middle" alt="" /></span><br />';