mallen Posted February 1, 2013 Share Posted February 1, 2013 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"; Quote Link to comment Share on other sites More sharing options...
mallen Posted February 1, 2013 Author Share Posted February 1, 2013 (edited) 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 February 1, 2013 by mallen Quote Link to comment Share on other sites More sharing options...
mallen Posted February 1, 2013 Author Share Posted February 1, 2013 If I echo <?php echo $catt; ?> I get 'wp_mycart_category' so I don't know how it tells that $catt is equal to wp_mycart_category Quote Link to comment Share on other sites More sharing options...
mallen Posted February 7, 2013 Author Share Posted February 7, 2013 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;} Quote Link to comment Share on other sites More sharing options...
mallen Posted February 7, 2013 Author Share Posted February 7, 2013 <?php $array = unserialize($Product->ivalue); echo $array[0]; ?> I tried this and it didn't work. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 8, 2013 Share Posted February 8, 2013 That's a serialized object, not an array. Quote Link to comment Share on other sites More sharing options...
mallen Posted February 8, 2013 Author Share Posted February 8, 2013 Ok its a serialized object. How can I extract that image name from it? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 8, 2013 Share Posted February 8, 2013 The same way you access any object's property. You're doing it with $Product. Quote Link to comment Share on other sites More sharing options...
mallen Posted February 8, 2013 Author Share Posted February 8, 2013 I tried this and still no luck. I need just to echo the image name. <?php $newvalue = unserialize($Product->ivalue); echo $newvalue ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 8, 2013 Share Posted February 8, 2013 (edited) *smh* Â Do you know that $Produce is an object? (And that PHP lines need to end in ; ) Edited February 8, 2013 by Jessica Quote Link to comment Share on other sites More sharing options...
Christian F. Posted February 8, 2013 Share Posted February 8, 2013 When you unserialize the string you get an object, then you can access its properties. You're doing it in the wrong order in your code. Quote Link to comment Share on other sites More sharing options...
mallen Posted February 8, 2013 Author Share Posted February 8, 2013 (edited) 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 February 8, 2013 by mallen Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 8, 2013 Share Posted February 8, 2013 So once you unserialize that string, it will create ANOTHER object. Try doing a print_r() on the new object to see what properties it has for you to access. Quote Link to comment Share on other sites More sharing options...
mallen Posted February 8, 2013 Author Share Posted February 8, 2013 <?php unserialize($Product->ivalue); print_r($Product->ivalue); ?> I get the same string above and the same if I do var_dump(); Quote Link to comment Share on other sites More sharing options...
Christian F. Posted February 8, 2013 Share Posted February 8, 2013 (edited) 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 February 8, 2013 by Christian F. Quote Link to comment Share on other sites More sharing options...
mallen Posted February 8, 2013 Author Share Posted February 8, 2013 (edited) 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 February 8, 2013 by mallen Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 8, 2013 Share Posted February 8, 2013 You didn't save the results of the unseralization into a variable. You *WERE* doing that before, so... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.