Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    New Coder
    Join Date
    Apr 2013
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Error in php coding please help

    i am having an error for website....

    the error is : Fatal error: Call to undefined method Model Product Catalog :: getProductsAFiltered () in / home / nmcinl / public_html / engine exhausts / catalog / controller / module / afilters.php on line 111


    another the afilters.php full php code is :

    PHP Code:
    <?php  



    class ControllerModuleAFilters extends Controller {



        protected function 
    index() {



            
    $this->language->load('module/afilters');



            



    //nmci        $this->data['heading_title'] = $this->language->get('heading_title');





                                



            
    $this->load->model('catalog/category');



            
    $this->load->model('catalog/product');

            

            

            
    // Get current category

            

            
    if (isset($this->request->get['path'])) {



                
    $path '';



            



                
    $parts explode('_', (string)$this->request->get['path']);



            



                foreach (
    $parts as $path_id) {



                    if (!
    $path) {



                        
    $path $path_id;



                    } else {



                        
    $path .= '_' $path_id;



                    }



                                        



                    
    $category_info $this->model_catalog_category->getCategory($path_id);



                    



                    if (
    $category_info) {



                           
    $this->data['breadcrumbs'][] = array(



                               
    'text'      => $category_info['name'],



                            
    'href'      => $this->url->link('product/category''path=' $path),



                            
    'separator' => $this->language->get('text_separator')



                        );



                    }



                }        



            



                
    $category_id array_pop($parts);



            } else {



                
    $category_id 0;



            }



            
    // END get current category



            //--------------------------------------------------------------------------------------------------









            // Get total products for current category

            

            
    $product_total $this->model_catalog_product->getTotalProducts(array('filter_category_id' => $category_id));

            

            
    // END get total products for current category

            

            //--------------------------------------------------------------------------------------------------

            

            // Get all attributes for current category

            

            
    if (isset($this->request->get['att_filters']) && (is_array($this->request->get['att_filters']))) {

                    

                foreach(
    array_keys($this->request->get['att_filters']) as $filter_att) {

                    

                    
    $data['afilters'][$filter_att] = $this->request->get['att_filters'][$filter_att];

                }



            }

            

            if (isset(
    $data['afilters'])) {

            
    $myafilters $data['afilters'];

            } else {

            
    $myafilters = array();    

            }

            

            
    $data['filter_category_id'] = $category_id;

            

            
    $results $this->model_catalog_product->getProductsAFiltered($data);

            

            foreach (
    $results as $product) {

                

                
    $attributes $this->model_catalog_product->getProductAttributes($product['product_id']);

                

                
    $category_attributes[] = $attributes// mutat din forul de mai jos

                

                
    foreach($attributes as $attribute) {

                    

                    if (
    is_array($attribute['attribute'])) {

                        

                    foreach(
    $attribute['attribute'] as $attribute_value) {

                        

                        
    $category_attributes_values[$attribute_value['attribute_id']][] = array(

                        

                                
    'attribute_text' => $attribute_value['text'],

                                

                                
    'attribute_name' => $attribute_value['name'], // name added

                                

                                
    'attribute_id'     => $attribute_value['attribute_id']

                        

                        );    

                    };

                    } else {

                        
    $category_attributes_values[$attribute['attribute_id']][] = array(

                        

                                
    'attribute_text' => '',//$option_value['name'],

                                

                                
    'attribute_name' => ''//added

                                

                                
    'attribute_id'     => 0//$option_value['option_value_id']

                        

                        
    );                    

                            }    

                }

                

            }

            

            unset(
    $attributes);

            

            
    $big_array = array();

            

            if(isset(
    $category_attributes)){

                

                
    $i 0;

            

                foreach(
    $category_attributes as $pattribute) { // parcurg produsele

                    

                    

                    
    foreach ($pattribute as $gattribute) { // pentru toate grupele de atribute - fiecare grup al fiecarui produs

                

                    

                    

                    
    $attribute_array $gattribute['attribute'];



                    
    // start get big attribute

                    
    $j $gattribute['attribute_group_id'];                

                    
    $mybool false;    

                    
    $myattr false;            

                    foreach (
    $big_array as $barray) {

                            if (
    in_array($j$barray)) {

                                
    $mybool true;

                                }

                            if (
    in_array($gattribute['attribute'], $barray)){

                                
    $myattr true;

                                }



                    }

                    if (!(
    $mybool)) {

                    
    $big_array[$i]['attribute_group_id'] = $j;

                    
    $big_array[$i]['name'] = $gattribute['name'];

                    
    $big_array[$i]['attribute_types'] = array();//$gattribute['attribute'][0]['attribute_id'];

                    //$big_array[$i]['attribute'][] = $gattribute['attribute'];

                    
    $i++;

                    }

                    

                    
    // eng get bit attribute

                    

                            
    foreach ($attribute_array as $att_array) { // pentru fiecare attribut - al fiecarui grup

                         

                                
    $attribute_ids[] = $att_array['attribute_id'];

                                

                                
    // start experiment

                            //    $big_array[$i]['attribute'][]

                                

                                
    $all_attribs[$att_array['attribute_id']][] = array(

                        

                                
    'attribute_text' => $attribute_value['text'],

                                

                                
    'attribute_name' => $attribute_value['name']

                                );

                                
    // end experiment

                        

                            
    }

                    

                    }

                

                }

                

                
    $i 0;

                

                foreach (
    $big_array as $barray) {

                    

                    foreach(
    $category_attributes as $pattribute) {

                    

                    foreach (
    $pattribute as $gattribute) {

                        

                        
    $attribute_array $gattribute['attribute'];

                    

                        if (
    $big_array[$i]['attribute_group_id'] == $gattribute['attribute_group_id']) {

                            

                            foreach (
    $attribute_array as $att_array) {

                                

                                if (!
    in_array($att_array['attribute_id'], $big_array[$i]['attribute_types'])) {

                                

                                
    $big_array[$i]['attribute_types'][] = $att_array['attribute_id'];

                                

                                }

                                

                            }

                        

                        };

                    

                    };

                    

                    };

                

                
    $i++;

                    

                };

            

                if (isset(
    $attribute_ids)) { 

                

                
    $attributes_ids array_unique($attribute_ids); // or should it by unique by name?/ text

                

                
    } else {

                    

                
    $attributes_ids = array();

                

                }

                

                

                
    $attributes = array();

                    

                foreach(
    $attributes_ids as $attribute_id){ // pentru fiecare Attribute ID unic

                                

                    
    $i $attribute_id;

                    
    $attributes[$i] = array();

                

                    foreach(
    $category_attributes_values[$i] as $pgroup ){ // foreach of all products attributes groups (deja unice) - arrayuri de valori non-unice

                

                                
    if (!in_array($pgroup$attributes[$i])){

                            

                                
    $attributes[$i][] = $pgroup;

                                

                                
    //$found = true;    

                            

                                
    }

                        

                        

                    }            

                }    

                

                

                
    $big_array2 = array();

                
    $i=0;

                

                foreach (
    $big_array as $barray) {

                    

                    
    $big_array2[$i]['attribute_group_id'] = $barray['attribute_group_id'];

                    
    $big_array2[$i]['name'] = $barray['name'];

                    
    $big_array2[$i]['attribute_types'] = array();

                    

                    
    $types $barray['attribute_types'];

                    

                    
    $j 0;

                    

                    foreach (
    $types as $type) {

                        

                        
    $big_array2[$i]['attribute_types'][$j]['type_id'] = $type;

                        
    $big_array2[$i]['attribute_types'][$j]['type_name'] = $attributes[$type][0]['attribute_name'];

                        
    $big_array2[$i]['attribute_types'][$j]['types'] = array();

                        

                        foreach (
    $attributes[$type] as $atts) {

                        

                        
    ///aici incepe comma 

                    

                        
    $findme   ',';

                           
    $pos strpos($atts['attribute_text'], $findme);

                   

                        if (
    $pos !== false) {

                        
    $pieces explode(",",$atts['attribute_text']);

                               foreach (
    $pieces as $piece) { 

                            

                               
    $big_array2[$i]['attribute_types'][$j]['types'][] = $piece;

                             }

                        } else { 

                        

                        
    // aici se termina

                        
    $exista in_array($atts['attribute_text'], $big_array2[$i]['attribute_types'][$j]['types']);

                        if (!
    $exista) {

                        
    $big_array2[$i]['attribute_types'][$j]['types'][] = $atts['attribute_text']; 

                        }

                        

                        }

                        

                        }

                    
    $j++;

                    }

                

                
    $i++;

                }            

                

                



        }

            
    // END get all attributes for current category

            

            

            

            // get URL

            

            
    $this->load->model('catalog/category');

            

            if (isset(
    $this->request->get['sort'])) {

                
    $sort $this->request->get['sort'];

            } else {

                
    $sort 'p.sort_order';

            }



            if (isset(
    $this->request->get['order'])) {

                
    $order $this->request->get['order'];

            } else {

                
    $order 'ASC';

            }

            

            if (isset(
    $this->request->get['page'])) {

                
    $page $this->request->get['page'];

            } else { 

                
    $page 1;

            }    

                                

            if (isset(
    $this->request->get['limit'])) {

                
    $limit $this->request->get['limit'];

            } else {

                
    $limit $this->config->get('config_catalog_limit');

            }

                        

            
    $this->data['breadcrumbs'] = array();



               
    $this->data['breadcrumbs'][] = array(

                   
    'text'      => $this->language->get('text_home'),

                
    'href'      => $this->url->link('common/home'),

                   
    'separator' => false

               
    );    

            

                
    $url '';



                



                if (isset(
    $this->request->get['sort'])) {



                    
    $url .= '&sort=' $this->request->get['sort'];



                }

                

                

                

                if (isset(
    $this->request->get['manufacturer_id'])) {



                    
    $url .= '&manufacturer_id=' $this->request->get['manufacturer_id'];

                    

                    
    $filter $this->request->get['manufacturer_id'];



                } else {

                

                    
    $filter "";

                        

                }







                if (isset(
    $this->request->get['order'])) {



                    
    $url .= '&order=' $this->request->get['order'];



                }    





                if (isset(
    $this->request->get['limit'])) {



                    
    $url .= '&limit=' $this->request->get['limit'];



                }

                
    // start URL

                
    if (isset($data['afilters'])) {

                

                
    $afilterURL $data['afilters'];



                }

                

                if (isset(
    $afilterURL)) {

                    foreach (
    $afilterURL as $key=>$val) {

                    
    $url .= '&att_filters['.$key.']=' $val;

                    }

                }

            

            

            
    // END GET URL

            

            //--------------------------------------------------------------------------------------------------

            

            

            
    $this->data['href'] = $this->url->link('product/category''path=' $path $url);

            

            if (isset(
    $big_array2)) {

                
    $this->data['attributes'] = $big_array2;

            } else {

                
    $this->data['attributes'] = "";    

            }

            

            
    $this->data['afilters'] = $myafilters;



            

            if (isset(
    $this->request->get['att_filters']) && (is_array($this->request->get['att_filters']))) {

                    

                foreach(
    array_keys($this->request->get['att_filters']) as $filter_att) {

                    

                    
    $data['afilters'][$filter_att] = $this->request->get['att_filters'][$filter_att];

                }



            }

            



            if (
    file_exists(DIR_TEMPLATE $this->config->get('config_template') . '/template/module/afilters.tpl')) {



                
    $this->template $this->config->get('config_template') . '/template/module/afilters.tpl';



            } else {



                
    $this->template 'default/template/module/afilters.tpl';



            }



            



            
    $this->render();



          }



    }



    ?>

  • #2
    New Coder
    Join Date
    Apr 2013
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts
    the afilers.php file is in attachment please....
    Attached Files Attached Files

  • #3
    New Coder
    Join Date
    Apr 2013
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts
    my website link is: http://motoruitlaten.nmci.nl

    it is dutch language...

    another the error getting link is for every product when go to following link:

    for instance just a product link : http://motoruitlaten.nmci.nl/index.p...ategory&path=1

  • #4
    New Coder
    Join Date
    Apr 2013
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts
    please help i am getting this error....

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Thats unusual. You should be getting either an undefined function on non-object error OR an undefined class error (since Model Product Catalog is not a valid class name) depending on use. Issue a var_dump($this->model_catalog_product); prior to the $results = $this->model_catalog_product->getProductsAFiltered($data); on line 111 to see what it is.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    nicefellow1234 (04-19-2013)

  • #6
    New Coder
    Join Date
    Apr 2013
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts
    can you please make it correct and then give me correct code...please

    i don't know about php much more..will you please make it correct...

    please any body help...
    Last edited by Fou-Lu; 04-19-2013 at 04:37 PM.

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Quote Originally Posted by nicefellow1234 View Post
    can you please make it correct and then give me correct code...please
    Well no, I can't. I haven't a clue what's wrong with it. I gave you instructions and the line to insert before in my previous post. Refer to that and post the output for it.
    Also, refer to our guidelines, #5 in particular here: http://www.codingforums.com/postguide.htm
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    nicefellow1234 (04-19-2013)

  • #8
    New Coder
    Join Date
    Apr 2013
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts
    sorry for misbehaving and going against rules...!

    i replaced the old afilters.php file with the new edited file by placing your given code before line 111 code...

    and now you can see the result by visiting following link:

    http://motoruitlaten.nmci.nl/index.p...egory&path=1_9

    it is too horrible now...

    please waiting for your reply...

    till now my post is didn't approve for preview..
    Last edited by Fou-Lu; 04-19-2013 at 07:20 PM.

  • #9
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    You need to stop bumping this thread. Your posts will be approved when a moderator reviews and approves them.
    Post the class code for ModelCatalogProduct.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    nicefellow1234 (04-20-2013)

  • #10
    New Coder
    Join Date
    Apr 2013
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts
    i don't know class code?

    will you please tell me where i should found it...?

  • #11
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    You may have a file called ModelCatalogProduct.php or similar. If not, then I haven't a clue where you'd find it.
    You can fetch that off of the reflection engine using:
    PHP Code:
    $rc = new ReflectionClass('ModelCatalogProduct');
    printf("Path to class definition: %s" PHP_EOL$rc->getFileName()); 
    Which should tell you the path to where it was declared.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    nicefellow1234 (04-20-2013)

  • #12
    New Coder
    Join Date
    Apr 2013
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts
    where to post this code so i will know the php file path...?

    i mean how to use this reflection code?

    to Fou Lu:

    another way please post your email here or send an email to me on following email:

    nicefellow1234@gmail.com

    so i will give you ftp informations so you can please do by your self..?

  • #13
    New Coder
    Join Date
    Apr 2013
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts
    please i will be so thankful to you for that.!

  • #14
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Put the reflection code at the bottom of your script.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    nicefellow1234 (04-20-2013)

  • #15
    New Coder
    Join Date
    Apr 2013
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts
    yaah i get to code...and got path to class definition:

    which is:
    Path to class definition: /home/nmcinl/public_html/motoruitlaten/catalog/model/catalog/product.php

    now following is the product.php file in attachment please..
    Attached Files Attached Files


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •