Tag Archives: Magento

Customer Attributes

Customer attributes provide the information that is required to support the order, fulfillment, and customer management processes. Because your business is unique, you might need fields in addition to those provided by the system. You can add custom attributes to the Account Information, Address Book, and Billing Information sections of the customer’s account. Customer address attributes can also be used in the Billing Information section during checkout, or when guests register for an account.

https://docs.magento.com/user-guide/v2.3/stores/attributes-customer.html

 

magento setup upgrade Unexpected error. Unable to create oAuth consumer account.

I have encountered this issue while community to enterprise migration and it was happening since the base table ‘oauth_consumer‘ was not available.

CREATE TABLE oauth_consumer (   entity_id int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Entity Id',
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Created At',
updated_at timestamp NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP COMMENT 'Updated At',
name varchar(255) NOT NULL COMMENT 'Name of consumer',
key varchar(32) NOT NULL COMMENT 'Key code',
secret varchar(32) NOT NULL COMMENT 'Secret code',
callback_url text COMMENT 'Callback URL',
rejected_callback_url text NOT NULL COMMENT 'Rejected callback URL',
PRIMARY KEY (entity_id),
UNIQUE KEY OAUTH_CONSUMER_KEY (key),
UNIQUE KEY OAUTH_CONSUMER_SECRET (secret),
KEY OAUTH_CONSUMER_CREATED_AT (created_at),
KEY OAUTH_CONSUMER_UPDATED_AT (updated_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='OAuth Consumers';

Magento 2 Requested store is not found

This issue can be fixed by issuing the following queries

UPDATE store SET store_id = 0 WHERE code='admin';
UPDATE store_group SET group_id = 0 WHERE name='Default';
UPDATE store_website SET website_id = 0 WHERE code='admin';

It can also be solved by modify StoreManager.php (/vendor/magento/module-store/Model/StoreManager.php)

If $storeId is not defined: It retrive data from COOKIE first, otherwise return the default store code.

if (!isset($storeId) || '' === $storeId || $storeId === true) {
if (null === $this->currentStoreId) {
\Magento\Framework\Profiler::start('store.resolve');
$this->currentStoreId = $this->storeResolver->getCurrentStoreId(); \Magento\Framework\Profiler::stop('store.resolve');
}
$storeId = $this->currentStoreId;
}

To

if(!$storeId) {
if(isset($_COOKIE['store']) && $_COOKIE['store'] !== ''){
$storeId = $_COOKIE['store'];
} else {
$storeId = $this->getDefaultStoreView()->getCode();
}
}

The requested URL /magento/admin/ was not found on this server magento 2

Edit apache configuration file and modify as follows. As per my installation, configuration file is /etc/httpd/conf/httpd.conf

<Directory /var/www/>
     Options Indexes FollowSymLinks
     AllowOverride None
     Require all granted
</Directory>

To

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

NginX PHP-FPM CentOS

This article assume that Nginx is installed in your server and its up and running.Lest install NginX

Update the repository

yum update -y

Install the EPEL repository

yum install epel-release -y

Install Dependencies

yum install -y git gcc gcc-c++ libxml2-devel pkgconfig openssl-devel bzip2-devel curl-devel libpng-devel libjpeg-devel libXpm-devel freetype-devel gmp-devel libmcrypt-devel mariadb-devel aspell-devel recode-devel autoconf bison re2c libicu-devel libxslt-devel libxslt

Get The PHP Source

curl -O -L https://github.com/php/php-src/archive/php-7.1.18.tar.gz
tar -xvf php-7.1.18.tar.gz
cd php-src-php-7.1.18/
Compile Source Code 

./buildconf --force

./configure --prefix=/etc/php --with-config-file-path=/etc/php/etc --with-config-file-scan-dir=/etc/php/etc/conf.d --enable-bcmath --with-bz2 --with-curl --enable-filter --enable-fpm --with-gd --enable-gd-native-ttf --with-freetype-dir --with-jpeg-dir --with-png-dir --enable-intl --enable-mbstring --with-mcrypt --enable-mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-sqlite --disable-phpdbg --disable-phpdbg-webhelper --enable-opcache --with-openssl --enable-simplexml --with-sqlite3 --enable-xmlreader --enable-xmlwriter --enable-zip --with-zlib --enable-soap --with-xsl

make
make install

Add PHP to $PATH

echo 'pathmunge /etc/php/bin' > /etc/profile.d/php.sh

Copy php.ini

cp php.ini-development /etc/php/lib/php.ini

Add module opcache

vi /etc/php/etc/conf.d/modules.ini

and add 'zend_extension=opcache.so'

PHP FPM SET UP

mkdir /etc/php/etc/conf.d

cp sapi/fpm/www.conf /etc/php/etc/php-fpm.d/www.conf

cp sapi/fpm/php-fpm.conf /etc/php/etc/php-fpm.conf

Update PHP FPM configuration

vi /etc/php/etc/php-fpm.d/www.conf

user = nobody
group = nobody

listen.owner = nginx
listen.group = nginx

listen = /var/run/php-fpm/php-fpm.sock

Create a symlink for php-fpm to the standard path

ln -s /etc/php/sbin/php-fpm /usr/sbin/php-fpm

Create a systemctl file add the following:

vi /usr/lib/systemd/system/php-fpm.service

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=simple
PIDFile=/run/php-fpm/php-fpm.pid
ExecStart=/usr/sbin/php-fpm --nodaemonize --fpm-config /etc/php/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

Create a run directory for php-fpm:

mkdir /run/php-fpm

Start php-fpm and Restart NginX

systemctl start php-fpm

service nginx restart

Create index.php

mv /etc/nginx/html/index.html /etc/nginx/html/index.php

Update nginx.con file with the followinf content

root /etc/nginx/html;
index index.php index.html index.htm;

location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

Load URL

http://127.0.0.1/

 

Install NginX CentOS From Source

Update the repository

yum update -y

Install the EPEL repository

yum install epel-release -y

Install dependencies from yum

yum install -y zlib zlib-devel pcre prce-devel openssl openssl-devel

Get the Nginx packages to install

cd /usr/src
wget https://nginx.org/download/nginx-1.14.0.tar.gz
tar xvf nginx-1.14.0.tar.gz
cd nginx-1.14.0

Create user nginx

useradd -d /etc/nginx/ -s /sbin/nologin nginx

Configure

./configure --user=nginx --group=nginx --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-file-aio --with-http_realip_module --without-http_scgi_module --without-http_uwsgi_module --with-http_realip_module

Compile and Install

make
make install

Verify NginX is installed

nginx -v

Add systemd service file

vi /etc/systemd/system/nginx.service

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Enable and start service

systemctl enable nginx
systemctl start nginx

Check nginx is processing your request

On commandline

curl localhost

Browser

Make sure port 80 is enabled.

firewall-cmd --zone=public --add-port=80/tcp --permanent && firewall-cmd --reload

Findout the ip

ip addr

Load the site using the URL and it should display ‘Welcome to nginx!’ message.

http://127.0.0.1/

 

Magento 2 Enable Redis

Install Redis.

And then edit app/etc/env.php to configure Magento to use Redis for session storage, default and page caching.

'session' =>
array (
'save' => 'redis',
'redis' =>
array (
'host' => '127.0.0.1',
'port' => '6379',
'password' => '',
'timeout' => '2.5',
'persistent_identifier' => '',
'database' => '2',
'compression_threshold' => '2048',
'compression_library' => 'gzip',
'log_level' => '1',
'max_concurrency' => '6',
'break_after_frontend' => '5',
'break_after_adminhtml' => '30',
'first_lifetime' => '600',
'bot_first_lifetime' => '60',
'bot_lifetime' => '7200',
'disable_locking' => '0',
'min_lifetime' => '60',
'max_lifetime' => '2592000'
)
),
'cache' =>
array(
'frontend' =>
array(
'default' =>
array(
'backend' => 'Cm_Cache_Backend_Redis',
'backend_options' =>
array(
'server' => '127.0.0.1',
'database' => '0',
'port' => '6379'
),
),
'page_cache' =>
array(
'backend' => 'Cm_Cache_Backend_Redis',
'backend_options' =>
array(
'server' => '127.0.0.1',
'port' => '6379',
'database' => '1',
'compress_data' => '0'
)
)
)
),