Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(isset($_POST['btn-save'])){
- $resource = Mage::getSingleton('core/resource');
- $readConnection = $resource->getConnection('core_read');
- $table = $resource->getTableName('catalog/product');
- $search = $_POST['gsearch'];
- $query = 'SELECT * FROM ' . $table . 'WHERE name LIKE' .$search.'';
- $results = $readConnection->fetchAll($query);
- foreach($results as $res){
- echo $res ['name'];
- }
- }
- if ($this->getRequest()->isPost() && $this->getRequest()->getPost('btn-save')) {
- $collection = Mage::getResourceModel('catalog/product_collection');
- $collection->addAttributeToSelect('name');
- $collection->addAttributeToFilter('name',array('like'=> '% '.$this->getRequest()->getPost('gsearch').' %'));
- $names = $collection->getColumnValues('name');
- }
Add Comment
Please, Sign In to add comment