• Resolved slimx91

    (@slimx91)


    Hi there,

    The website im dealing with has been setup to deal with all these random attributes and needs cleaning up.

    The website has for example
    NISSAN > PATROL 02-2010
    NISSAN PATROL > PATROL > 02-2010

    I need to clean it up, but i can’t find where to DELETE or EDIT the years and makes and models?

    When I export the CSV i get a huge file, but in some cases I don’t even see the ‘errored’ make/model.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Pektsekye

    (@pektsekye)

    Hello,

    > and needs cleaning up

    You should correct the data in the .csv file and then import it back with the “delete existing values” checkbox checked.
    Screenshot:
    https://hottons.com/demo/wp/ymm/screenshots/delete_existing_values.png

    >
    > I don’t even see the ‘errored’ make/model

    Try to replace the function getVehicleData()

    with:

    public function getVehicleData($limit = 0)     
        {
          $queryLimit = $limit > 0 ? " LIMIT {$limit} " : '';    
        
          $select = "
            SELECT DISTINCT IF(LENGTH(postmeta.meta_value)>0, postmeta.meta_value, posts.ID) as product_sku, ymm.make, ymm.model, ymm.year_from, ymm.year_to  
            FROM {$this->_wpdb->posts} AS posts 
    		    LEFT JOIN {$this->_wpdb->postmeta} AS postmeta 
    		      ON postmeta.post_id = posts.ID AND postmeta.meta_key = '_sku' 
            JOIN {$this->_mainTable} ymm 
              ON ymm.product_id = posts.ID 
    		    WHERE posts.post_type = 'product'
    		    ORDER BY posts.ID 
    		    {$queryLimit}		            
          ";
          
          return (array) $this->_wpdb->get_results($select, ARRAY_N);     
        }
    

    and the function getProductIdsBySku()

    with:

    public function getProductIdsBySku($limit = 0)
        {
          $queryLimit = $limit > 0 ? " LIMIT {$limit} " : '';
          
          $select = "
            SELECT IF(LENGTH(postmeta.meta_value)>0, postmeta.meta_value, posts.ID) as product_sku, posts.ID as product_id 
            FROM {$this->_wpdb->posts} AS posts 
    		    LEFT JOIN {$this->_wpdb->postmeta} AS postmeta 
    		      ON postmeta.post_id = posts.ID AND postmeta.meta_key = '_sku' 
    		    WHERE posts.post_type = 'product'
    		    {$queryLimit}          
          ";
          $result = (array) $this->_wpdb->get_results($select, ARRAY_A);
    
          $productIds = array();
          foreach ($result as $row){
            $productIds[$row['product_sku']] = $row['product_id'];
          }
           
          return $productIds;   
        }
    

    in the file:
    wp-content/plugins/ymm-search/Model/Db.php

    Stanislav

    Thread Starter slimx91

    (@slimx91)

    Excellent, I’ve seem to have figured it out now.
    I took a good look at the file – so basically it stores data PER SKU…

    Product 1 > TOYORA > LANDCRUISER
    Product 2 > TOYOTA > LANDCRUISER

    I think that’s the mistake , iwas making so now im just gonna spend some time cleaning that up. thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘deletes makes and models’ is closed to new replies.