Automotive Lighting upgrades
http://www.BriteLightLEDs.co.uk
This is definitely not the most well written as this was a really quick job, but does work.
Code: Select all
<?php
################
# Written By: #
# Lawrence Shea#
# for OpenCart #
#AddPriceToMeta#
################
include 'config.php';
# VARIABLES #
$tagline = 'Get it now for';
$currency = '$';
# VARIABLES #
$connect = mysql_connect(DB_HOSTNAME,DB_USERNAME,DB_PASSWORD);
mysql_select_db(DB_DATABASE,$connect);
$data = mysql_query("SELECT * FROM `".DB_PREFIX."product` WHERE 1")
or die(mysql_error());
while($row = mysql_fetch_assoc($data)) { ?>
<?php $price = $row["price"]; $price = explode('.',$price); $pid = $row["product_id"];
echo '===GOT NEW PRODUCT===<br>Product ID ->'.$pid.'<br><br>';
echo 'Got Price of '.$price[0].' For Product Id '.$pid.'<br><br>';
$data1 = mysql_query("SELECT * FROM `".DB_PREFIX."product_description` WHERE `product_id`=$pid")
or die(mysql_error());
while($row2 = mysql_fetch_assoc($data1)) {
$meta = $row2["meta_description"];
echo 'Got Meta Description '.$meta.'For Product Id '.$pid.'<br><br>';
$metaprice = $meta.' '.$tagline.' '.$currency.$price[0];
mysql_query("UPDATE `".DB_PREFIX."product_description` SET `meta_description`='$metaprice' WHERE `product_id`=$pid") or die(mysql_error());
echo 'Changed Meta Description '.$metaprice.'<br><br>';
}
}
?>
As with anything that directly edits your DB, you should first make a backup. I am not responsible for anything bad that happens to your DB if you choose to run this script.
You should only run this once, because there's no check in place for multiple runs, and it will just continually add the price to the end of the description... so you would get something like...
'META_DESCRIPTION' Get it now for only $100 Get it now for only $100 Get it now for only $100 Get it now for only $100 Get it now for only $100 Get it now for only $100 Get it now for only $100 Get it now for only $100...etc..
Attachments
Adds price to meta description
[module] PayPal Pro w/Recurring Profiles FREE
[module] 1 Click "Amazon Style" Checkout w/PayPal Pro FREE
[module] Adjustable PayPal Pro Fee FREE
[module] Add Sample To Cart LITE FREE
The guide to fixing just about everything wrong with OpenCart FREE!
Add INFINITE SCROLL to your homepage for FREE!
Live update product price for FREE!
Dynamic generation of Opencart coupon, FREE!
Hire me
Code: Select all
update `product_description` pd inner join `product` p on pd.product_id = p.`product_id` set pd.`meta_description` = p.`price`;
Code: Select all
update `product_description` pd inner join `product` p on pd.product_id = p.`product_id` set pd.`meta_description` = concat("get ", pd.`name`, " for only $", format(p.`price`,2));
Automotive Lighting upgrades
http://www.BriteLightLEDs.co.uk
[module] PayPal Pro w/Recurring Profiles FREE
[module] 1 Click "Amazon Style" Checkout w/PayPal Pro FREE
[module] Adjustable PayPal Pro Fee FREE
[module] Add Sample To Cart LITE FREE
The guide to fixing just about everything wrong with OpenCart FREE!
Add INFINITE SCROLL to your homepage for FREE!
Live update product price for FREE!
Dynamic generation of Opencart coupon, FREE!
Hire me
I'm not sure who you were adressing here but the sql i provided will replace meta-description. If you need to append to it you can write:Brite Light LEDs wrote:by doing this will i loose any current text that im using in the meta description ?
Code: Select all
update `product_description` pd inner join `product` p on pd.product_id = p.`product_id` set pd.`meta_description` = concat(pd.`meta_description`, "get ", pd.`name`, " for only $", format(p.`price`,2));
Find:
Code: Select all
$this->document->setDescription($product_info['meta_description']);
Code: Select all
$this->document->setDescription($product_info['meta_description'] . 'Get it for only ' . $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))));
Code: Select all
$this->document->setDescription($product_info['meta_description'] . 'Get it for only ' . $this->currency->format($product_info['price']));
This way, the price is not hard coded into the description and will update whenever there is a price change.
Google Product Feed - Get your products into Google Shopping. Includes a bulk update facility.
Backup Pro - Backup (on demand or scheduled), Restore and Clone your store.
Freestyle Box - Add multiple information boxes on multiple pages of your store. Includes optional "Code Mode".
View my other extensions
[module] PayPal Pro w/Recurring Profiles FREE
[module] 1 Click "Amazon Style" Checkout w/PayPal Pro FREE
[module] Adjustable PayPal Pro Fee FREE
[module] Add Sample To Cart LITE FREE
The guide to fixing just about everything wrong with OpenCart FREE!
Add INFINITE SCROLL to your homepage for FREE!
Live update product price for FREE!
Dynamic generation of Opencart coupon, FREE!
Hire me
running custom theme
Automotive Lighting upgrades
http://www.BriteLightLEDs.co.uk
Yes, thats right. The code you have changed puts the Meta Description information you can see PLUS the price information in the meta description tags on the product page at the store front.Brite Light LEDs wrote:Tried that just curious, go to EDIT and shows same Metatag description - no price ?
Browse to one of your products, view the source and look for the code:
Code: Select all
<meta name="description" content="Meta Description - Get it for £50" />
Google Product Feed - Get your products into Google Shopping. Includes a bulk update facility.
Backup Pro - Backup (on demand or scheduled), Restore and Clone your store.
Freestyle Box - Add multiple information boxes on multiple pages of your store. Includes optional "Code Mode".
View my other extensions
Automotive Lighting upgrades
http://www.BriteLightLEDs.co.uk
[module] PayPal Pro w/Recurring Profiles FREE
[module] 1 Click "Amazon Style" Checkout w/PayPal Pro FREE
[module] Adjustable PayPal Pro Fee FREE
[module] Add Sample To Cart LITE FREE
The guide to fixing just about everything wrong with OpenCart FREE!
Add INFINITE SCROLL to your homepage for FREE!
Live update product price for FREE!
Dynamic generation of Opencart coupon, FREE!
Hire me
If you go with the latter, when you update your prices, you will need to edit the meta descriptions individually; it would require really complex coding to strip out the old price and replace with the new in that situation.
Regards
Google Product Feed - Get your products into Google Shopping. Includes a bulk update facility.
Backup Pro - Backup (on demand or scheduled), Restore and Clone your store.
Freestyle Box - Add multiple information boxes on multiple pages of your store. Includes optional "Code Mode".
View my other extensions
[module] PayPal Pro w/Recurring Profiles FREE
[module] 1 Click "Amazon Style" Checkout w/PayPal Pro FREE
[module] Adjustable PayPal Pro Fee FREE
[module] Add Sample To Cart LITE FREE
The guide to fixing just about everything wrong with OpenCart FREE!
Add INFINITE SCROLL to your homepage for FREE!
Live update product price for FREE!
Dynamic generation of Opencart coupon, FREE!
Hire me
I have no knowledge of how the Facebook links work
Google Product Feed - Get your products into Google Shopping. Includes a bulk update facility.
Backup Pro - Backup (on demand or scheduled), Restore and Clone your store.
Freestyle Box - Add multiple information boxes on multiple pages of your store. Includes optional "Code Mode".
View my other extensions
Automotive Lighting upgrades
http://www.BriteLightLEDs.co.uk
The purpose of the script I proposed was to add the price to the (hidden) meta description tag which is on the store product page and often used by Google as the snippet in the search results. You won't see the combined result in the Admin Control Panel.
I thought that was what you wanted. You've since clarified your requirement.
Can you post a couple of screenshots of what is appearing on screen and what you want to see?
I think that tacobanditos solution would work for you, but it will be a royal pain whenever you update your prices.
Google Product Feed - Get your products into Google Shopping. Includes a bulk update facility.
Backup Pro - Backup (on demand or scheduled), Restore and Clone your store.
Freestyle Box - Add multiple information boxes on multiple pages of your store. Includes optional "Code Mode".
View my other extensions
Automotive Lighting upgrades
http://www.BriteLightLEDs.co.uk
My one-off solution would certainly make it slightly more time consuming to update a price, as you would need to edit the meta description along with the price when those change, or when adding new products.justcurious wrote:I think that tacobanditos solution would work for you, but it will be a royal pain whenever you update your prices.
That said, even I'm suggesting that you use justcurious's solution. It's better than mine.
[module] PayPal Pro w/Recurring Profiles FREE
[module] 1 Click "Amazon Style" Checkout w/PayPal Pro FREE
[module] Adjustable PayPal Pro Fee FREE
[module] Add Sample To Cart LITE FREE
The guide to fixing just about everything wrong with OpenCart FREE!
Add INFINITE SCROLL to your homepage for FREE!
Live update product price for FREE!
Dynamic generation of Opencart coupon, FREE!
Hire me
Meta Description is an HTML tag designed to allow website owners to put a short description in the website code to help the search engines work out what your page is about.
Over time, Google has started using this description as the "snippet" in the search results when there is not much information actually showing on the page.
Although the Meta Description is included in the HTML, it is not displayed anywhere on the page.
To use an example from your own website:
In the search results, you can see that for the home page, the "snippet" is the same as your meta description, but for the product "BMW E60/E61LCI Angel Eye 5w 7000k White CREE LED ...", Google has used information from the product description as it has judged that the product description provides better information than the meta description.
Here is how the HTML appears. This is the section of HTML that the code that I suggested earlier would affect:
There is a different section of code that creates your Facebook Links - that is what you need to edit. Do you have an extension that creates the fb links for you?
Google Product Feed - Get your products into Google Shopping. Includes a bulk update facility.
Backup Pro - Backup (on demand or scheduled), Restore and Clone your store.
Freestyle Box - Add multiple information boxes on multiple pages of your store. Includes optional "Code Mode".
View my other extensions
Users browsing this forum: No registered users and 337 guests