Products - summary by custom field?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
jezatron
Forum Members
Forum Members
Posts: 63
Joined: Sun May 17, 2009 3:02 pm

Products - summary by custom field?

Post by jezatron »

Hi sorry if this has already been answered / detailed somewhere but I have searched and searched and also looked in the module help but can't see it.

In the same way that one can call a summary of products that share a specific category... i.e.
{Products detailpage="yourDetailPage" detailtemplate="yourTemplate" category="selectedCategory"}

how would you call a summary of products with a specific value for a custom field?
obviously you need to detail the fact that you are sorting based on a custom field, the fieldname and the field value but I have no idea what the protocol / syntax for doing so would be?

Thanks

Jamie
jezatron
Forum Members
Forum Members
Posts: 63
Joined: Sun May 17, 2009 3:02 pm

Re: Products - summary by custom field?

Post by jezatron »

sorry guys

im sure this will be a fairly generic solution but in case you were put off by lack of set up info i just realised forgot to detail it....

i am running cmsms carolina 1.5.4
products 2.3.1
User avatar
manc
Forum Members
Forum Members
Posts: 107
Joined: Wed Apr 01, 2009 12:59 pm

Re: Products - summary by custom field?

Post by manc »

did you ever find a solution to this? i am also trying to find out how to search by field definition
User avatar
manc
Forum Members
Forum Members
Posts: 107
Joined: Wed Apr 01, 2009 12:59 pm

Re: Products - summary by custom field?

Post by manc »

i'm messing around at the moment with some SQL, however, not sure how to get the entered search parameters into the UDT ($searchterm). anyone know how to do this?

here's some code I made:
global $gCms;
$smarty = &$gCms->GetSmarty();
$db = &$gCms->db;

function make_alias($string, $isForm=false)
  {
    $string = trim($string);
    $string = preg_replace("/[_-\W]+/", "-", $string);
    $string = trim($string, '_');
    return strtolower($string);
  }

$prop = 'SELECT * FROM cms_module_products WHERE status="Published"';
$propresult= $db->Execute($prop);

$fields = 'SELECT * FROM cms_module_products_fieldvals WHERE value=$searchterm';
$fieldresult= $db->Execute($fields);


while ($row= $propresult->FetchRow())
{
        while ($fieldprop= $fieldresult->FetchRow())
        {
echo $fieldprop['value'];
        }
}
this just outputs the matched field and will obviously will make more of a template (once i've sorted the rest out).
tyman00
Power Poster
Power Poster
Posts: 906
Joined: Tue Oct 24, 2006 5:59 pm

Re: Products - summary by custom field?

Post by tyman00 »

To the best of my knowledge there is no way without building a UDT of sorting by custom fields. I know it has been discussed but it is currently not built into the module.
If all else fails, use a bigger hammer.
M@rtijn wrote: This is a community. This means that we work together and have the same goal (a beautiful CMS), not that we try to put people down and make their (voluntary) job as difficult as can be.
User avatar
manc
Forum Members
Forum Members
Posts: 107
Joined: Wed Apr 01, 2009 12:59 pm

Re: Products - summary by custom field?

Post by manc »

this is my UDT. do you know how to get parameters from the search entry into the UDT?
tyman00
Power Poster
Power Poster
Posts: 906
Joined: Tue Oct 24, 2006 5:59 pm

Re: Products - summary by custom field?

Post by tyman00 »

I'm far from a programmer :) So I cannot be of any service. I wish you luck though, I personally wouldn't mind seeing this ability in Products as well.
If all else fails, use a bigger hammer.
M@rtijn wrote: This is a community. This means that we work together and have the same goal (a beautiful CMS), not that we try to put people down and make their (voluntary) job as difficult as can be.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Products - summary by custom field?

Post by calguy1000 »

There's no functionality for this in the Products module.... and if you wanted to do it, it would have to be a sponsored modification.  I just don't have time to do it gratis.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
manc
Forum Members
Forum Members
Posts: 107
Joined: Wed Apr 01, 2009 12:59 pm

Re: Products - summary by custom field?

Post by manc »

ok. if i get something completed i'll post it here...
User avatar
manc
Forum Members
Forum Members
Posts: 107
Joined: Wed Apr 01, 2009 12:59 pm

Re: Products - summary by custom field?

Post by manc »

i'm progessing here. just need a little help. does anyone know how to only call one product, by product id, as a summary template. i tried doing the following to call one id from the detail page, but use a detail template called result which is just a copied version of my default summary template:

{Products action='details' detailtemplate='result' productid='PRODUCT_ID'}

obviously the following does nothing:

{Products productid='PRODUCT_ID'}

any ideas?
tyman00
Power Poster
Power Poster
Posts: 906
Joined: Tue Oct 24, 2006 5:59 pm

Re: Products - summary by custom field?

Post by tyman00 »

Try installing the CGSimpleSmarty module and looking at the module_action_link tag. Something like:

{module_action_link module='Products' action='details' productid=$entry->id text=$entry->product_name}
If all else fails, use a bigger hammer.
M@rtijn wrote: This is a community. This means that we work together and have the same goal (a beautiful CMS), not that we try to put people down and make their (voluntary) job as difficult as can be.
User avatar
manc
Forum Members
Forum Members
Posts: 107
Joined: Wed Apr 01, 2009 12:59 pm

Re: Products - summary by custom field?

Post by manc »

this works, however, i don't want a simple link. i want to be able to output the summary template (or an edited detail template) with information from the module data. i can call them all fine, just not one in particular. this is essential to make the rest of the SQL work.

your suggestion also doesn't make way for the SEO-friendly URLs given in a normal instance
Last edited by Anonymous on Tue Oct 20, 2009 6:15 pm, edited 1 time in total.
tyman00
Power Poster
Power Poster
Posts: 906
Joined: Tue Oct 24, 2006 5:59 pm

Re: Products - summary by custom field?

Post by tyman00 »

I am not sure what you are asking for then. Your descriptions are fairly convoluted.

The {module_action_link} tag does indeed work, but you are right it doesn't do pretty urls. Though it won't hurt your SEO rank it just likely won't improve it.
If all else fails, use a bigger hammer.
M@rtijn wrote: This is a community. This means that we work together and have the same goal (a beautiful CMS), not that we try to put people down and make their (voluntary) job as difficult as can be.
User avatar
manc
Forum Members
Forum Members
Posts: 107
Joined: Wed Apr 01, 2009 12:59 pm

Re: Products - summary by custom field?

Post by manc »

after much faffing, i've come up with some SQL, however, need a little help that i'm sure one of you will know how to solve.

here's my PHP/SQL as a UDT:
global $gCms;
$smarty = &$gCms->GetSmarty();
$db = &$gCms->db;

function make_alias($string, $isForm=false)
  {
    $string = trim($string);
    $string = preg_replace("/[_-\W]+/", "-", $string);
    $string = trim($string, '_');
    return strtolower($string);
  }

$post=$params['pc'];
$bedrooms=$params['rooms'];
$price=$params['rent'];

$query ="SELECT DISTINCT product_id FROM cms_module_products, cms_module_products_fieldvals WHERE (cms_module_products_fieldvals.fielddef_id=21 AND cms_module_products_fieldvals.value != 'true') ";

if ($post!= '[unspecified]') {
$query .="AND (cms_module_products_fieldvals.fielddef_id IN (8,9) AND cms_module_products_fieldvals.value LIKE '%$post%') ";
}

if ($bedrooms!= '[unspecified]') {
$query .="AND (cms_module_products_fieldvals.fielddef_id IN (12) AND cms_module_products_fieldvals.value >= '$bedrooms') ";
}

if ($price!= '[unspecified]') {
$query .="AND cms_module_products.price >= '$price'";
}

$counting = mysql_query($query);
$count = mysql_num_rows($counting);
echo "We have found ".$count." properties that match your search!
";

echo "

".$query."


";

$fieldresult= $db->Execute($query);
while ($fieldprop= $fieldresult->FetchRow())
{
$smarty_data = "{Products action='details' detailtemplate='result' productid='".$fieldprop['product_id']."'}";
$smarty->_compile_source('temporary template', $smarty_data, $_compiled );
@ob_start();
$smarty->_eval('?>' . $_compiled);
$_contents = @ob_get_contents();
@ob_end_clean();
echo $_contents;
}
the bold is where my issue is. i am having trouble combining the first statement with the other 3. the 3 bold statements are based on search inputs by the user. i know each query within each bracket by itself works fine, but combining them bring out 0 results (even when i know the search query should output something)
User avatar
manc
Forum Members
Forum Members
Posts: 107
Joined: Wed Apr 01, 2009 12:59 pm

Re: Products - summary by custom field?

Post by manc »

suggestions here anyone?
Post Reply

Return to “Modules/Add-Ons”