Jump to content

Customizing a ecommerce query


mallen

Recommended Posts

I am using this ecommerce theme with Wordpress and now the company is no longer I can't get support. There is a admin page that displays Name, Category, Price, Inventory and ID. I am trying to diplay the product image. If I make any changes to the query I get no reults. If I use Meta::$table I get an error that that Meta does not exits. Is there anywhere else I could check? Maybe the $wpd->wp_mycart_meta line is correct but the query is not. The query pulls data from mycart_price and mycart_catalog but I don't know how it finds those tables. I need to search the mycart_meta

$pd = DatabaseObject::tablename(Product::$table);
$pt = DatabaseObject::tablename(Price::$table);
$catt = DatabaseObject::tablename(Category::$table);
$clog = DatabaseObject::tablename(Catalog::$table);
$imgg = DatabaseObject::tablename(Meta::$table); // this I added
 $imgg = $wpd->wp_mycart_meta // I alo tried this







$query = "SELECT $columns $matchcol FROM $pt AS pt LEFT JOIN $pd AS pd ON pd.id=pt.product LEFT JOIN $clog AS clog ON pd.id=clog.product LEFT JOIN $catt AS cat ON cat.id=clog.parent AND clog.type='category' WHERE $where GROUP BY pt.id $having ORDER BY pd.id,pt.sortorder LIMIT $start,$per_page";


$Products = $db->query($query,AS_ARRAY);
$productcount = $db->query("SELECT FOUND_ROWS() as total");

} else {
$columns = "SQL_CALC_FOUND_ROWS pd.id,pd.name,pd.slug,pd.featured,pd.variations,GROUP_CONCAT(DISTINCT cat.name ORDER BY cat.name SEPARATOR ', ') AS categories,
IF(pt.options=0,IF(pt.tax='off',pt.price,pt.price+(pt.price*$taxrate)),-1) AS mainprice,
IF(MAX(pt.tax)='off',MAX(pt.price),MAX(pt.price+(pt.price*$taxrate))) AS maxprice,
IF(MAX(pt.tax)='off',MIN(pt.price),MIN(pt.price+(pt.price*$taxrate))) AS minprice,
IF(pt.inventory='on','on','off') AS inventory,
ROUND(SUM(pt.stock)/IF(clog.id IS NULL,1,count(DISTINCT clog.id)),0) AS stock";
if ($workflow) $columns = "pd.id";


$query = "SELECT $columns $matchcol FROM $pd AS pd LEFT JOIN $pt AS pt ON pd.id=pt.product AND pt.type != 'N/A' AND pt.context != 'addon' LEFT JOIN $clog AS clog ON pd.id=clog.product LEFT JOIN $catt AS cat ON cat.id=clog.parent AND clog.type='category' WHERE $where GROUP BY pd.id $having ORDER BY pd.name LIMIT $start,$per_page";

Link to comment
Share on other sites

When I run this

<?php echo var_dump($Product); ?>

I get the following. Not sure how it includes the categories in the array. I was trying to copy that to get it to include the image.

object(stdClass)#561 (12) { ["id"]=> string(2) "51" ["name"]=> string(22) "Nice Shiny Car" ["slug"]=> string(22) "Nice-Shiny-Car" ["featured"]=> string(3) "off" ["variations"]=> string(3) "off" ["categories"]=> string(6) "Luxury" ["mainprice"]=> string( "1.000000" ["maxprice"]=> string( "1.000000" ["minprice"]=> string( "1.000000" ["inventory"]=> string(2) "on" ["stock"]=> string(3) "900" ["catids"]=> string(2) "23" }

Edited by mallen
Link to comment
Share on other sites

I am getting closer.


<?php echo $Product->ivalue;?>

I get this value and all I need is the value of s27 How can I do that:

O:8:"stdClass":10:{s:4:"mime";s:10:"image/jpeg";s:4:"size";s:5:"14737";s:7:"storage";s:9:"FSStorage";s:3:"uri";s:27:"cache_276_260__100_A130.jpg";s:8:"filename";s:27:"cache_276_260_100_A130.jpg";s:5:"width";s:3:"258";s:6:"height";s:3:"260";s:3:"alt";s:0:"";s:5:"title";s:0:"";s:8:"settings";a:6:{s:5:"width";i:276;s:6:"height";i:260;s:5:"scale";i:0;s:7:"sharpen";i:100;s:7:"quality";b:0;s:4:"fill";b:0;}

Link to comment
Share on other sites

Thanks Christian F. you are always hepfull on here. I have

echo $Product->ivalue; and I get this

O:8:"stdClass":10:{s:4:"mime";s:10:"image/jpeg";s:4:"size";s:5:"14737";s:7:"storage";s:9:"FSStorage";s:3:"uri";s:27:"cache_276_260__100_A130.jpg";s:8:"filename";s:27:"cache_276_260_100_A130.jpg";s:5:"width";s:3:"258";s:6:"height";s:3:"260";s:3:"alt";s:0:"";s:5:"title";s:0:"";s:8:"settings";a:6:{s:5:"width";i:276;s:6:"height";i:260;s:5:"scale";i:0;s:7:"sharpen";i:100;s:7:"quality";b:0;s:4:"fill";b:0;}

Edited by mallen
Link to comment
Share on other sites

Even more serialization?! How many times has this been serialized?

Oh, well.. You just have to unserialize that too then. Also, you need to save the result from the second unserialize () as well.

 

"Yay" for notifications on new replies, btw...

Edited by Christian F.
Link to comment
Share on other sites

object(stdClass)#844 (10) { ["mime"]=> string(10) "image/jpeg" ["size"]=> string(5) "23471" ["storage"]=> string(9) "FSStorage" ["uri"]=> string(43) "cache_215_215_1_100_100_16777215_A1-1.jpg" ["filename"]=> string(43) "cache_215_215_1_100_100_16777215_A1-1.jpg" ["width"]=> string(3) "215" ["height"]=> string(3) "215" ["alt"]=> string(0) "" ["title"]=> string(0) "" ["settings"]=> array(6) { ["width"]=> int(215) ["height"]=> int(215) ["scale"]=> int(1) ["sharpen"]=> int(100) ["quality"]=> int(100) ["fill"]=> int(16777215) } }

I got it finally.

<?php $newvalue = unserialize($Product->ivalue); echo $newvalue->filename; ?>

Edited by mallen
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.