Magento – Upload file code

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

<?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);

Request and Post parameters in controllers magento

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

To get the parameters magento 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");

Pass data from controller to view in magento

Share
Posted on August 26th, 2014 | Posted by admin

t’s may be very easy for Zend framework user But, I find some magento developer fighting to pass data from controller to view.
In magento you have to create a empty model(if your mod don’t have a varient object model) which extends to varient object. Magento use magic getter magic setter so you can pass value by setAnyname() and getAnyname() thus functions will be auto defines by Zend like many other framework do.

Model file:

get Attribute Options of the dropdown type attribute in Magento

Share
Posted on August 25th, 2014 | Posted by admin

For the attributes attribute in Magento which have a frontend type “Select” we need to define options that on the product page converted into a dropdown. For example attribute color may have options Red, Green, Blue etc. which are defined in the admin area.

We can easily collect all the defined options for any attribute.

This code will return all options of attribute “color”

// use your own attribute code here
$attribute_code = "color";
$attribute_details = Mage::getSingleton("eav/config")->getAttribute("catalog_product", $attribute_code);
$options = $attribute_details->getSource()->getAllOptions(false);
Foreach($options as $option){
	// print_r($option) and find all the elements
	echo $option["value"];
	echo $option["label"];
}

X-Cart and Magento, What is the difference?

Share
Posted on May 26th, 2013 | Posted by admin

Want to make your online business highly profitable? Then you need a platform that will be able to handle thousand of products, clients and orders. Moreover, you will need a shopping cart that will provide you with various design and customization options to fulfill 100% of your client’s needs.

To keep it short and clear two popular solutions can be offered to meet all these requirements: X-Cart and Magento. And here is a short fact review mentioning ‘X-Cart and Magento, What is the difference?’  magento vs x cart  will help you make a decision which cart is better for your business.

Background

X-Cart – a PHP based and open source solution. Comes as a licensed paid cart. Can offer flexible pricing so it will suit for any size and type of business. Powers more than 25 000 online stores.

Magento shopping cart – a PHP and Zend Framework based platform. It is current leader in the world of eCommerce. It powers more than 125 000 shops and recognized as the most flexible and scalable solution in the world. The platform comes in several options including both free and paid editions.

Common Features

Due to their open source structure both carts share some beneficial common features:

  • Product Management. Add unlimited number of products, categories and images. Sell any type of products including physical and virtual goods. Manage your items in categories, add options and attributes.
  • Shipping and Payment. Hundreds of options that include virtually all major payment and shipment gateways, such as PayPal, Google Checkout, 2Checkout, UPS, DHL, FedEX, etc. If some special option is not available most likely you will find a module that will enable this feature.
  • Design. Use one of free templates and customize it the way you like. Or create your own theme. Basically you have no limits since you have a full access to CSS and HTML files, etc. Other great features include multi-store (ability to run several stores via one admin panel), high security standards (PCI compliance), multiple currencies and language support.

Specific Features

Each cart has its own peculiarities and competitive advantages. So, let us check what is the difference between running an X-Cart store and Magento store:

  • Usability. Nevertheless, X-Cart is much more user-friendly and intuitive solution than Magento. In case if you don’t have a lot of experience with PHP and HTML programming than X-Cart is definitely an easier platform to go with.
  • Extensions. Magento comes with bigger set of features and has a lot more extensions than X-Cart. If you need any feature which is not there by default simply go to Magento Connect marketplace and you will find it there.
  • Speed. Magento is generally known as powerful but very resource consuming solution that may be quite slow if you run it on a hared server. You can speed it up by doing some performance optimization but it will require time and efforts. X-Cart is less resource consuming and can be easily set up at shared server. Moreover, it is fast without any additional optimization.

Definitely both shopping carts can perfectly suit your business if you have enough programming skills or good budget to hire a developer. However, as it was stated, X-Cart is more user-friendly while Magento is more flexible and has better set of default functions. So, before making a final decision try each solution for free. X-Cart offers unlimited trial version and Magento provides you with totally free Community edition.

Page 4 of 90« First...«23456»102030...Last »