Guest User

Untitled

a guest
Aug 17th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. if(isset($_POST['btn-save'])){
  2. $resource = Mage::getSingleton('core/resource');
  3. $readConnection = $resource->getConnection('core_read');
  4. $table = $resource->getTableName('catalog/product');
  5. $search = $_POST['gsearch'];
  6. $query = 'SELECT * FROM ' . $table . 'WHERE name LIKE' .$search.'';
  7. $results = $readConnection->fetchAll($query);
  8. foreach($results as $res){
  9. echo $res ['name'];
  10. }
  11. }
  12.  
  13. if ($this->getRequest()->isPost() && $this->getRequest()->getPost('btn-save')) {
  14.  
  15. $collection = Mage::getResourceModel('catalog/product_collection');
  16. $collection->addAttributeToSelect('name');
  17. $collection->addAttributeToFilter('name',array('like'=> '% '.$this->getRequest()->getPost('gsearch').' %'));
  18. $names = $collection->getColumnValues('name');
  19.  
  20.  
  21. }
Add Comment
Please, Sign In to add comment