How to get all attributes with all available labels/options in Magento2?

I did a lot of research but could not find a solution for that. so gathered some info and created this code: (it is not the best way to do it, but it works – you can use it at least one time for quick results) the values need to be transformed if you want to see them properly in csv Here is how to print all available attributes in backend and along with their all available options aka labels <?php use \Magento\Framework\App\Bootstrap; error_reporting(E_ALL); ini_set("display_errors",1); include('./app/bootstrap.php'); $bootstrap = Bootstrap::create(BP, $_SERVER); $objectManager = $bootstrap->getObjectManager(); //use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory; $collection= $objectManager->get('\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory')->create(); //$attr_groups = array(); $fta=array(); $ft=array(); foreach ($collection as $items) { $attr_groups = $items->getData(); if($attr_groups['frontend_input']=="select" or $attr_groups['frontend_input']=="multiselect"){ $eav=$objectManager->get('\Magento\Eav\Model\Config')->getAttribute('catalog_product',$attr_groups['attribute_code'])->getSource()->getAllOptions(); $ft[]=$attr_groups['frontend_label']; $ft[]=$attr_groups['attribute_code']; //echo $attr_groups['attribute_code'].'<br>'.$attr_groups['frontend_input'].'<br>'.$attr_groups['frontend_label'].'<br>'.$attr_groups['attribute_id'].'<br>'; foreach($eav as $getlabel) { if(is_object($getlabel['label'])){ $r = new ReflectionObject($getlabel['label']); $p = $r->getProperty('text'); //echo $p; $p->setAccessible(true); $ft[]= $p->getValue($getlabel['label']); } else $ft[]= $getlabel['label']; } $fta[]=$ft; $ft=array(); }

August 31, 2018 · 1 min · Harshvardhan Malpani

Magento 2 cli commands [continued]

1. Setting GD2 as defualt image adapter from command line Magento >= 2.2 php bin/magento config:set dev/image/default_adapter GD2 php bin/magento cache:clean Magento >= 2.2 mysql --host=(host) --user=(user) --password=(password) -D (database) -e "\ UPDATE core_config_data SET value = 'GD2' WHERE 'dev/image/default_adapter' = path; \"; 2. Disable Minify CSS Files option from command line Magento >= 2.2 php bin/magento config:set dev/css/minify_files 0 php bin/magento cache:clean Magento < 2.2 mysql --host= --user= --password= -D -e "\ UPDATE core_config_data SET value = 0 WHERE 'dev/css/minify_files' = path; \"; php bin/magento cache:clean 3. Disable Merge CSS Files option from command line php bin/magento config:set dev/css/merge_css_files 0 php bin/magento cache:clean Magento < 2.2 mysql --host= --user= --password= -D -e "\ UPDATE core_config_data SET value = 0 WHERE 'dev/css/merge_css_files' = path; \"; php bin/magento cache:clean

August 1, 2018 · 1 min · Harshvardhan Malpani

How to install theme in Magento 2

Download the theme and copy the app folder and paste it in your magento root directory Open Shell, in the root directory, enter ***php bin/magento setup:upgrade .***This will upgrade all the magento files. Also, Clear cache ,type php bin/magento cache:clean . Now force deploy the static files by typing ***php bin/magento setup:static-content:deploy -f .***It will take a while. Now, Go in the dashboard and select content->configuration. ...

July 29, 2018 · 1 min · Harshvardhan Malpani

[SOLVED] PHP must be run as a CLI application error : Content-type: text/html; charset=UTF-8

php bin/magento cache:clean Content-type: text/html; charset=UTF-8 bin/magento must be run as a CLI application as root user, run the following commands (For php v7.0) # yum install ea-php70 # source /opt/cpanel/ea-php70/enable The solution involves fixing php variable’s path. We need to find which php is being used right now, you can find out by $ which php $ php -v To fix this PHP cli error, see how to edit php in bash profile (.bashrc)

July 28, 2018 · 1 min · Harshvardhan Malpani

Magento 2 all cli commands

[~/www]# php bin/magento list Magento CLI version 2.2.4 Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Available commands: help Displays help for a command list Lists commands admin admin:user:create Creates an administrator admin:user:unlock Unlock Admin Account app app:config:dump Create dump of application app:config:import Import data from shared configuration files to appropriate data storage cache cache:clean Cleans cache type(s) cache:disable Disables cache type(s) cache:enable Enables cache type(s) cache:flush Flushes cache storage used by cache type(s) cache:status Checks cache status catalog catalog:images:resize Creates resized product images catalog:product:attributes:cleanup Removes unused product attributes. config config:sensitive:set Set sensitive configuration values config:set Change system configuration config:show Shows configuration value for given path. If path is not specified, all saved values will be shown cron cron:install Generates and installs crontab for current user cron:remove Removes tasks from crontab cron:run Runs jobs by schedule customer customer:hash:upgrade Upgrade customer's hash according to the latest algorithm deploy deploy:mode:set Set application mode. deploy:mode:show Displays current application mode. dev dev:di:info Provides information on Dependency Injection configuration for the Command. dev:profiler:disable Disable the profiler. dev:profiler:enable Enable the profiler. dev:query-log:disable Disable DB query logging dev:query-log:enable Enable DB query logging dev:source-theme:deploy Collects and publishes source files for theme. dev:template-hints:disable Disable frontend template hints. A cache flush might be required. dev:template-hints:enable Enable frontend template hints. A cache flush might be required. dev:tests:run Runs tests dev:urn-catalog:generate Generates the catalog of URNs to *.xsd mappings for the IDE to highlight xml. dev:xml:convert Converts XML file using XSL style sheets i18n i18n:collect-phrases Discovers phrases in the codebase i18n:pack Saves language package i18n:uninstall Uninstalls language packages import import:categories Run category importer script indexer indexer:info Shows allowed Indexers indexer:reindex Reindexes Data indexer:reset Resets indexer status to invalid indexer:set-mode Sets index mode type indexer:show-mode Shows Index Mode indexer:status Shows status of Indexer info info:adminuri Displays the Magento Admin URI info:backups:list Prints list of available backup files info:currency:list Displays the list of available currencies info:dependencies:show-framework Shows number of dependencies on Magento framework info:dependencies:show-modules Shows number of dependencies between modules info:dependencies:show-modules-circular Shows number of circular dependencies between modules info:language:list Displays the list of available language locales info:timezone:list Displays the list of available timezones maintenance maintenance:allow-ips Sets maintenance mode exempt IPs maintenance:disable Disables maintenance mode maintenance:enable Enables maintenance mode maintenance:status Displays maintenance mode status module module:disable Disables specified modules module:enable Enables specified modules module:status Displays status of modules module:uninstall Uninstalls modules installed by composer sampledata sampledata:deploy Deploy sample data modules sampledata:remove Remove all sample data packages from composer.json setup setup:backup Takes backup of Magento Application code base, media and database setup:config:set Creates or modifies the deployment configuration setup:cron:run Runs cron job scheduled for setup application setup:db-data:upgrade Installs and upgrades data in the DB setup:db-schema:upgrade Installs and upgrades the DB schema setup:db:status Checks if DB schema or data requires upgrade setup:di:compile Generates DI configuration and all missing classes that can be auto-generated setup:install Installs the Magento application setup:performance:generate-fixtures Generates fixtures setup:rollback Rolls back Magento Application codebase, media and database setup:static-content:deploy Deploys static view files setup:store-config:set Installs the store configuration. Deprecated since 2.2.0. Use config:set instead setup:uninstall Uninstalls the Magento application setup:upgrade Upgrades the Magento application, DB data, and schema store store:list Displays the list of stores store:website:list Displays the list of websites theme theme:uninstall Uninstalls theme varnish varnish:vcl:generate Generates Varnish VCL and echos it to the command line

July 27, 2018 · 3 min · Harshvardhan Malpani

Magento File Directory

/app The etc folder contains the di.xml configuration file The di.xml file contains class mapping and interface preferences Contains the design folder for themes. /bin The directory contains the magento file or a Command Line Interface script /dev Magento 2 testing and development tools are placed in this folder. /lib The internal and web subfolders are located here The internal directory contains server-side libraries and several font files; The web subfolder contains client-side libraries, jquery, modernizr, requirejs, prototype, scriptaculous ...

July 27, 2018 · 1 min · Harshvardhan Malpani

Installing Magento Common Issues

Following are the steps to complete install Magento error-free:- Uncomment the files which are required by Magento in php.ini and restart the server If installation error occurs, set memory_limit = 786M if still error occurs, uninstall the db and make it again after successfull install, go to (root_directory)app/etc/di.xml and change “Symlink” to “Copy” in developerMaterialization section. go to cmd , root directory and type :- “/bin/magento setup:static-content:deploy refresh the page. done.

July 22, 2018 · 1 min · Harshvardhan Malpani

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry Magento 2

SELECT u.value_id,u2.value_id, u.attribute_id, u.entity_id, u.value FROM catalog_product_entity_int u, catalog_product_entity_int u2 WHERE u.entity_id = u2.entity_id AND u.attribute_id = u2.attribute_id AND u.value= u2.value and u.value_id<u2.value_id DELETE FROM catalog_product_entity_int WHERE value_id IN ( SELECT u.value_id as value_id FROM catalog_product_entity_int u, catalog_product_entity_int u2 WHERE u.entity_id = u2.entity_id AND u.attribute_id = u2.attribute_id AND u.value= u2.value and u.store_id=u2.store_id and u.value_id<u2.value_id )

May 29, 2018 · 1 min · Harshvardhan Malpani

Bulk Add Custom Attribute Options in Magento 1

$jq=new jQuery.noConflict(); var mimim=["Yellow Topaz", "Alexandrite"]; $jq.each(mimim,function(a,b){ $jq("#add_new_option_button").click(); $jq("#matage-options-panel .dynamic-grid tbody tr:nth-child(2) td:nth-child(1) input").val(b); });

May 16, 2018 · 1 min · Harshvardhan Malpani

Magento 2 – How to manage multi domain website store setup URLs

select * from `core_config_data` where path like 'web/%'

April 3, 2018 · 1 min · Harshvardhan Malpani