Jump to content

max_maggot

Members
  • Content Count

    15
  • Joined

  • Last visited

Community Reputation

0 Neutral

About max_maggot

  • Rank
    Member
  • Birthday 01/12/1981

Profile Information

  • Gender
    Male
  • Location
    Ireland
  • Age
    37
  1. Ok, I think the function is firing because the defaults in my dropdown lists are not null e.g. Please Select Country is taken as a set value and therefore the form is processed by the PHP. I believe I'll have to check for these values in an IF statement and ignore the function call in that case i.e on first load of form.
  2. If it helps, I changed the following <form id="user_profile" name="user_profile" class="form-signin" onsubmit="return validateUserInput()" method="post" action="<?php $user_home->save_user_profile(); ?>" > and now the PHP function fires but the javascript does not, Here is what I get at the top of my form when I load it in the browser without clicking submit alert("message successfully sent")" >
  3. Hi all, The following code was working fine up until 1 hour ago and now fails to execute the PHP function call or anything within isset($_POST ​The JavaScript works successfully but I had to change the order in which form onsubmit and form action were called. As I said, I was getting the echo message back from the function until 1 hour ago. Here is the code. At the start of my page with the form: <?php session_start(); require_once 'class.user.php'; $user_home = new USER(); if(!$user_home->is_logged_in()) { $user_home->redirect('signin.php'); } $stmt = $user_home->runQuery("SELECT * FROM user WHERE id=:uid"); $stmt->execute(array(":uid"=>$_SESSION['userSession'])); $row = $stmt->fetch(PDO::FETCH_ASSOC); // print_r($row['learner_type']); ?> The code to check if the submit button has been clicked <?php if(isset($_POST['save_profile_changes'])) { $user_home->save_user_profile(); ?> <div class='alert alert-success alert-dismissible'> <button class='close' data-dismiss='alert'>×</button> <strong>Profile Submitted Successfully</strong> </div> <?php } else { //Left blank so it doesn't fire on form first load } ?> and the form code <form id="user_profile" name="user_profile" class="form-signin" onsubmit="return validateUserInput()" method="post" action="#"> <h2 class="form-signin-heading">Update Profile</h2> <!--Username, Email. Unchangeable for now--> <div> <strong> <label><strong>Username: </strong></label> <?php echo $row['username']; ?> <br> <label><strong>Email: </strong></label> <?php echo $row['email']; ?> </strong> <br> <a href="change_pass.php" style="padding-top:10px; font-weight: bolder">Change Password</a> <br><br> </div> <!-- First, Last Name --> <div> <input id="first_name" name="first_name" type="text" placeholder="First Name" class="form-control" minlength="2" maxlength="15" pattern="[A-Za-z]{2,15}" title="Only letters allowed" required> <input id="last_name" name="last_name" type="text" placeholder="Last Name" class="form-control" minlength="2" maxlength="25" pattern="[A-Za-z]{2,25}" title="Only letters allowed" required> </div> <!-- File Button --> <div> <label for="upload_photo">Upload Photo</label> <input class = "form-control" id="upload_photo" name="upload_photo" type="file" accept="image/*"> </div> <!-- DOB input--> <br> <div> <label for="dob">Date of Birth</label> <input id="dob" name="dob" type="date" class="form-control" min="1935-12-31" max="2014-12-31"required> </div> <!-- Gender --> <br> <div> <label for="Gender">Gender</label><br> <label class="radio-inline" for="gender-0"> <input type="radio" name="gender" id="gender-0" value="male" required> Male </label> <label class="radio-inline" for="gender-1"> <input type="radio" name="gender" id="gender-1" value="female"> Female </label> <label class="radio-inline" for="gender-2"> <input type="radio" name="gender" id="gender-2" value="other"> Other </label> </div> <!-- Region --> <br> <div> <label for="country">Select Your Country</label> <script type="text/javascript" src="assets/countries.js"></script> <select id="country" name="country" class="form-control" required></select> <script language="javascript"> populateCountries("country"); </script> </div> <!-- Occupation--> <br> <div> <label for="occupations">Select Your Occupation</label> <script type="text/javascript" src="assets/occupations.js"></script> <select id="occupations" name="occupations" class="form-control" required></select> <script language="javascript"> populateOccupations("occupations"); </script> </div> <!-- Primary Instructor Language --> <br> <div> <label for="languages">Primary Language of Instruction</label> <script type="text/javascript" src="assets/languages.js"></script> <select id="languages" name="languages" class="form-control" required></select> <script language="javascript"> populateLanguages("languages"); </script> </div> <!-- Bio --> <br> <div> <label for="bio">Bio (max 200 words)</label> <textarea class="form-control" rows="10" id="bio" name="bio" placeholder="Say a little about yourself." maxlength="200"> </textarea> </div> <!--Submission Buttons--> <hr> <div> <button class="btn btn-primary btn-common font18" type="submit" name="save_profile_changes">Save Changes</button> <a href="home.php" style="float:right; padding-top:10px;">Go Back Home</a> </div> </form> Thanks for any help you can provide.
  4. PHP XQuery AHHH

  5. I am trying to retrieve a really tricky array of values. The value I am trying to retrieve are the -price values and the text within the price tag -color values which can be more than one option (black and white in this case) <dd> <div class="input-box"> <select name="options[1216]" id="select_1216" class="product-custom-option" title="" onchange="opConfig.reloadPrice()"> <option value="" >-- Please Select --</option> <option value="4185" price="4.99" >4GB +$4.99</option> <option value="4186" price="5.99" >8GB +$5.99</option> <option value="4187" price="9.99" >16GB +$9.99</option> <option value="4188" price="16.99" >32GB +$16.99</option> <option value="4189" price="29.99" >64GB +$29.99</option> </select> </div> </dd> <dt> <label class="required"><em>*</em>Color</label></dt> <dd class="last"> <div class="input-box"> <ul id="options-1215-list" class="options-list"> <li><input type="radio" class="radio validate-one-required-by-name product-custom-option" onclick="opConfig.reloadPrice()" name="options[1215]" id="options_1215_2" value="4183" price="0" /> <span class="label"><label for="options_1215_2">Black </label></span> <script type="text/javascript"> </li> <li> <input type="radio" class="radio validate-one-required-by-name product-custom-option" onclick="opConfig.reloadPrice()" name="options[1215]" id="options_1215_3" value="4184" price="0" /> <span class="label"><label for="options_1215_3">White </label></span> </li> </ul> </div> I have wrtten the following code to try and retrieve the values of the price but to no avail. I'm trying to use a wildcard character in the xquery to try because other pages will have different option names. Here is what I came up with so far. There won't be more than 20 options on a page. Any help would be much appreciated. Thanks in advance. $option_array = array(); for($k = 1; $k <= 20; $k++) { $option_array[$k] = $xpath->query("//div[@class='input-box']//select/*/option[$k]/@price")->item(0)->textContent; //If we have captured all the images then we need to exit the for loop if($option_array[$k] == null){ break; } }
  6. Thank you both for thes relies. I made the changes and ppart of the issue was the mixing of xpath and HTMLDOM. The other issue was the for loop was incorrect. I should have had < than rather than <= Thanks again.
  7. Hi, I have two xquery statements that I can't seem to get working. I am trying to read the weight value from this site: http://www.vopmart.com/cs2013135.html I have the xquery statement $items['weight'] = $xpath->query("//div/table/tr/td[@class='et7']")->item(0)->textContent; I am also having a problem trying to retrieve the meta_keyword using this statement $items['meta_keyword'] = $xpath->query("//meta[@name='keywords']/@content")->item(0)->textContent; If anybody can spot where I am going wrong I would really appreciate it.
  8. OK, Fixed initial problem. See code snippet below. The code is still crashing out after it completes its task. Any help is much appreciated. //This function takes a all product page for a category and opens each of the pages individually //It then scrapes all the information about that product and stores the details in a CSV file function get_product_details($product_link_list) { //Open CSV file //a+ opens the file for writing and placing the pointer at the end of the file to append new data //If the file does not exist a+ will try to create the file products.csv //Appending the data to this file happens later in this function. //looping variable $i = 0; global $file_handle; //Load DOM of product page //@$html->loadHtmlFile($category_sub_page_list[$i]); while ($i <= count($product_link_list)) { //loop through each of the product details pages and scrape data { $html = new DOMDocument(); $html->loadHTMLFile($product_link_list[$i]); $xpath = new DOMXPath($html); $csv_details = ""; $html = file_get_html($product_link_list[$i]); $items = array(); //TODO: title is wrong, finish scraped values, Fix up headings at top of code. foreach ($html->find('div.main') as $article) { //capture content from website $item['title'] = $article->find('li.product', 0)->plaintext; $item['sku'] = $article->find('div.sku-no', 0)->plaintext; $item['price'] = $article->find('div.price-box', 0)->plaintext; //Capture HTML code and content for description $item['description'] = $article->find('div.std', 0)->outertext; $items['categories'] = $xpath->query("//a[@class='in-category']")->item(0)->textContent; $items['image'] = $xpath->query("//img/@src")->item(0)->textContent; //Get and Set Product Image $items['thumbnail_label'] = $xpath->query("//div[@class='highslide-caption']")->item(0)->textContent; $items['media_image'] = $xpath->query("//div[@class='highslide-gallery']//a/@href")->item(0)->textContent; $items['meta_description'] = $xpath->query("//meta[@name='description']/@content")->item(0)->textContent; $items['meta_keyword'] = $xpath->query("//meta[@name='keywords']/@content")->item(0)->textContent; //Get and Set meta keywords $item['name'] = $article->find('li.product', 0)->plaintext; $items['short_description'] = $xpath->query("//div[@class='short-description']")->item(0)->textContent; //Get and Set short description $items['small_image'] = $xpath->query("//div[@class='highslide-gallery']//a/@href")->item(0)->textContent; //Get and Set small image $items['thumbnail_label'] = $xpath->query("//div[@class='highslide-caption']")->item(0)->textContent; //Get and Set thumbnail label $items['weight'] = $xpath->query("//td[@class='et7']/text()")->item(0)->textContent; //Trim and fix values $item['title'] = str_replace(' ', '', $item['title']); $item['sku'] = str_replace('SKU:', '', $item['sku']); $item['price'] = str_replace(' ', '', $item['price']); $item['name'] = str_replace(' ', '', $item['price']); //Remove HTML code from the scraped data. $items['short_description'] = trim(preg_replace('/\s\s+/', ' ', $items['short_description'])); $items['thumbnail_label'] = trim(preg_replace('/\s\s+/', ' ', $items['thumbnail_label'])); //Assign values to temporary variables for writing to SCV $sku = $item['sku']; //Scrape $title = $item['title']; //Scrape $_store = " "; //Default value $_attribute_set = "Default"; //Default value $_type = "Simple"; //Default value $_category = $items['categories']; //Scrape $_root_category = "Default Category"; //Default value $_product_websites = "base"; //Default value $color = " "; //Default value $cost = $item['price']; //Scrape $country_of_manufacture = " "; //Set Value - No tag to get this $created_at = " "; //Default value $custom_design = "99"; //Default value $custom_design_from = "1"; //Default value $custom_design_to = " "; //Default value $custom_layout_update = " "; //Default Value $description = $item['description']; //Scrape $gallery = " "; //Default Value $gift_message_available = " "; //Default Value $has_options = "1"; //Default value $image = $items['image']; //Scrape $image_label = $items['thumbnail_label']; //Scrape $manufacturer = " "; //Default - cannot scrape $media_gallery = $items['_media_image']; //Scrape $meta_description = $items['meta_description']; //Scrape $meta_keyword = $items['meta_keyword']; //Scrape $meta_title = $item['title']; //Scrape $minimal_price = " "; //Default Value $msrp = "0"; //Default value $msrp_display_actual_price_type = "100"; //Default value $msrp_enabled = "0"; //Default value $name = $item['name']; //Scrape $news_from_date = " "; //Default value $news_to_date = " "; //Default value $options_container = "1"; //Default value $page_layout = " "; //Default value $price = $item['price']; //Scrape $required_options = "0"; //Default value $short_description = $items['short_description']; //Scrape $small_image = $items['small_image']; //Scrape $small_image_label = $items['thumbnail_label']; //Scrape $special_from_date = " "; //Default value $special_price = " "; //Default value $special_to_date = " "; //Default value $status = "1"; //Default value $tax_class_id = "1"; //Default value $thumbnail = "0"; //Default value $thumbnail_label = "1"; //Default value $updated_at = "0"; //Default value $url_key = "0"; //Default value $url_path = " "; //Default value $visibility = " "; //Default value $weight = $items['weight']; //Scrape and Ramon has Work to do $qty = "100"; //Default value $min_qty = " "; //Default value $use_config_min_qty = " "; //Default value $is_qty_decimal = " "; //Default value $backorders = " "; //Default value $use_config_backorders = " "; //Default value $min_sale_qty = " "; //Default value $use_config_min_sale_qty = " "; //Default value $max_sale_qty = " "; //Default value $use_config_max_sale_qty = " "; //Default value $is_in_stock = "1"; //Default value $notify_stock_qty = " "; //Default value $use_config_notify_stock_qty = " "; //Default value $manage_stock = "88"; //Default value $use_config_manage_stock = "0"; //Default value $stock_status_changed_auto = " "; //Default value $use_config_qty_increments = "1"; //Default value $qty_increments = " "; //Default value $use_config_enable_qty_inc = " "; //Default value $is_decimal_divided = " "; //Default value $_links_related_sku = " "; //Default value $_links_related_position = " "; //Default value $_links_crosssell_sku = " "; //Default value $_links_crosssell_position = " "; //Default value $_links_upsell_sku = " "; //Default value $_links_upsell_position = " "; //Default value $_associated_sku = "0"; //Default value $_associated_default_qty = " "; //Default value $_associated_position = "0"; //Default value $_tier_price_website = " "; //Default value $_tier_price_customer_group = " "; //Default value $_tier_price_qty = " "; //Default value $_tier_price_price = " "; //Default value $_group_price_website = " "; //Default value $_group_price_customer_group = " "; //Default value $_group_price_price = " "; //Default value $_media_attribute_id = " "; //Default value $_media_image = " "; //Default value $_media_label = " "; //Default value $_media_position = " "; //Default value $_media_is_disabled = " "; //Default value $_custom_option_store = " "; //Default value $_custom_option_type = " "; //Default value $_custom_option_title = " "; //Default value $_custom_option_is_required = " "; //Default value $_custom_option_price = " "; //Default value $_custom_option_sku = " "; //Default value $_custom_option_max_characters = " "; //Default value $_custom_option_sort_order = " "; //Default value $_custom_option_row_title = " "; //Default value $_custom_option_row_price = " "; //Default value $_custom_option_row_sku = " "; //Default value $_custom_option_row_sort = " "; //Default value $enable_config_enable_qty_inc = " "; //Default value $enable_qty_inc = " "; //Default value //Append data to CSV file $csv_details .= $sku . "," . $title . "," . $_store . "," . $_attribute_set . "," . $_type . "," . $_category . "," . $_root_category . "," . $_product_websites . "," . $color . "," . $cost . "," . $country_of_manufacture . "," . $created_at . "," . $custom_design . "," . $custom_design_from . "," . $custom_design_to . "," . "," . $custom_layout_update . "," . $description . "," . $gallery . "," . $gift_message_available . "," . $has_options . "," . $image . "," . $image_label . "," . $manufacturer . "," . $media_gallery . "," . $meta_description . "," . $meta_keyword . "," . $meta_title . "," . $minimal_price . "," . $msrp . "," . $msrp_display_actual_price_type . "," . $msrp_enabled . "," . $name . "," . $news_from_date . "," . $news_to_date . "," . $options_container . "," . $page_layout . "," . $price . "," . $required_options . "," . $short_description . "," . $small_image . "," . $small_image_label . "," . $special_from_date . "," . $special_price . "," . $special_to_date . "," . $status . "," . $tax_class_id . "," . $thumbnail . "," . $thumbnail_label . "," . $updated_at . "," . $url_key . "," . $url_path . "," . $visibility . "," . $weight . "," . $qty . "," . $min_qty . "," . $use_config_min_qty . "," . $is_qty_decimal . "," . $backorders . "," . $use_config_backorders . "," . $min_sale_qty . "," . $use_config_min_sale_qty . "," . $max_sale_qty . "," . $use_config_max_sale_qty . "," . $is_in_stock . "," . $notify_stock_qty . "," . $use_config_notify_stock_qty . "," . $manage_stock . "," . $use_config_manage_stock . "," . $stock_status_changed_auto . "," . $use_config_qty_increments . "," . $qty_increments . "," . $use_config_enable_qty_inc . "," . $qty_increments . "," . $use_config_qty_increments . "," . "," . $is_decimal_divided . "," . $_links_related_sku . "," . $_links_related_position . "," . $_links_crosssell_position . "," . $_links_crosssell_sku . "," . $_links_crosssell_position . "," . $_links_upsell_sku . "," . $_links_upsell_position . "," . $_associated_sku . "," . $_associated_default_qty . "," . $_associated_position . "," . $_tier_price_website . "," . $_tier_price_customer_group . "," . $_tier_price_qty . "," . $_tier_price_price . "," . $_group_price_website . "," . $_group_price_customer_group . "," . $_group_price_price . "," . $_media_attribute_id . "," . $_media_image . "," . $_media_label . "," . $_media_position . "," . $_media_is_disabled . "," . $_custom_option_store . "," . $_custom_option_type . "," . $_custom_option_title . "," . $_custom_option_is_required . "," . $_custom_option_price . "," . $_custom_option_sku . "," . $_custom_option_max_characters . "," . $_custom_option_sort_order . "," . $_custom_option_row_sort . "," . $_custom_option_row_title . "," . $_custom_option_row_price . "," . $_custom_option_row_sku . "," . $_custom_option_row_sort . "," . $enable_config_enable_qty_inc . "," . $enable_qty_inc . "\r\n"; fwrite($file_handle, $csv_details); //move to next product category page $i++; } } }
  9. Hi all, I I am writing a script to scrape a website. The client wants extra details captured from the website so I've had to include Xquery as well as html DOM to retrieve these values. I'm getting an error when the while loop moves from 0 to 1 which is displayed below. I know there seems like a lot of code but I believe the error is in the creation/destruction of the DOMXpath. The rest of the code is for the scrape. It moves through a list of product webpages for a category of products and scrapes the appropriate data then moves on to the next category and the product pages associated with it. The program dies on the line $xpath = new DOMXPath($html_x); whne the i variable reaches 1 (second time running through the loop). If you need the whole source code, I can PM you. This has been driving me crazy all day. Thanks for any help you can provide. It is very much appreciated. function get_product_details($product_link_list) { //Open CSV file //a+ opens the file for writing and placing the pointer at the end of the file to append new data //If the file does not exist a+ will try to create the file products.csv //Appending the data to this file happens later in this function. //looping variable $i = 0; global $file_handle; $html = new DOMDocument(); $html_x= new DOMXPath(); //Load DOM of product page //@$html->loadHtmlFile($category_sub_page_list[$i]); while ($i <= count($product_link_list)) { //loop through each of the product details pages and scrape data { $html->loadHTMLFile($product_link_list[$i]); $xpath = new DOMXPath($html_x); $csv_details = ""; $html = file_get_html($product_link_list[$i]); $items = array(); //TODO: title is wrong, finish scraped values, Fix up headings at top of code. foreach ($html->find('div.main') as $article) { //capture content from website $item['title'] = $article->find('li.product', 0)->plaintext; $item['sku'] = $article->find('div.sku-no', 0)->plaintext; $item['price'] = $article->find('div.price-box', 0)->plaintext; //Capture HTML code and content for description $item['description'] = $article->find('div.std', 0)->outertext; $items['categories'] = $xpath->query("//a[@class='in-category']")->item(0)->textContent; $items['image'] = $xpath->query("//img/@src")->item(0)->textContent; //Get and Set Product Image $items['thumbnail_label'] = $xpath->query("//div[@class='highslide-caption']")->item(0)->textContent; $items['media_image'] = $xpath->query("//div[@class='highslide-gallery']//a/@href")->item(0)->textContent; $items['meta_description'] = $xpath->query("//meta[@name='description']/@content")->item(0)->textContent; $items['meta_keyword'] = $xpath->query("//meta[@name='keywords']/@content")->item(0)->textContent; //Get and Set meta keywords $item['name'] = $article->find('li.product', 0)->plaintext; $items['short_description'] = $xpath->query("//div[@class='short-description']")->item(0)->textContent; //Get and Set short description $items['small_image'] = $xpath->query("//div[@class='highslide-gallery']//a/@href")->item(0)->textContent; //Get and Set small image $items['thumbnail_label'] = $xpath->query("//div[@class='highslide-caption']")->item(0)->textContent; //Get and Set thumbnail label $items['weight'] = $xpath->query("//td[@class='et7']/text()")->item(0)->textContent; //Trim and fix values $item['title'] = str_replace(' ', '', $item['title']); $item['sku'] = str_replace('SKU:', '', $item['sku']); $item['price'] = str_replace(' ', '', $item['price']); $item['name'] = str_replace(' ', '', $item['price']); //Remove HTML code from the scraped data. $items['short_description'] = trim(preg_replace('/\s\s+/', ' ', $items['short_description'])); $items['thumbnail_label'] = trim(preg_replace('/\s\s+/', ' ', $items['thumbnail_label'])); //Assign values to temporary variables for writing to SCV $sku = $item['sku']; //Scrape $title = $item['title']; //Scrape $_store = " "; //Default value $_attribute_set = "Default"; //Default value $_type = "Simple"; //Default value $_category = $items['categories']; //Scrape $_root_category = "Default Category"; //Default value $_product_websites = "base"; //Default value $color = " "; //Default value $cost = $item['price']; //Scrape $country_of_manufacture = " "; //Set Value - No tag to get this $created_at = " "; //Default value $custom_design = "99"; //Default value $custom_design_from = "1"; //Default value $custom_design_to = " "; //Default value $custom_layout_update = " "; //Default Value $description = $item['description']; //Scrape $gallery = " "; //Default Value $gift_message_available = " "; //Default Value $has_options = "1"; //Default value $image = $items['image']; //Scrape $image_label = $items['thumbnail_label']; //Scrape $manufacturer = " "; //Default - cannot scrape $media_gallery = $items['_media_image']; //Scrape $meta_description = $items['meta_description']; //Scrape $meta_keyword = $items['meta_keyword']; //Scrape $meta_title = $item['title']; //Scrape $minimal_price = " "; //Default Value $msrp = "0"; //Default value $msrp_display_actual_price_type = "100"; //Default value $msrp_enabled = "0"; //Default value $name = $item['name']; //Scrape $news_from_date = " "; //Default value $news_to_date = " "; //Default value $options_container = "1"; //Default value $page_layout = " "; //Default value $price = $item['price']; //Scrape $required_options = "0"; //Default value $short_description = $items['short_description']; //Scrape $small_image = $items['small_image']; //Scrape $small_image_label = $items['thumbnail_label']; //Scrape $special_from_date = " "; //Default value $special_price = " "; //Default value $special_to_date = " "; //Default value $status = "1"; //Default value $tax_class_id = "1"; //Default value $thumbnail = "0"; //Default value $thumbnail_label = "1"; //Default value $updated_at = "0"; //Default value $url_key = "0"; //Default value $url_path = " "; //Default value $visibility = " "; //Default value $weight = $items['weight']; //Scrape and Ramon has Work to do $qty = "100"; //Default value $min_qty = " "; //Default value $use_config_min_qty = " "; //Default value $is_qty_decimal = " "; //Default value $backorders = " "; //Default value $use_config_backorders = " "; //Default value $min_sale_qty = " "; //Default value $use_config_min_sale_qty = " "; //Default value $max_sale_qty = " "; //Default value $use_config_max_sale_qty = " "; //Default value $is_in_stock = "1"; //Default value $notify_stock_qty = " "; //Default value $use_config_notify_stock_qty = " "; //Default value $manage_stock = "88"; //Default value $use_config_manage_stock = "0"; //Default value $stock_status_changed_auto = " "; //Default value $use_config_qty_increments = "1"; //Default value $qty_increments = " "; //Default value $use_config_enable_qty_inc = " "; //Default value $is_decimal_divided = " "; //Default value $_links_related_sku = " "; //Default value $_links_related_position = " "; //Default value $_links_crosssell_sku = " "; //Default value $_links_crosssell_position = " "; //Default value $_links_upsell_sku = " "; //Default value $_links_upsell_position = " "; //Default value $_associated_sku = "0"; //Default value $_associated_default_qty = " "; //Default value $_associated_position = "0"; //Default value $_tier_price_website = " "; //Default value $_tier_price_customer_group = " "; //Default value $_tier_price_qty = " "; //Default value $_tier_price_price = " "; //Default value $_group_price_website = " "; //Default value $_group_price_customer_group = " "; //Default value $_group_price_price = " "; //Default value $_media_attribute_id = " "; //Default value $_media_image = " "; //Default value $_media_label = " "; //Default value $_media_position = " "; //Default value $_media_is_disabled = " "; //Default value $_custom_option_store = " "; //Default value $_custom_option_type = " "; //Default value $_custom_option_title = " "; //Default value $_custom_option_is_required = " "; //Default value $_custom_option_price = " "; //Default value $_custom_option_sku = " "; //Default value $_custom_option_max_characters = " "; //Default value $_custom_option_sort_order = " "; //Default value $_custom_option_row_title = " "; //Default value $_custom_option_row_price = " "; //Default value $_custom_option_row_sku = " "; //Default value $_custom_option_row_sort = " "; //Default value $enable_config_enable_qty_inc = " "; //Default value $enable_qty_inc = " "; //Default value //Append data to CSV file $csv_details .= $sku . "," . $title . "," . $_store . "," . $_attribute_set . "," . $_type . "," . $_category . "," . $_root_category . "," . $_product_websites . "," . $color . "," . $cost . "," . $country_of_manufacture . "," . $created_at . "," . $custom_design . "," . $custom_design_from . "," . $custom_design_to . "," . "," . $custom_layout_update . "," . $description . "," . $gallery . "," . $gift_message_available . "," . $has_options . "," . $image . "," . $image_label . "," . $manufacturer . "," . $media_gallery . "," . $meta_description . "," . $meta_keyword . "," . $meta_title . "," . $minimal_price . "," . $msrp . "," . $msrp_display_actual_price_type . "," . $msrp_enabled . "," . $name . "," . $news_from_date . "," . $news_to_date . "," . $options_container . "," . $page_layout . "," . $price . "," . $required_options . "," . $short_description . "," . $small_image . "," . $small_image_label . "," . $special_from_date . "," . $special_price . "," . $special_to_date . "," . $status . "," . $tax_class_id . "," . $thumbnail . "," . $thumbnail_label . "," . $updated_at . "," . $url_key . "," . $url_path . "," . $visibility . "," . $weight . "," . $qty . "," . $min_qty . "," . $use_config_min_qty . "," . $is_qty_decimal . "," . $backorders . "," . $use_config_backorders . "," . $min_sale_qty . "," . $use_config_min_sale_qty . "," . $max_sale_qty . "," . $use_config_max_sale_qty . "," . $is_in_stock . "," . $notify_stock_qty . "," . $use_config_notify_stock_qty . "," . $manage_stock . "," . $use_config_manage_stock . "," . $stock_status_changed_auto . "," . $use_config_qty_increments . "," . $qty_increments . "," . $use_config_enable_qty_inc . "," . $qty_increments . "," . $use_config_qty_increments . "," . "," . $is_decimal_divided . "," . $_links_related_sku . "," . $_links_related_position . "," . $_links_crosssell_position . "," . $_links_crosssell_sku . "," . $_links_crosssell_position . "," . $_links_upsell_sku . "," . $_links_upsell_position . "," . $_associated_sku . "," . $_associated_default_qty . "," . $_associated_position . "," . $_tier_price_website . "," . $_tier_price_customer_group . "," . $_tier_price_qty . "," . $_tier_price_price . "," . $_group_price_website . "," . $_group_price_customer_group . "," . $_group_price_price . "," . $_media_attribute_id . "," . $_media_image . "," . $_media_label . "," . $_media_position . "," . $_media_is_disabled . "," . $_custom_option_store . "," . $_custom_option_type . "," . $_custom_option_title . "," . $_custom_option_is_required . "," . $_custom_option_price . "," . $_custom_option_sku . "," . $_custom_option_max_characters . "," . $_custom_option_sort_order . "," . $_custom_option_row_sort . "," . $_custom_option_row_title . "," . $_custom_option_row_price . "," . $_custom_option_row_sku . "," . $_custom_option_row_sort . "," . $enable_config_enable_qty_inc . "," . $enable_qty_inc . "\r\n"; fwrite($file_handle, $csv_details); //move to next product category page $i++; } } }
  10. Thanks for your answer Ch0cu3r. I found a xpath query generator and noticed the mistake. http://xmltoolbox.appspot.com/xpath_generator.html Thanks for your help
  11. Figured it out myself. I should have taken 5 more minutes $items[price] = $xpath->query("//div[@class='price-box']/span[@class='regular-price']/span[@class='price']")->item(0)->textContent;
  12. <div class="price-box"> <span class="regular-price" id="product-price-13129" itemtype="http://schema.org/Offer" itemscope="" itemprop="offers"> <span class="price" itemprop="price">$9.80</span> </span> </div> Hi all, In the above HTML code I am using the following xpath query to try and retrieve the price value ($9.80). I can't seem to get the query correct. Here is what I have come up with so far $items[price] = $xpath->query("//div[@class='price-box']//span/[@class='regular-price']//span/[@class='price']")->item(0)->textContent; //Get and Set price Any help or direction would be greatly appreciated.
  13. Figured it out. Forgot @ in the line foreach($html->find('div.main')as $node) Should read foreach($html->find(//'div[@class=main]')as $node) 6 hours of my life gone
  14. PS. I've also tried foreach($html->find('div[class=main]')as $node) unsuccesfully
×
×
  • 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.