[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

Catalgoue Feed does not print output unless error_reporting is turned on.

Asked by uknetweb in PHP and Databases

Tags: catalgoue

Hi,

  I have a script which retrieves a shop catalogue and formats the output to provide a feed an affiliate scheme.

  I have set up the script to produce one feed and this works fine.

  I have implemented a similar class to produce a feed with different fields and format the output.

  This is set up to write the output to a file or print to a browser.

  The problem is that the script will not output the entire catalogue to the browser unless the error_reporting is not suppressed.  

  If I allow the "trigger_error" output to be shown, the entire catalogue shows up fine, otherwise I get no output.

  It has the symptoms of being a memory problem, but I have a track on the memory usage and I am iterating through the catalogue, one item at a time to reduce the amount of data I have to hold in arrays.  Memory usage appears tiny, compared to the limit of 20M (Increasing to 64Mb has no effect).

  The problem appears to be in the following function which basically translates the data from the shop data fields to the feed data fields.  This is called with an associative array and will return the array which is then printed or written to a file.  Some of the parts are commented out as allowing long string lengths makes the script fall over.

/**
       _formatItem maps the data from our Catalogue fields to the format required by AffiliateFuture.
       This falls over if the length of the LongDesc and ShortDesc fields are allowed to be 4000 and 1000 characters
       respectively - there is no error in the log and the error handler does not show any problems, we just get a blank screen
    */
    function _formatItem(&$item) {
        global $mem_limit;
        trigger_error("_formatItem() " .memory_get_usage() ."/" .$mem_limit);
        global $gBaseURL;
        global $gImgURL;
        $formatted = array();
       
        $formatted['ProductName'] = stripslashes($item['ProdName']);
        $formatted['Brand'] = stripslashes($item['BrandName']);
        $formatted['Category'] = stripslashes(ucwords(strtolower($this->currentCategory)));
        $formatted['Subcategory'] = stripslashes(ucwords(strtolower($this->currentSubCategory)));
        $newlines = array($this->newline, "\n");
        $desc = stripslashes(str_replace($newlines, array("  ", "  "), $item['ProdDesc']));
       
        /*Truncate "LongDescription to N characters - try to do it nicely on a fullstop then a space*/
        /*
        $max = 4000;
        $offset = 3500;
        if($max <= strlen($desc)) {
            $pos = strpos($desc, array(".", " "), $offset);
            if(FALSE != $pos) {
                $desc =   substr($desc, 0, $pos);  
            } else {
                $desc =   substr($desc, 0, $max-1);
            }
        }
        */
        $formatted['LongDescription'] = substr($desc, 0, 1000);
        /*  Repeat for short description...*/
        /*
        $max = 200;
        $offset = 150;
        if($max <= strlen($desc)) {
            $pos = strpos($desc, array(".", " "), $offset);
            if(FALSE != $pos) {
                $desc =   substr($desc, 0, $pos);  
            } else {
                $desc =   substr($desc, 0, $max-1);
            }
        }
        */
        $formatted['ShortDescription'] = substr($desc, 0, 200);
       
        $formatted['Product URL'] = $gBaseURL ."shop.php?cmd=viewitem&cat=" .$item['CategoryID'] ."&id=" .$item['ID'];
        $formatted['Image URL'] = $gImgURL ."images/catalogue/" .$item['ImageDetail'];
        //$formatted['RRP'] = $item['PriceIncVat'];
        $formatted['OfferPrice'] = $item['PriceIncVat'];
        $formatted['Availability'] = "Check Site";
        $formatted['DeliveryCost'] = $this->shippingCost;
        $formatted['DeliveryLeadDays'] = "Next Working Day";
        //$formatted['PromoText'] = "";        
        return $formatted;
    }
   
   Any light shed on this would be very useful.

    Cheers

Glen


 
[+][-]09/29/05 03:36 AM, ID: 14982512Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: PHP and Databases
Tags: catalgoue
Sign Up Now!
Solution Provided By: fibo
Participating Experts: 2
Solution Grade: A
 
[+][-]09/29/05 06:21 PM, ID: 14989185Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09/30/05 02:42 AM, ID: 14990730Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/30/05 05:37 AM, ID: 14991465Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/03/05 02:13 AM, ID: 15005051Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/05/05 01:58 PM, ID: 15025572Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/08/06 03:05 AM, ID: 15901194Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]02/12/06 11:04 AM, ID: 15935998Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89