Jump to content

[Solved] Prestashop Add Custom URL Field


Recommended Posts

Finally I have done adding a URL field in product page. I was looking for it so that I can setup my affiliate shop easily and in the same time can enjoy all other prestashop features.

I have modified a tutorial by Kerm a little more for the purpose. Check the steps below.


In AdminProducts.php add following:

'.$this->l('Affiliate URL:').' 
<input size="55" type="text" name="affurl" value="'.htmlentities($this->getFieldValue($obj, 'affurl'), ENT_COMPAT, 'UTF-8').'" style="width: 130px; margin-right: 44px;" />

'.$this->l('Enter Your Affiliate URL including http://').'



in classes/product.php add following:

    /** @var string affurl */ 
   public  $affurl;



where public function getFields() add:

$fields['affurl'] = psql($this->affurl);



In your theme product.tpl add:

{if not $product->affurl==0}affurl|escape:'htmlall':'UTF-8'}" target="_blank" id="buy-now">{l s=''}{/if}



In your theme css/product.css add:

#buy-now {
   background: #f1f2f4 url(../img/button.jpg) repeat-x top left;
   font-size: 1.1em;
   color: #374853;
   margin-bottom: 1.5em;
   display: block;
   width: 200px;
   height: 50px;
}



In phpmyadmin, add new field in ps_product table, with name affurl with this parameters:

Type: varchar(255), utf8_general_ci, NULL Yes, default NULL

Design button.jpg and upload it in your theme's image folder.

I will update a link to website soon with working model of above tutorial.

Link to comment
Share on other sites

  • 2 weeks later...
  • 5 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...