Magento – Upload file code

Share
Posted on September 19th, 2014 | Posted by admin
1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
$post = $this->getRequest()->getPost();
//var_dump($post); die;
if(isset($_FILES['file']['name']) && (file_exists($_FILES['file']['tmp_name']))) {
  try {

 $uploader = new Varien_File_Uploader('file');
 $uploader->setAllowedExtensions(array('pdf','doc','png','jpg')); // or pdf or anything

 $uploader->setAllowRenameFiles(false);
 // setAllowRenameFiles(true) -> move your file in a folder the magento way
 // setAllowRenameFiles(true) -> move your file directly in the $path folder
 $uploader->setFilesDispersion(false);

Running PHP Scripts on CLI and Faking a Web Request

Share
Posted on September 18th, 2014 | Posted by admin

Some times you build a PHP script that is designed to run from a web request and you want to run it on the command line. The problem is that you have used the standard PHP super globals and you would rather not refactor the script loads.

Here is a nice quick solution:

if(isset($argc)){
    for ($i = 1; $i < $argc; $i++) {
      $things = explode("=", $argv[$i]);
        if (false !== stripos($things[0], 'POST:')) {
             $post = str_replace('POST:', '', $things[0]);
             $_POST[$post] = $things[1];

Magento – Request and Post parameters in controllers

Share
Posted on September 15th, 2014 | Posted by admin

To get the parameters passed in the controllers use the following code.

Retrieve URI parameters.

$params = $this->getRequest()->getParams();
$id = $params["id"];
$name = $params["name"];

Retrieve Post parameters.

$id =$this->getRequest()->getPost("id");
$name = $this->getRequest()->getPost("name");

- See more at: http://www.techdilate.com/code/magento-request-and-post-parameters-in-controllers/#sthash.T5u5Xv5q.dpuf

Bizarre – Responsive Magento Theme

Share
Posted on September 13th, 2014 | Posted by admin

Bizarre – Responsive Magento Theme

Since we are authors of just theme, we do not provide support which concerns any 3-rd party extensions, including modules that comes with theme.
Support is provided only via ticket system. All ticket are handled in queue, that’s why the reply make take up to two working days. Be patience please. We recommend to create ticket with maximum information about issue. In that case you will get answer faster.

Magento error: Exception printing is disabled by default for security reasons

Share
Posted on September 12th, 2014 | Posted by admin

Magento Error
There has been an error processing your request
Exception printing is disabled by default for security reasons.
Error log record number: 793079875677

Solution
If you get the above error in Magento, try the following solution:
1) In your File Manager (or FTP client), go to your Magento folder.
2) Rename file “errors/local.xml.sample” to “errors/local.xml”.

Page 1 of 15912345»102030...Last »