add category tree structure in magento

this post we will see how generate a category tree, recursively showing all categories and sub categories. Preparing function in  magento public function getCategoriesArray() { $categoriesArray = Mage::getModel(‘catalog/category’) ->getCollection() ->addAttributeToSelect(‘name’) ->addAttributeToSort(‘path’, ‘asc’) ->load() ->toArray(); $categories = array(); foreach ($categoriesArray as $categoryId => $category) { if (isset($category[‘name’]) && isset($category[‘level’])) { $categories[] = array( ‘label’ => $category[‘name’], ‘level’ =>$category[‘level’], ‘value’ => $categoryId ); } } return $categories; } Front end  form please add below code to display your category $fieldset->addField(‘categories’, ‘multiselect’, array( ‘label’ => $this->__(‘Categories’), ‘name’ => ‘categories’, ‘values’ => $this->getCategoriesArray(), ));

Read More

product tier price addupdate magento

you can use some PHP code that uses the Magento code to query for a list of products that match those criteria and then adjust each one   <?php require ‘app/Mage.php’; $app = Mage::app(‘default’); // Mage_Core_Model_App $store = $app->getStore(); // Mage_Core_Model_Store $products = Mage::getModel(‘catalog/product’)->getCollection(); // filter out anything that doesnt match the customer group 4 $products->addFieldToFilter(‘customer_group’, ‘4’); // loop through each product and delete it for ($products->load() as $product) { $product->delete(); }

Read More

Programmatically creating simple Magento product

Please follow the step to add product in magento using your code <?php Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $product = Mage::getModel(‘catalog/product’); //    if(!$product->getIdBySku(‘testsku61’)): try{ $product //    ->setStoreId(1) //you can set data in store scope ->setWebsiteIds(array(1)) //website ID the product is assigned to, as an array ->setAttributeSetId(9) //ID of a attribute set named ‘default’ ->setTypeId(‘simple’) //product type ->setCreatedAt(strtotime(‘now’)) //product creation time //    ->setUpdatedAt(strtotime(‘now’)) //product update time ->setSku(‘testsku00’) //SKU ->setName(‘test product’) //product name ->setWeight(4.0000) ->setStatus(1) //product status (1 – enabled, 2 – disabled) ->setTaxClassId(4) //tax class (0 – none, 1 – default, 2…

Read More

Programmatically create a configurable Magento product

Creating a simple product programmatically in Magento. Configurable product, however, things get a little bit complicated. As you already know, a configurable product is merely a product with simple products that differ in some option (attribute) assigned to itself. We can use this conclusion to extend our code for creation of simple products to work with configurable. Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $simpleProduct = Mage::getModel(‘catalog/product’); try { $simpleProduct // ->setStoreId(1) //you can set data in store scope ->setWebsiteIds(array(1)) //website ID the product is assigned to, as an array ->setAttributeSetId(20) //ID of a attribute set…

Read More

Difference Between Magento 1.x and 2.0 ?

Magento 2 was recently released after several developed by Magento core team. Magento 2 is bringing along some drastic, yet exciting changes in comparison with its predecessor Magento 1. In this , I’ll try to list out new features in Magento 2, and what it does better than Magento 1. If you are a field-tested Magento 1 developer making your way up to Magento 2 ASAP. 1. New uptodate file structure Being a Magento 1.x developer, some will feel a bit lost at first when it comes to the new…

Read More

New files structure in magento 2

1.  New files structure There are 2  major changes in the Magento-2 file structure. I)   Everything is placed directly under the app structure. II)  Every module has its own VIEW directory in which you can access all template, layout, js, and css/less files of any specific module. This is no doubt a big help for module developers as they can have more opportunities for customization without changing core site functionality. There are 4 types of directories in Magento 2  Primary System Application Public  – The Primary forlder cannot be…

Read More

Difference Between Primary key, Unique key And Foreign Key

Please checkout the below details Primary Key Primary key cannot have a NULL value. Each table can have only one primary key. By default, Primary key is clustered index and data in the database table is physically organized in the sequence of clustered index. Primary key can be related with another table’s as a Foreign Key. We can generated ID automatically with the help of Auto Increment field. Primary key supports Auto Increment value. Foreign Key Foreign key is a field in the table that is primary key in another…

Read More

WordPress Shortcode Terminology

What is shortcode in wordpress ? Worpdress opensource CMS, Shortcodes in WP are little bits of code that allow you to do various things with little effort. They were introduced in WordPress 2.5, and the reason to introduce them was to allow people to execute code inside WordPress posts, pages, and widgets without writing any code directly. This allows you to embed files or create objects that would normally require a lot of code in just one single line. For example, a shortcode for embedding a video might look like…

Read More