Datafeedr Support Forums  

Go Back   Datafeedr Support Forums > Current Version (V3) Forum > Tips, Tricks & Tutorials
Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Important - The support forums are now in "read-only" mode as we transition to an alternative help desk solution. Feel free to contact us here with any of your questions or search the forums for an existing solution.
 
 
Thread Tools Search this Thread Display Modes
  #21  
Old September 15th, 2012, 11:59 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi

Can you change the HTML to this (below), load the page and copy any of the <pre>formatted text and paste it here?

HTML Code:
<pre><?php print_r($category); ?></pre>

<form method="get">
  
  <!-- Brand drop down select menu -->
  <select name="brand">
    <?php echo dfr_get_brands($category->id); ?>
  </select>
  
  <input type="submit" value="Go" />
  
</form>
  #22  
Old September 15th, 2012, 04:11 PM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

Hi there,

This is the text I get:

stdClass Object
(
[id] => 999838
[parent] => 992506
[typ] => 0
[name] => stoffen1
[path] => dames/rijbroeken/stoffen1
[slug] => stoffen1

=>
[thumbnail] =>
[description] =>
[keywords] =>
[pc] => 138
[pct] => 138
[legacy_id] => dames_rijbroeken_stoffen1
[site_link] => store/category/dames/rijbroeken/stoffen1/
[visible] => 1
[children] => Array
(
)

)
  #23  
Old September 15th, 2012, 04:21 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi

This means the products appearing in this category are already in another category and the query will need to use a JOIN on the p2c table.

Eric
  #24  
Old September 15th, 2012, 04:44 PM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

uhmm... say what?
  #25  
Old September 15th, 2012, 05:11 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Try this function:
PHP Code:
function dfr_get_brands($cat=false) {
    global 
$wpdb;
    if (
$cat) { $cat_query "WHERE p2c.cat_id = ".$cat." "; }
    
$brands $wpdb->get_results("    
        SELECT brand, p2c.cat_id
        FROM "
.$wpdb->prefix."dfr_shop_products AS p
        INNER JOIN "
.$wpdb->prefix."dfr_shop_p2c AS p2c ON p.id = p2c.id
        
$cat_query
        GROUP BY brand
    "
);
    
$html '<option value="">Select a brand</option>';
    foreach (
$brands as $brands) {
        if (
trim($brands->brand) != "") {
            
$selected = (strip_tags(stripslashes($_GET['brand']))==$brands->brand) ? ' selected="selected"' '';
            
$html .= '<option value="'.$brands->brand.'"'.$selected.'>'.$brands->brand.'</option>';
        }
    }
    return 
$html;

  #26  
Old September 16th, 2012, 12:42 PM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

wow!!!!!!! it works!!! Thank you sooo much!

I guess it is also possible to add functions for merchant, tag and price filter in the way the code above has been set up? I will give that a try

Once again, thank you!
  #27  
Old September 20th, 2012, 05:29 AM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

One additional question...

In some categories, it doesn't show the brands and merchants, because I added the products to the subcategory and not the parent category. To overcome this problem, I want to add the category ids to the code in the view page. However, I can't seem to get multiple id's in a proper way. I use the following code for 1 ID, but I also want to add the ID's "994434", "994435" and "994436." How should I implement that?

<form method="get">
<p style="font-family: Play; font-size: 18px; margin-bottom: 10px;">Selecteer merk</p><select name="brand">
<?php echo dfr_get_brands($cat_ids='994433'); ?>
</select>

<p style="font-family: Play; font-size: 18px; margin-bottom: 10px; margin-top: 10px;">Selecteer webshop</p><select name="merchant_id">
<?php echo dfr_get_merchants($category_id='994433'); ?>
</select>
<p style="margin-bottom: 20px;"></p>
<input type="submit" value="Zoeken" />

</form>

Thanks in advance!!

EDIT: this is for the page "Veiligheid" which can be seen at: http://www.paardenlifestyle.com/stor...es/veiligheid/

Last edited by connepon : September 20th, 2012 at 05:33 AM.
  #28  
Old September 20th, 2012, 09:04 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi

You need to use MySQL's IN().

WHERE p2c.cat_id IN(994434,994435,994436)

Eric
  #29  
Old September 20th, 2012, 04:05 PM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

Hi Erik,

thanks for you reply. Where do I add the line of code? I've tried adding it in the view page on several ways, but now it keeps breaking up. I'm sorry I'm not experienced with this, so I'm just trying to sort it out.
  #30  
Old September 20th, 2012, 04:54 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Are you passing 1 or more than 1 category IDs into the dfr_get_brands() function?
  #31  
Old September 21st, 2012, 02:14 AM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

The "parent category" is called "Veiligheid" and has ID 992504. That category is empty, because the products are in the subcategories: 994433, 994434, 994435 and 994436. I want to show the products from the subcategories on the page Veiligheid (in the dropdown filter).

So I started with the following code, which shows the products from 994433 on the page Veiligheid. However, I want to show 34, 35 and 36 as well. I've added the line you've suggested and placed it on several ways, but that didn't work. I'm sure I'm doing something wrong, so I was hoping you could tell me how to change the code below.


<form method="get">
<p style="font-family: Play; font-size: 18px; margin-bottom: 10px;">Selecteer merk</p><select name="brand">
<?php echo dfr_get_brands($cat_id='994433'); ?>
</select>

<p style="font-family: Play; font-size: 18px; margin-bottom: 10px; margin-top: 10px;">Selecteer webshop</p><select name="merchant_id">
<?php echo dfr_get_merchants($cat_id='994433'); ?>
</select>
<p style="margin-bottom: 20px;"></p>
<input type="submit" value="Zoeken" />

</form>
  #32  
Old September 21st, 2012, 09:44 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi

You can do this in your view:

HTML Code:
<?php echo dfr_get_brands('994433,994434,994435,994436'); ?>
And this in your function:

PHP Code:
if ($cat) { $cat_query "WHERE p2c.cat_id IN (".$cat.") "; } 
That should query brands from multiple categories.

Eric
  #33  
Old September 25th, 2012, 09:21 AM
connepon connepon is offline
 
Join Date: Sep 2012
Posts: 25
Default

Yeah it works! Thanks!!!!!! !!
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Category Menu dropdown works but cannot add non Datafeedr menus gutfeelboy Questions 2 August 15th, 2011 08:49 AM
Search in specific category sylviathewitch Questions 1 March 11th, 2011 11:30 AM
Dropdown Filters Code feri Questions 4 March 6th, 2011 05:32 PM
Drip products to one specific category? onefairworld Tips, Tricks & Tutorials 6 February 19th, 2011 09:24 AM
Drip Specific Category k9marketing Tips, Tricks & Tutorials 1 January 23rd, 2011 12:25 PM


All times are GMT -5. The time now is 12:28 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.