Author Archives: gotechsolution

Magento update product attribute without trigger reindex

Magento update product attribute without trigger reindex
Create a file updateAttribute.php on the root directory of your project folder and paste the the below code on your newly created (updateAttribute.php) file.

require_once('app/Mage.php'); 
umask(0);
Mage::app('admin');
// $product_id thhis is your product id(entity_id)
// $attribue_code this is your product attribute code (LIKE magento1 default code staus,description, etc )
// $value this is product code value 

FIRST WAY:- 
$product = Mage::getModel('catalog/product')->load($product_id); 
$resource = $product->getResource();
$product->setData($attribue_code, $value);
$resource->saveAttribute($product, $attribute_code);

SECOND WAY:-


First run this code 
$processes = Mage::getSingleton('index/indexer')->getProcessesCollection();
$processes->walk('setMode', array(Mage_Index_Model_Process::MODE_MANUAL));
$processes->walk('save');

Second run your product attribute code ..


NOTE:- if you run below code then reindex event will be trigger manually.. 
Third run below code.

$processes = Mage::getSingleton('index/indexer')->getProcessesCollection();
$processes->walk('reindexAll');
$processes->walk('setMode', array(Mage_Index_Model_Process::MODE_REAL_TIME));
$processes->walk('save');

Below is the example how to run the code..




$processes = Mage::getSingleton('index/indexer')->getProcessesCollection();
$processes->walk('setMode', array(Mage_Index_Model_Process::MODE_MANUAL));
$processes->walk('save');

$product = Mage::getModel('catalog/product')->load($product_id); 
$resource = $product->getResource();
$product->setData($attribue_code, $value);
$resource->saveAttribute($product, $attribute_code);

magento 1 update product attribute without reindex programmatically

update your product attribute without reindex programmatically.
Create a file updateAttribute.php on the root directory of your project folder and paste the the below code on your newly created (updateAttribute.php) file.

require_once('app/Mage.php'); 
umask(0);
Mage::app('admin');
// $product_id thhis is your product id(entity_id)
// $attribue_code this is your product attribute code (LIKE magento1 default code staus,description, etc )
// $value this is product code value 


$product = Mage::getModel('catalog/product')->load($product_id); 
$resource = $product->getResource();
$product->setData($attribue_code, $value);
$resource->saveAttribute($product, $attribute_code);


Unable to enable modules because of the following constraints on magento2

I have faced this problem when i was setup new magento2
on local machine, and i have tried to many process to
solve this issue but nothing work.

Simply this is caching issue. The browser which I was
used it. They have save js with my previous installation.

Step1: Use different browser and than check.

OR

Step2
Clear browser cache and than check.

How to Install magento2 on localhost using GIT

we can download magento2 in 3 ways.
1) Direct Download
2) Using COMPOSER
3) Using GIT

Step1: go to your root folder and check git install on
your local machine or not. type below command on console.

git

If not than install it.

apt -get install git

Step2: get a git clone on the root directory.

git clone https://github.com/magento/magento2.git

Step3: Give the permission of the folder

sudo chmod -R 777 YOUR-PROJET-FOLDER-NAME/

Step4: After that put below url on your local browser.


http://localhost/YOUR-PROJET-FOLDER-NAME/

how to install magento2 on localhost using Composer

we can download magento2 in 3 ways.
1) Direct Download
2) Using COMPOSER
3) Using GIT

Step1: First you need to check composer install on system or not.
Type below command on your console to check composer installation

	composer -help

If not install than install it . using below command.

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

The first command install Composer into your local directory,
the second will move the composer.phar file to a directory
where it can be accessed globally by your system.

Again check below command

 composer -help

Step 2: Install magento project on local machine, Type command on console.

composer create-project magento/project-community-edition magentodemo

  
root@system:/var/www/html# composer composer create-project magento/project-community-edition magentodemo

you see below output on your console

Installing magento/project-community-edition (2.0.2)
  - Installing magento/project-community-edition (2.0.2)
    Downloading: 100%         

Created project in Magento
Loading composer repositories with package information
    Authentication required (repo.magento.com):       
      Username: bfba1bb4bdfdcb63d8458457728f
      Password: 
Do you want to store credentials for repo.magento.com in /home/gaurav/.composer/auth.json ? [Yn] Y

Step3: After this you need username and password

 

https://www.magentocommerce.com/

and login into your account and than go to Develoers >> Secure Keys and generate key here.
Basically public key is belong to Username
Private key is belong to Password

Step4: Give the permission of the folder

sudo chmod -R 777 magentodemo/

Step5: After that put below url on your local browser.


http://localhost/magentodemo/

If you want to add sample data on your project than run
below command on console after complete install project.

php <your Magento install dir>/bin/magento sampledata:deploy