Tuesday, May 21, 2013

Prestashop adding image field

To add in admin as a list field:
override/controllers/admin/Admin[Name]Controller.php
in __construct():

$this->fieldImageSettings = array(
  'name' => 'image', //form name
  'dir' => 'name'//img/name
);
$this->imageType = "jpg";


in __construct() or ajaxProcessDetails(): //depending on extended controller

$this->fields_list['image'] = array(
  'title' => $this->l('Image'),
  'width' => 70,
  "image" => $this->fieldImageSettings["dir"]
);

if helper is generated manually:
//$this->setHelperDisplay($helper); // this is full helper
$helper->imageType = $this->imageType;

in __construct() or renderForm or renderForm[Name] //depending on extended controller
$this->fields_form["input"][] = array(
  'type' => 'file',
  'label' => $this->l('Image:'),
  'name' => 'image',
  'required' => false,
  'display_image' => true
);

In override/classes/modelname.php
in __construct():
$this->image_dir = "name"; //points to same path as fieldImageSettings["dir"] above

if you generate custom thumb based on alias name, makesure to clear all cache files in tmp with this additional function in Model Class:

public function deleteImage($force_delete = false) {
    $res = parent::deleteImage($force_delete);
 
    if ($res) {
      //clear cached file
      $files = array(
        $table.'_mini_'.$this->id.'.'.$type,
        $table.'_thumb_'.$this->id.'.'.$type
    );
    foreach($files as $file) {
      if (file_exists(_PS_TMP_IMG_DIR_.$file)) {
        unlink(_PS_TMP_IMG_DIR_.$file);
      }
    }
   
    }
  return $res;
}




Wednesday, May 15, 2013

Prestashop form field type

Adminisration notes:

the template for default form helper is located @
[path-to-project]/[admin-path]/themes/default/template/helper/form/form.tpl

the template for default listing helper is located @
[path-to-project]/[admin-path]/themes/default/template/helper/list/list.tpl

if you want to override the form template,
create the file or copy a pre-made template to:
[path-to-project]/[admin-path]/themes/default/template/controllers/[yourcontrollername]/helpers/form/form.tpl

eg:
AdminMyAdminController form helper in

[path-to-project]/[admin-path]/themes/default/template/controllers/my_admin/helpers/form/form.tpl


If you want to know all other supported form type, locate the smarty form functions @
[path-to-project]/tools/smarty/plugins/function.[name].php

Monday, May 13, 2013

prestashop Undefined index: unifunc in

I came across this issue while trying to get a module hook output.
it turn out that if i tried to get instance of a module and render its hook,
and then try to return my own output for my hook, the $this->display will cause error: Undefined index: unifunc in ...


Thursday, May 2, 2013

changing hostname on centos vps

if you are using solus vps, just login into solus control panel, click on vps and click on hostname and change the hostname.

after some tinker, i realize changing /etc/hosts nor /etc/sysconfig/network seems to revert back after reboot

GoDaddy VPS SUCKS!


  • Customer
    hi
    6:10:34 PM
  • Customer
    im facing slow email
    6:10:40 PM
  • Jiri S
    Hello, how can I help you?
    6:10:44 PM
  • Customer
    some of my email hang in queue
    6:10:45 PM
  • Customer
    [root@ip-[hidden] script]# /var/qmail/bin/qmail-qread
    2 May 2013 08:57:43 GMT  #29037308  1152  reeve@hidden
      done remote fteo@[hidden]
      done remote lng@[hidden]
           remote sandra@[hidden]
      done remote wteo@[hidden]
    
    2 May 2013 10:01:16 GMT  #29033403  723  test@hidden
     remote james@hidden-gmail-server
    6:10:55 PM
  • Customer
    the mail is sent about an hour ago
    6:11:08 PM
  • Customer
    initially 2 is sent, but the rest 2 was hanging there
    6:11:26 PM
  • Customer
    did u defer my mail?
    6:11:36 PM
  • Customer
    its going extremely slow
    6:12:21 PM
  • Jiri S
    We would not make changes to the configuration of your email.
    6:12:44 PM
  • Jiri S
    However.
    6:12:47 PM
  • Jiri S
    If the relay has to process larger volume of emails than usual,
    6:13:06 PM
  • Jiri S
    it is possible that some of the email would not be accepted by the relay.
    6:13:26 PM
  • Jiri S
    Email is not an instant service and sometimes can become backed up and queued on your server. We are unable to guarantee instant delivery as Simple Mail Transfer Protocol (SMTP) is not designed to do so. RFC 821, RFC 2821, RFC 5321, and others, contain technical specifications. The inclusion of sections relating to sending, receiving, and retry strategies; and the nature of global telecommunications networks imply that instant delivery is neither intended, expected, nor guaranteed. The retry time frames specified in the sending strategies support this conclusion. That is not to say that we do not strive to minimize delivery time; it just says that it cannot be guaranteed.
    6:13:36 PM
  • Customer
    noo
    6:14:11 PM
  • Customer
    i cant accept such delay
    6:14:21 PM
  • Customer
    my server is already on low traffic
    6:14:28 PM
  • Customer
    less than 5 accounts using it and the mail isnt much in the queue
    6:14:37 PM
  • Customer
    and why would u take 1 hour to send a single queue?
    6:14:48 PM
  • Customer
    THIS IS NOT ACCEPTABLE
    6:14:59 PM
  • Customer
    if your relay is unable to service my server, then please consider adding more proxy
    6:16:02 PM
  • Customer
    upgrading ur system to handle more loads
    6:16:09 PM
  • Customer
    you cannot be allowing this kind of delay to happen
    6:16:24 PM
  • Customer
    ELSE just open up port 25 so that my server can flow my own email
    6:16:44 PM
  • Customer
    fyi, ive 3 servers on your services
    6:17:03 PM
  • Customer
    and im responsible for every single client using it.
    6:17:15 PM
  • Customer
    if you guys are always giving me this kind of service problem and delay
    6:17:26 PM
  • Customer
    how am i suppose to answer my client?
    6:17:31 PM
  • Customer
    ive been sitting here trying to figure out what went wrong
    6:17:49 PM
  • Customer
    just now even cant connect to your smtp proxy on port 25
    6:17:58 PM
  • Customer
    it failed to connect
    6:18:01 PM
  • Customer
    r u having ddos attack internally?
    6:18:06 PM
  • Customer
    look, my queue is almost empty
    6:18:40 PM
  • Jiri S
    These are standards for email
    6:18:48 PM
  • Customer
    left 2 in the queue since i started wthis chat with u , and now its still 2 in the queue pending
    6:18:59 PM
  • Jiri S
    as you can see if you lookup the email standards mentioned above.
    6:19:01 PM
  • Customer
    wtf is going on????
    6:19:03 PM
  • Customer
    look @ this, no change since start of this chat!
    6:19:31 PM
  • Customer
    root@ip-[hidden]script]# /var/qmail/bin/qmail-qread
    2 May 2013 08:57:43 GMT  #29037308  1152  reeve@[hidden]
      done remote fteo@hidden
      done remote lng@hidden
     remote sandra@hidden
      done remote wteo@hidden
    2 May 2013 10:01:16 GMT  #29033403  723  test@hidden
    6:19:32 PM
  • Customer
    pls dont give me excuses, i want answer to the delay
    6:20:56 PM
  • Jiri S
    We are unable to guarantee instant delivery as Simple Mail Transfer Protocol (SMTP) is not designed to do so. RFC 821, RFC 2821, RFC 5321, and others, contain technical specifications.
    6:21:29 PM
  • Jiri S
    I would recommend reviewing those.
    6:21:37 PM
  • Customer
    dont talk nonsense
    6:21:39 PM
  • Customer
    ive another server in us, and ive over 30 domains on it and its running fine!
    6:22:01 PM
  • Customer
    ive no queue stuck
    6:22:47 PM
  • Customer
    you guys must just admited that your idea of smtp proxy SUCKS!
    6:23:00 PM
  • Customer
    if you cant handle those mail volumes, then pls reconsider opening up port 25
    6:23:20 PM
  • Customer
    so please.. i need answer