//修改 modal 彈窗的 z-index 低於 magnific popup 高於 includeproduct.twig
/var/www/html/catalog/view/javascript/jquery/magnific/magnific-popup.css
.mfp-content {
...
z-index: 1045; }
/* The shadow behind the image */
.mfp-figure {
...
z-index: -1;
4.) /var/www/html/catalog/view/theme/default/template/product/product.twig
//popupop.twig 共用 Jquery 調用 magnific popup
-> $('.thumbnails').magnificPopup({
--- 20210201 opencart-3.0.3.6 研究 modal 彈窗 + magnific popup
=========================================================================================================================
{% include 'default/template/product/popupop.twig' ignore missing %}
{{ constant('Twig_Environment::VERSION') }}
2.13.0
->
cd /var/www/html/system/
wget 118.163.15.73/bpc/dv/modification.xml -N
->
$code));
]]> $code));
$loader2 = new \Twig\Loader\FilesystemLoader(array(DIR_TEMPLATE)); // to find further includes
$loader = new \Twig\Loader\ChainLoader(array($loader1, $loader2));
]]>
->Extensions->Modifications->Refresh
->default include path: DIR_TEMPLATE = "/var/www/html/catalog/view/theme/"
----------------------
(!!注意-> twig include 判斷日期如果沒有最新的就不會重加載)
--- 20210201 opencart-3.0.3.6 + twig 2.13.0 {% include %}無效錯誤 -> 修改 modification.xml
=========================================================================================================================
運費估算調用路徑
1.) catalog/controller/checkout/cart.php->
//找出所有/controller/extension/total/下的php
$this->load->model('setting/extension');
$data['modules'] = array();
$files = glob(DIR_APPLICATION . '/controller/extension/total/*.php');
if ($files) {
foreach ($files as $file) {
$result = $this->load->controller('extension/total/' . basename($file, '.php'));
if ($result) {
$data['modules'][] = $result;
}
}
}
2.) catalog/view/theme/default/template/checkout/cart.twig->
//列出所有total下enable的功能
{% for module in modules %}
{{ module }}
{% endfor %}
3.) catalog/controller/startup/startup.php->
//讀取db->oc_setting所有設定
// Settings
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "setting` WHERE store_id = '0' OR store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY store_id ASC");
foreach ($query->rows as $result) {
if (!$result['serialized']) {
$this->config->set($result['key'], $result['value']);
} else {
$this->config->set($result['key'], json_decode($result['value'], true));
}
}
4.) system/library/session/db.php->
//讀取db->oc_session->data->json_decode
public function read($session_id) {
$query = $this->db->query("SELECT `data` FROM `" . DB_PREFIX . "session` WHERE session_id = '" . $this->db->escape($session_id) . "' AND expire > " . (int)time());
if ($query->num_rows) {
return json_decode($query->row['data'], true);
5.) catalog/controller/extension/total/shipping.php->
//判斷本功能是否enable
class ControllerExtensionTotalShipping extends Controller {
public function index() {
if ($this->config->get('total_shipping_status') && $this->config->get('total_shipping_estimator') && $this->cart->hasShipping()) {
//送出session資料countries, zone_id, postcode, shipping_method
if (isset($this->session->data['shipping_address']['country_id'])) {
$data['country_id'] = $this->session->data['shipping_address']['country_id'];
//調用catalog/model/localisation/country.php取國家列表
$this->load->model('localisation/country');
//調用catalog/model/localisation/zone.php取單一國家zone列表
'zone' => $this->model_localisation_zone->getZonesByCountryId($this->request->get['country_id']),
6.) catalog/view/theme/default/template/extension/total/shipping.twig->
//按quote鍵->ajax catalog/controller/extension/total/shipping.php->quote()
...
$('#button-quote').on('click', function() {
$.ajax({
url: 'index.php?route=extension/total/shipping/quote',
type: 'post',
data: 'country_id=' + $('select[name=\'country_id\']').val() + '&zone_id=' + $('select[name=\'zone_id\']').val() + '&postcode=' + encodeURIComponent($('input[name=\'postcode\']').val()),
dataType: 'json',
beforeSend: function() {
$('#button-quote').button('loading');
},
complete: function() {
$('#button-quote').button('reset');
},
7.) catalog/controller/extension/total/shipping.php
//調用 catalog/model/extension/shipping/ 下所有可用 shipping extension (系統自帶13個)
->foreach ($results as $result) {
if ($this->config->get('shipping_' . $result['code'] . '_status')) {
$this->load->model('extension/shipping/' . $result['code']);
$quote = $this->{'model_extension_shipping_' . $result['code']}->getQuote($this->session->data['shipping_address']);
--- 20210131 opencart-3.0.3.6 運費估算調用路徑
=========================================================================================================================
所有url調用路徑
1.)index.php->
require_once('config.php'); //定義各種 DIR_XXX, DB_XXX
require_once(DIR_SYSTEM . 'startup.php'); //調用startup.php + function modification, library, start + spl_autoload_register
start('catalog'); //調用framework.php + 傳$application_config
2.)system/startup.php->
require_once(DIR_STORAGE . 'vendor/autoload.php'); //autoload vender
//加載所有library
spl_autoload_register('library'); //cache config db document encryption image language log mail pagination request response session squareup template url
//加載所有Engine
require_once(modification(DIR_SYSTEM . 'engine/action.php')); //-> function getId execute
require_once(modification(DIR_SYSTEM . 'engine/controller.php'));
require_once(modification(DIR_SYSTEM . 'engine/event.php')); //-> function register trigger unregister clear
require_once(modification(DIR_SYSTEM . 'engine/router.php')); //-> function addPreAction dispatch execute
require_once(modification(DIR_SYSTEM . 'engine/loader.php')); //-> function controller model view library helper config language callback
require_once(modification(DIR_SYSTEM . 'engine/model.php'));
require_once(modification(DIR_SYSTEM . 'engine/registry.php')); //-> function get set has
require_once(modification(DIR_SYSTEM . 'engine/proxy.php'));
3.)system/framework.php->
$config->load('default'); //system/cinfig/default.php 設db, action_default=common/home
$config->load($application_config); //system/cinfig/catalog.php 設action_pre_action=startup/startup...
$registry->set('config', $config); //設$this->config
$registry->set('load', $loader); //設$this->load
....
//設所有$this->request response db session cookie cache url language document
//判斷所有autoload->config_autoload language_autoload library_autoload model_autoload
//取url route
$route = new Router($registry);
//判斷所有Pre Actions 取所有值
if ($config->has('action_pre_action')) {
foreach ($config->get('action_pre_action') as $value) {
$route->addPreAction(new Action($value));
}
}
//跳轉Dispatch
$route->dispatch(new Action($config->get('action_router')), new Action($config->get('action_error')));
//送出結果Output
$response->output();
4.)system/engine/router.php->
function dispatch->function execute
5.) system/engine/action.php->
public function execute($registry, array $args = array()) {
...
$file = DIR_APPLICATION . 'controller/' . $this->route . '.php';
$class = 'Controller' . preg_replace('/[^a-zA-Z0-9]/', '', $this->route);
...
include_once($file);
$controller = new $class($registry);
--- 20210131 opencart-3.0.3.6 所有url調用路徑
=========================================================================================================================
extension Lazy-Load-Images-OC3.0.x.ocmod
0.) SQL->oc_modification->xml (update from install.xml)
1.) 修改 catalog/view/theme/*/template/common/header.twig(20210327 已手工改)
->before add
2.) 修改所有要加 lazy-load 的 php
catalog/controller/extension/module/featured.php(20210327 已刪除不改)
catalog/controller/extension/module/{bestseller,special,latest}.php(20210327 已刪除不改)
catalog/controller/product/{special,search,category}.php(special 20210327 已刪除不改)(search,category 20210327 已手工改)
->before
foreach ($products as $product_id) {
foreach ($results as $result) {
->add
$data['lazy_load_width_height'] = 'width="' . $setting['width'] . '" height="' . $setting['height'] . '"';
$data['lazy_load_width_height'] = 'width="' . $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width') . '" height="' . $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height') . '"';
3.) 修改所有要加 lazy-load 的 twig
catalog/view/theme/*/template/extension/module/{featured,latest,special,bestseller}.twig(20210327 已刪除不改)
catalog/view/theme/*/template/product/{special,category,search}.twig(special 20210327 已刪除不改)(search,category 20210327 已手工改)
->
src="{{ product.thumb }}"
->replace
class="lazy-load" data-original="{{ product.thumb }}" {{ lazy_load_width_height }}
4.) dv 新增 product page 加 lazy-load
(20210307 直接新增在 product.php)
catalog/controller/product/product.php(20210327 已手工改)
->
->
上傳 simple_html_dom.php + product_description_lazyload_dv.php(自動修改 $data['description'] 中所有 img 格式成為 lazy-load 格式)
(20210327 已改 /var/www/html/ -> /var/www/html/dv/ 下)
cd /var/www/storage
mkdir dv (777)
wget 118.163.15.73/bpc/dv/simple_html_dom.php0
mv simple_html_dom.php0 simple_html_dom.php
wget 118.163.15.73/bpc/dv/product_description_lazyload_dv.php0
mv product_description_lazyload_dv.php0 product_description_lazyload_dv.php
chmod 777 *
-------------------------
ocmod 運行原則
1.) 優先使用 /var/www/storage/modification/system,catalog,admin/下已有的php twig
2.) 如果1.)沒有就使用 /var/www/html/system,catalog,admin/下的php twig
--- 20210130 opencart-3.0.3.6 研究 extension Lazy-Load-Images-OC3.0.x.ocmod + ocmod 運行原則
=========================================================================================================================
1.) 重新 zip 以下文件 + 目錄
install.xml
目錄 upload 包含2文件
Lazy-Load-Images-OC3.0.x.ocmod\upload\catalog\view\javascript\lazyload\jquery.lazyload.min.js
Lazy-Load-Images-OC3.0.x.ocmod\upload\catalog\view\javascript\lazyload\loading.gif
-> lazy-dv-1.ocmod.zip
2.) Extensions->Installer->upload lazy-dv-1.ocmod.zip
3.) Extensions->Modifications->Clear + Refresh
--- 20210129 opencart-3.0.3.6 安裝 extension Lazy-Load-Images-OC3.0.x.ocmod
=========================================================================================================================
Extensions->Modifications->Refresh
->Log:
-----------------------------------------------
2021-01-29 0:35:23 - MOD: Modification Default
...
FILE: system/library/template/twig.php
CODE: $loader = new \Twig_Loader_Filesystem(DIR_TEMPLATE);
NOT FOUND - OPERATIONS ABORTED!
->https://github.com/opencart/opencart/blob/3.0.x.x_Maintenance/upload/system/modification.xml 下載 modification.xml(bug fixed)
cd /var/www/html/system/
wget 118.163.15.73/bpc/dv/modification.xml -N
Extensions->Modifications->Refresh
--- 20210129 opencart-3.0.3.6 安裝 extension refresh 後 twig 錯誤 -> 修改 modification.xml
=========================================================================================================================
Extensions->Installer->upload Lazy-Load-Images-OC3.0.x.ocmod.zip
->error: mkdir permission denied
->cd /var/www/html/catalog/view/
chmod 777 . -R
--- 20210128 opencart-3.0.3.6 安裝 extension lazy-load 錯誤 -> 修改 /var/www/html/catalog/view/ 權限
=========================================================================================================================
0.) !!必需先停止 ocmod template cache
->後台 -> 右上角齒輪->theme-cache-: off + action -> 再至 extensions->modifications->右上角 clear + refresh
1.) joe /var/www/html/catalog/controller/product/product.php
-> $data['popupop'] = $this->load->controller('product/popupop');
2.) joe /var/www/html/catalog/view/theme/default/template/product/product.twig
-> {{ popupop }}
3.) cd /var/www/html/catalog/controller/product/
wget 118.163.15.73/bpc/dv/popupop.php0 -N
mv popupop.php0 popupop.php
joe /var/www/html/catalog/controller/product/popupop.php
->class ControllerCommonPopupop extends Controller {
...
$data['xxxx'] = 'xxxx';
return $this->load->view('product/popupop', $data);
4.) cd /var/www/html/catalog/view/theme/default/template/product/
wget 118.163.15.73/bpc/dv/popupop.twig -N
joe /var/www/html/catalog/view/theme/default/template/product/popupop.twig
->
--- 20210124 opencart-3.0.3.6 新增 popup option page (已改用直接在調用頁中增加{% include %}方法)
=========================================================================================================================
修改 product page 上移 add to cart button + 下移 description
joe /var/www/html/catalog/view/theme/default/template/product/product.twig
->cd /var/www/html/catalog/view/theme/default/template/product/
wget 118.163.15.73/bpc/dv/product.twig -N
--- 20210124 opencart-3.0.3.6 修改 product page description 位置
=========================================================================================================================
http://18.217.214.174/index.php?route=checkout/cart 調用路徑
1.)index.php->start('catalog');
2.)system/startup.php->function start($application_config) { require_once(DIR_SYSTEM . 'framework.php'); }
3.)system/framework.php->$route->dispatch(new Action($config->get('action_router')), new Action($config->get('action_error')));
4.)system/engine/router.php->system/engine/action.php->
public function execute($registry, array $args = array()) {
...
$file = DIR_APPLICATION . 'controller/' . $this->route . '.php';
$class = 'Controller' . preg_replace('/[^a-zA-Z0-9]/', '', $this->route);
// Initialize the class
if (is_file($file)) {
include_once($file);
5.)catalog/controller/checkout/cart.php
--- 20210123 opencart-3.0.3.6 shopping cart 頁調用路徑
=========================================================================================================================
首頁調用路徑 http://18.217.214.174/index.php(?route=common/home)
1.)index.php->start('catalog');
2.)system/startup.php->function start($application_config) { require_once(DIR_SYSTEM . 'framework.php'); }
3.)system/framework.php->$config = new Config();$config->load('default');
4.)system/library/config.php->public function load($filename) { $file = DIR_CONFIG . $filename . '.php';
5.)system/config/default.php->$_['action_default'] = 'common/home';
6.)system/framework.php->$route->dispatch(new Action($config->get('action_router')), new Action($config->get('action_error')));
7.)catalog/controller/common/home.php->
--- 20210123 opencart-3.0.3.6 首頁調用路徑
=========================================================================================================================
修改首頁 shopping cart 入口
joe /var/www/html/catalog/controller/common/header.php
// $data['shopping_cart'] = $this->url->link('checkout/cart');
$data['shopping_cart'] = 'www.buck4u.com';
--------------------
修改 shopping cart 頁跳轉
joe /var/www/html/catalog/controller/checkout/cart.php
header("Location: tb/Views/Shop/ShopCart.html");
exit;
--------------------
twig render 位置
system/library/template/twig.php->
$loader = new \Twig\Loader\ArrayLoader(array($filename . '.twig' => $code));
$twig = new \Twig\Environment($loader, $config);
->
system/storage/vendor/twig/twig/src/Loader/ArrayLoader.php //-> namespace Twig\Loader;
system/storage/vendor/twig/twig/src/Environment.php //-> namespace Twig;
--- 20210123 opencart-3.0.3.6 修改 shopping cart + 研究 twig render 位置
=========================================================================================================================
後台產品管理產生縮圖路徑
1.)進後台產品管理 http://18.217.214.174/admin/index.php?route=catalog/product
joe /var/www/html/admin/controller/catalog/product.php
->$this->model_tool_image->resize('no_image.png', 40, 40); //-> image/no_image.png
2.)調用 model_tool_image
joe /var/www/html/admin/model/tool/image.php
->class ModelToolImage extends Model {
public function resize($filename, $width, $height) {
...
if ($width_orig != $width || $height_orig != $height) {
$image = new Image(DIR_IMAGE . $image_old);
$image->resize($width, $height);
$image->save(DIR_IMAGE . $image_new);
} else {
3.)繼承基本class image
joe /var/www/html/system/library/image.php
->class Image {
public function resize($width = 0, $height = 0, $default = '') {
...
public function save($file, $quality = 90) {
...
錯誤: image/cache/ 下不產生縮圖致前后台所有縮圖全都破圖不能顯示
修改: 不明原因 $this->image = imagecreatefromgif($file); 產生的是object, 而不是resource
// if (is_resource($this->image)) {
if (is_object($this->image)) {
--- 20210120 opencart-3.0.3.6 後台產品管理產生縮圖路徑
=========================================================================================================================
安裝 sd-aws
sdonaws 592047561@qq.com + aa2233zz!!
IP: 18.217.214.174
Ubuntu Server 20.04 LTS (HVM), SSD Volume Type-> t2.micro->添加存储30G
sd-1.ppk->log in:ubuntu->sudo su
更新系统并安装必要的软件包
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get -y install curl nano git
sudo apt install unzip
sudo apt install joe
安装Apache
sudo apt-get install apache2
sudo systemctl restart apache2
Server version: Apache/2.4.41 (Ubuntu)
Server built: 2020-08-12T19:46:17
安装PHP/PHP-FPM
sudo apt install php8.0-cli
sudo apt-get install php8.0-gd
php -v
->PHP 8.0.1 (cli) (built: Jan 13 2021 08:22:35) ( NTS )
Copyright (c) The PHP Group Zend Engine v4.0.1, Copyright (c) Zend Technologies with Zend OPcache v8.0.1, Copyright (c), by Zend Technologies
安装mysql
sudo apt-get install mysql-server
->Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8 Server version: 8.0.22-0ubuntu0.20.04.3 (Ubuntu)
配置mysql
mysql_secure_installation
->root + frevres88->alter user 'root'@'localhost' identified by 'Frevres88!';
创建数据库+设置单独的MySQL用户帐户
mysql -u root -p
CREATE DATABASE oc_work CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'Frevres88!';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
CREATE USER 'ocwork'@'localhost' IDENTIFIED BY 'Frevres88!';
GRANT ALL PRIVILEGES ON *.* TO 'ocwork'@'localhost' WITH GRANT OPTION;
flush privileges;
select user,host from mysql.user;
\q
sudo systemctl restart mysql
安装phpmyadmin
sudo apt-get install php-mbstring
sudo apt-get install phpmyadmin
sudo apt-get update phpmyadmin
sudo apt update && sudo apt install phpmyadmin
sudo ln -s /usr/share/phpmyadmin /var/www/html/P3-myA5
18.217.214.174/P3-myA5
-->
root 密碼安全度太差
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
SHOW VARIABLES LIKE 'validate_password%';
set global validate_password.policy=LOW;
ALTER user 'root'@'localhost' IDENTIFIED BY 'Frevres88!';
------------------------------------------------------------------------------------------------
下載 opencart-3.0.3.6.zip
cd /var/www/bk-zip/
wget 118.163.15.73/bpc/dv/upload.zip
建空資料庫 oc_work
安裝 opencart-3.0.3.6
cd /var/www/html/
sudo ln -s /usr/share/phpmyadmin /var/www/html/P3-myA5
unzip -q /var/www/bk-zip/upload.zip
mv config-dist.php config.php
mv admin/config-dist.php admin/config.php
chmod 777 system/storage/cache/
chmod 777 system/storage/download/
chmod 777 system/storage/logs/
chmod 777 system/storage/modification/
chmod 777 system/storage/session/
chmod 777 system/storage/upload/
chmod 777 system/storage/vendor/
chmod 777 image/
chmod 777 image/cache/
chmod 777 image/catalog/
chmod 777 config.php
chmod 777 admin/config.php
手工安装 cli_install.php
cd install
php cli_install.php install --db_hostname localhost --db_username ocwork --db_password Frevres88! --db_database oc_work --db_driver mysqli --db_port 3306 --username admin --password Frevres88! --email 1837794505@qq.com --http_server http://18.217.214.174/
->
SUCCESS! Opencart successfully installed on your server
Store link: http://18.217.214.174/
Admin link: http://18.217.214.174/admin/
136 张表 总计 5,467 InnoDB utf8_unicode_ci 550.2 KB 0 字节
->
手工移 storage 目錄出 html
rm /var/www/storage -rf
mv /var/www/html/system/storage /var/www/
mv /var/www/html/install /var/www/html/install-x
------------------------------------------------------------------------------------------------
Bugs opencart-3.0.3.6
1.) /var/www/html/install/cli_install.php
錯誤: DIR_STORAGE undefine
修改: 手工加定義
-> define('DIR_STORAGE', DIR_SYSTEM . 'storage/');
錯誤: MYSQL40 不能使用
/var/www/html/system/library/db/mysqli.php on line 40
Fatal error: Uncaught Exception: Error: Variable 'sql_mode' can't be set to the value of 'MYSQL40' Error No: 1231 SET @@session.sql_mode = 'MYSQL40' in /var/www/html/system/library/db/mysqli.php:44
修改: 手工加remark
-> // $db->query("SET @@session.sql_mode = 'MYSQL40'");
2.) system/storage 不可以放html下不安全一定要移出
修改: 改 config.php 的路徑定義
->function write_config_files($options) {
...
// $output .= 'define(\'DIR_STORAGE\', DIR_SYSTEM . \'storage/\');' . "\n";
$output .= 'define(\'DIR_STORAGE\', \'/var/www/storage/\');' . "\n";
修改: 改 admin/config.php 的路徑定義
->function write_config_files($options) {
...
// $output .= 'define(\'DIR_STORAGE\', DIR_SYSTEM . \'storage/\');' . "\n";
$output .= 'define(\'DIR_STORAGE\', \'/var/www/storage/\');' . "\n";
修改: 手工移 storage 目錄出 html
rm /var/www/storage -rf
mv /var/www/html/system/storage /var/www/
mv /var/www/html/install /var/www/html/install-x
3.) /var/www/html/system/library/image.php
錯誤: image/cache/ 下不產生縮圖致前后台所有縮圖全都破圖不能顯示
修改: 不明原因 $this->image = imagecreatefromgif($file); 產生的是object, 而不是resource
->public function save($file, $quality = 90) {
...
// if (is_resource($this->image)) {
if (is_object($this->image)) {
--- 20210119-20 AWS sdonaws 新account + opencart-3.0.3.6 安裝 + Debug
=========================================================================================================================
=========================================================================================================================
root@ip-172-31-40-85:/# df -h
Filesystem Size Used Avail Use% Mounted on
udev 488M 0 488M 0% /dev
tmpfs 100M 11M 89M 11% /run
/dev/xvda1 30G 20G 10G 66% /
tmpfs 496M 0 496M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 496M 0 496M 0% /sys/fs/cgroup
/dev/loop2 18M 18M 0 100% /snap/amazon-ssm-agent/1566
/dev/loop1 29M 29M 0 100% /snap/amazon-ssm-agent/2012
/dev/loop4 97M 97M 0 100% /snap/core/9665
/dev/loop0 97M 97M 0 100% /snap/core/9804
tmpfs 100M 0 100M 0% /run/user/1000
--- 20200825 AWS-QT ADA 備份下載
=========================================================================================================================
後台打開設定
STORES->Configuration->GENERAL->Reports->General Options->Enable Reports->Yes
清空舊的表
customer_visitor->訪客記錄
report_event->訪問記錄
report_viewed_product_index->訪問產品
(20200502 16:00)
mysqldump -u root -prevres88 --databases magento2 > /var/www/bk-gz/magento2_234_8pm_20200502_1600_ok.sql
(20200503 10:51)
TRUNCATE sales_bestsellers_aggregated_monthly;
SELECT * FROM sales_order_item WHERE created_at < '2020-03-20';
DELETE FROM sales_order_item WHERE created_at < '2020-03-20'; (共 54 行)
Bestsellers->You refreshed lifetime statistics.
--- 20200502 AWS-QT most viewed product report 沒有生效 + 新增 Packing Material + 清舊表成功
=========================================================================================================================
cd /var/www/magento2/app/design/frontend/Lee
cp pwc b4u -r
joe b4u/registration.php->
'frontend/Lee/b4u',
joe b4u/theme.xml->
b4u
cd /var/www/magento2/
php bin/magento cache:flush
chown -R www-data:www-data .
改store b4u的theme->b4u
php bin/magento cron:remove
Magento cron tasks have been removed
joe /var/www/magento2/app/design/frontend/Lee/b4u/Magento_Cms/templates/html/homepage/home_content.phtml
->addAttributeToFilter('new',1); (原為featured)
//->addCategoryFilter($category);
getName()*/; ?>
(原為featured)
刪除原Zou code第一大段
改 line 75:
' : '' */ ?>
--- 20200429 AWS-QT 增加新 theme -> Lee/b4u
=========================================================================================================================
(20200426 14:00)
mysqldump -u root -prevres88 --databases magento2 > /var/www/bk-gz/magento2_234_8pm_20200426_backup_ok.sql
(20200428 12:50)
mysqldump -u root -prevres88 --databases magento2 > /var/www/bk-gz/magento2_234_8pm_20200428_1250_ok.sql
(20200429 10:00)
cd /var/www/magento2_234_8pm_20200422_ready_ok/
tar -czf /var/www/bk-gz/magento2_234_8pm_20200422_ready_ok.tar.gz *
cd /var/www/bk-gz/
rm magento2-219-org-ok.tar.gz
rm magento2-219-qt-20200409-ok.tar.gz
rm magento232-20200405.tar.gz
--- 20200426-29 AWS-QT 正式使用備份 + 整理
=========================================================================================================================
S-0.)備份aws-qt magento2.3.4(現成) + 資料庫
cd /var/www/
cp magento2 magento2_234_8pm_20200422_ready_ok -r
mysqldump -u root -prevres88 --databases magento2 > /var/www/bk-gz/magento2_234_8pm_20200422_ready_ok.sql
S-1.)改DNS + AWS-QT nginx 設定
改www.buck4u.com 指向 3.22.57.114
改www.purewaterclub.com 指向 3.22.57.114
rm /etc/nginx/sites-enabled/qt-wg-1
ln -s /etc/nginx/sites-available/b4-pwc-wk /etc/nginx/sites-enabled/
systemctl restart nginx
systemctl restart php7.2-fpm
S-2.)magento2.3.4(現成) + 導入 magento8pm_20200423_1500.sql + 修改資料庫 + 刪無用data + 升級資料庫
導出資料庫-aws-dv
php bin/magento maintenance:enable
mysqldump -u root -prevres88 --databases magento8pm > /var/www/html/magento8pm_20200423_1500.sql
導入資料庫-aws-qt
cd /var/www/bk-gz/
wget 3.22.57.63/magento8pm_20200423_1500.sql
joe magento8pm_20200423_1500.sql
line 22->(原為magento8pm)
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `magento2` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `magento2`;
->
mysql -u root -prevres88
mysql>drop database magento2;
mysql -u root -prevres88 < /var/www/bk-gz/magento8pm_20200423_1500.sql
mysql -u root -prevres88
USE magento2;
先修改資料庫
DROP TABLE ves_blockbuilder_block ;
DROP TABLE ves_blockbuilder_cms ;
DROP TABLE ves_blockbuilder_page ;
DROP TABLE ves_blockbuilder_product ;
DROP TABLE ves_blockbuilder_widget ;
DROP TABLE ves_blog_category ;
DROP TABLE ves_blog_category_store ;
DROP TABLE ves_blog_comment ;
DROP TABLE ves_blog_comment_store ;
DROP TABLE ves_blog_post ;
DROP TABLE ves_blog_post_category ;
DROP TABLE ves_blog_post_related ;
DROP TABLE ves_blog_post_store ;
DROP TABLE ves_blog_post_tag ;
DROP TABLE ves_brand ;
DROP TABLE ves_brand_group ;
DROP TABLE ves_brand_product ;
DROP TABLE ves_brand_store ;
DROP TABLE ves_megamenu_item ;
DROP TABLE ves_megamenu_menu ;
DROP TABLE ves_megamenu_menu_store ;
DROP TABLE ves_testimonial_testimonial ;
DROP TABLE ves_testimonial_testimonial_store ;
DROP TABLE core_config_dataBK;
DROP TABLE theme_0 ;
DROP TABLE catalog_category_entity_text_20191212 ;
DELETE FROM core_config_data WHERE path='dev/static/sign';
DELETE FROM core_config_data WHERE path LIKE 'ves%' ;
UPDATE core_config_data SET value='2' WHERE path='design/theme/theme_id' ;
UPDATE core_config_data SET value='pwc-home' WHERE path='web/default/cms_home_page' AND scope_id=5 ;
DELETE FROM url_rewrite WHERE store_id=1 OR store_id=2 ;
DELETE FROM url_rewrite WHERE request_path LIKE 'ves%' OR target_path LIKE 'ves%' ;
DELETE FROM url_rewrite WHERE request_path LIKE 'zou%' OR target_path LIKE 'zou%' ;
DELETE FROM url_rewrite WHERE url_rewrite_id<=24838 AND entity_type='category' ;
DELETE FROM admin_user WHERE user_id < 5 ;
DELETE FROM store WHERE store_id=1 OR store_id=2 ;
DELETE FROM theme WHERE theme_id > 3 ;
DELETE FROM cms_page WHERE page_id>4 AND page_id<>30 AND page_id<>36 AND page_id<>37 AND page_id<>42 AND page_id<>44 AND page_id<>45 AND page_id<>49;
TRUNCATE TABLE cms_page_store;
INSERT INTO cms_page_store (page_id,store_id) VALUES (1,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (2,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (3,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (30,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (36,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (37,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (42,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (44,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (45,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (49,0) ;
DELETE FROM cms_block WHERE is_active=0;
DELETE FROM cms_block_store WHERE block_id<32;
UPDATE catalog_product_entity_text LEFT JOIN catalog_product_entity_int ON catalog_product_entity_text.entity_id=catalog_product_entity_int.entity_id
SET catalog_product_entity_text.value='Free shipping within USA, 48 states only'
WHERE catalog_product_entity_text.attribute_id=73 AND catalog_product_entity_int.attribute_id=159 AND catalog_product_entity_int.value=1 ;
UPDATE catalog_product_entity_text LEFT JOIN catalog_product_entity_int ON catalog_product_entity_text.entity_id=catalog_product_entity_int.entity_id
SET catalog_product_entity_text.value='Shipping and handling: $3.5 Each additional item $0.2 FREE SHIPPING ON ORDERS OVER $25'
WHERE catalog_product_entity_text.attribute_id=73 AND catalog_product_entity_int.attribute_id=160 AND catalog_product_entity_int.value=1 ;
DELETE FROM core_config_data WHERE path LIKE 'payment/%' AND
path<>'payment/authorizenet_acceptjs/cctypes' AND
path<>'payment/authorizenet_acceptjs/currency' AND
path<>'payment/authorizenet_acceptjs/order_status' AND
path<>'payment/authorizenet_acceptjs/payment_action' ;
升級資料庫
cd /var/www/magento2/
php bin/magento setup:upgrade
php bin/magento cache:clean
php bin/magento indexer:reindex
chown -R www-data:www-data .
S-3.)後台手工改設定
CONTENT->Configuration->改全部theme(web site+store+2 store view)為pwc(原為luma)
store->aws-219->aws-qt
CATALOG->Category->Default Category->Design->Use Parent Category Settings->Yes
將PWC下3個子目錄搬至Default Category下
刪PWC目錄
S-4.)後台設paypal + 刷卡 + 寄信 + reCaptcha
(20200423 15:30)通知ADA
(20200423 15:42)設好了, 己通知陳測試
mysqldump -u root -prevres88 --databases magento2 > /var/www/bk-gz/magento2_234_8pm_20200422_ready_ada_ok.sql
/dev/xvda1 30G 15G 15G 51% /
du -sh
828M
(20200426 14:00)
mysqldump -u root -prevres88 --databases magento2 > /var/www/bk-gz/magento2_234_8pm_20200426_backup_ok.sql
(20200428 12:50)
mysqldump -u root -prevres88 --databases magento2 > /var/www/bk-gz/magento2_234_8pm_20200428_1250_ok.sql
--- 20200423 15:00 正式轉 AWS-DV magento8pm 完成
=========================================================================================================================
直接改xml + phtml太困難->放棄
joe /var/www/magento2/app/design/frontend/Lee/pwc/Magento_Catalog/layout/catalog_product_view.xml
vendor/magento/module-theme/view/frontend/templates/html/header/logo.phtml
cp /var/www/magento2/vendor/magento/module-catalog/view/frontend/layout/catalog_product_view.xml /var/www/html/catalog_product_viewxml
屬性表->eav_attribute->attribute_id(entity_type_id=4:產品屬性)
70->name
71->sku
72->description
73->short_description
159->free_shipping
160->b4_free_shipping
產品屬性值表數字型->catalog_product_entity_int->value(attribute_id=159:free_shipping)
0->no / 1->yes
產品屬性值表文字型->catalog_product_entity_text->value(attribute_id=73:short_description)
SELECT * FROM catalog_product_entity_text LEFT JOIN catalog_product_entity_int ON catalog_product_entity_text.entity_id=catalog_product_entity_int.entity_id
WHERE catalog_product_entity_text.attribute_id=73 AND catalog_product_entity_int.attribute_id=159 AND catalog_product_entity_int.value=1 ;
->
UPDATE catalog_product_entity_text LEFT JOIN catalog_product_entity_int ON catalog_product_entity_text.entity_id=catalog_product_entity_int.entity_id
SET catalog_product_entity_text.value='Free shipping within USA, 48 states only'
WHERE catalog_product_entity_text.attribute_id=73 AND catalog_product_entity_int.attribute_id=159 AND catalog_product_entity_int.value=1 ;
->
SELECT * FROM catalog_product_entity_text LEFT JOIN catalog_product_entity_int ON catalog_product_entity_text.entity_id=catalog_product_entity_int.entity_id
WHERE catalog_product_entity_text.attribute_id=73 AND catalog_product_entity_int.attribute_id=160 AND catalog_product_entity_int.value=1 ;
->
UPDATE catalog_product_entity_text LEFT JOIN catalog_product_entity_int ON catalog_product_entity_text.entity_id=catalog_product_entity_int.entity_id
SET catalog_product_entity_text.value='Shipping and handling: $3.5 Each additional item $0.2 FREE SHIPPING ON ORDERS OVER $25'
WHERE catalog_product_entity_text.attribute_id=73 AND catalog_product_entity_int.attribute_id=160 AND catalog_product_entity_int.value=1 ;
(20200422)在aws-dv上作
手工修改aws-dv ro站b4_free_shipping的產品說明刪除shipping價格
ID: 0 - 2200 b4 Free Shipping: Yes 14 records found
To buy this item can be combined with any products in our web store. If your order don't excess minimum amount, a shipping must be charged.
2043,2045,2052,2134,2135,2138,2139,2140,2142,2143,2144,2145,2147,2194
--- 20200422 AWS-QT 改產品頁 short description 內容改 shipping + AWS-DV 預先直接改RO的1元產品說明
=========================================================================================================================
cd /var/www/magento2/
mkdir -p app/design/frontend/Lee/pwc/Magento_Theme/templates/html/header/
cp vendor/magento/module-theme/view/frontend/templates/html/header/logo.phtml app/design/frontend/Lee/pwc/Magento_Theme/templates/html/header/logo.phtml
joe app/design/frontend/Lee/pwc/Magento_Theme/templates/html/header/logo.phtml
line 22->刪除
= $block->getLogoHeight() ? 'height="' . $block->escapeHtmlAttr($block->getLogoHeight()) . '"' :'' ?>
--- 20200421 AWS-QT 改首頁 logo 固定長寬比
=========================================================================================================================
cd /var/www/magento2/
cp vendor/magento/module-catalog/view/frontend/templates/product/list.phtml app/design/frontend/Lee/pwc/Magento_Catalog/templates/product/list.phtml
joe app/design/frontend/Lee/pwc/Magento_Catalog/templates/product/list.phtml
line 71->
SKU#: ').$_product->getSku() ?>
--- 20200421 AWS-QT 改產品列表頁加 SKU
=========================================================================================================================
joe /var/www/magento2/app/design/frontend/Lee/pwc/Magento_Cms/templates/html/homepage/home_content.phtml
//$categoryId = 85; //FEATURE ITEMS
//$category = $categoryModel->load($categoryId);
$productCollection = $productCollection
->setVisibility([2,3,4])
->addAttributeToFilter('status', ['in' => [1]])
->addMinimalPrice()
->addFinalPrice()
->addTaxPercents()
->addAttributeToSelect($catalogConfig->getProductAttributes())
->addUrlRewrite()
->addStoreFilter()
->setPageSize(8)
->setCurPage(1)
->addAttributeToFilter('featured',1);
//->addCategoryFilter($category);
getName()*/; ?>
--- 20200421 AWS-QT 改首頁跑馬燈直接抓 attribute featured 產品
=========================================================================================================================
(20200420 10:50)
T-1.)magento2.3.4(現成) + 導入magento8pm_20200420_1050.sql + 修改資料庫 + 刪無用data + 升級資料庫
導出資料庫-aws-dv
mysqldump -u root -prevres88 --databases magento8pm > /var/www/html/magento8pm_20200420_1050.sql
導入資料庫-aws-qt
cd /var/www/bk-gz/
wget 3.22.57.63/magento8pm_20200420_1050.sql
joe magento8pm_20200420_1050.sql
line 22->(原為magento8pm)
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `magento2` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `magento2`;
->
mysql -u root -prevres88
mysql>drop database magento2;
mysql -u root -prevres88 < /var/www/bk-gz/magento8pm_20200420_1050.sql
mysql -u root -prevres88
USE magento2;
先修改資料庫
DROP TABLE ves_blockbuilder_block ;
DROP TABLE ves_blockbuilder_cms ;
DROP TABLE ves_blockbuilder_page ;
DROP TABLE ves_blockbuilder_product ;
DROP TABLE ves_blockbuilder_widget ;
DROP TABLE ves_blog_category ;
DROP TABLE ves_blog_category_store ;
DROP TABLE ves_blog_comment ;
DROP TABLE ves_blog_comment_store ;
DROP TABLE ves_blog_post ;
DROP TABLE ves_blog_post_category ;
DROP TABLE ves_blog_post_related ;
DROP TABLE ves_blog_post_store ;
DROP TABLE ves_blog_post_tag ;
DROP TABLE ves_brand ;
DROP TABLE ves_brand_group ;
DROP TABLE ves_brand_product ;
DROP TABLE ves_brand_store ;
DROP TABLE ves_megamenu_item ;
DROP TABLE ves_megamenu_menu ;
DROP TABLE ves_megamenu_menu_store ;
DROP TABLE ves_testimonial_testimonial ;
DROP TABLE ves_testimonial_testimonial_store ;
DROP TABLE core_config_dataBK;
DROP TABLE theme_0 ;
DROP TABLE catalog_category_entity_text_20191212 ;
DELETE FROM core_config_data WHERE path='dev/static/sign';
DELETE FROM core_config_data WHERE path LIKE 'ves%' ;
UPDATE core_config_data SET value='2' WHERE path='design/theme/theme_id' ;
UPDATE core_config_data SET value='pwc-home' WHERE path='web/default/cms_home_page' AND scope_id=5 ;
DELETE FROM url_rewrite WHERE store_id=1 OR store_id=2 ;
DELETE FROM url_rewrite WHERE request_path LIKE 'ves%' OR target_path LIKE 'ves%' ;
DELETE FROM url_rewrite WHERE request_path LIKE 'zou%' OR target_path LIKE 'zou%' ;
DELETE FROM url_rewrite WHERE url_rewrite_id<=24838 AND entity_type='category' ;
DELETE FROM admin_user WHERE user_id < 5 ;
DELETE FROM store WHERE store_id=1 OR store_id=2 ;
DELETE FROM theme WHERE theme_id > 3 ;
x->DELETE FROM cms_page WHERE page_id <> 2 AND page_id <> 30 AND page_id <> 36 AND page_id <> 37 AND page_id <> 42 AND page_id <> 44 AND page_id <> 45 AND page_id <> 49;
新增加 1:404 + 3:Enable Cookies
DELETE FROM cms_page WHERE page_id>4 AND page_id<>30 AND page_id<>36 AND page_id<>37 AND page_id<>42 AND page_id<>44 AND page_id<>45 AND page_id<>49;
TRUNCATE TABLE cms_page_store;
INSERT INTO cms_page_store (page_id,store_id) VALUES (1,0) ; (新增加)
INSERT INTO cms_page_store (page_id,store_id) VALUES (2,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (3,0) ; (新增加)
INSERT INTO cms_page_store (page_id,store_id) VALUES (30,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (36,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (37,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (42,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (44,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (45,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (49,0) ;
DELETE FROM cms_block WHERE is_active=0;
DELETE FROM cms_block_store WHERE block_id<32;
x->UPDATE catalog_product_entity_text SET value='' WHERE value LIKE '%s-Desc%';
(20200422)改為修改short description為shipping
free_shipping->
UPDATE catalog_product_entity_text LEFT JOIN catalog_product_entity_int ON catalog_product_entity_text.entity_id=catalog_product_entity_int.entity_id
SET catalog_product_entity_text.value='Free shipping within USA, 48 states only'
WHERE catalog_product_entity_text.attribute_id=73 AND catalog_product_entity_int.attribute_id=159 AND catalog_product_entity_int.value=1 ;
b4_free_shipping->
UPDATE catalog_product_entity_text LEFT JOIN catalog_product_entity_int ON catalog_product_entity_text.entity_id=catalog_product_entity_int.entity_id
SET catalog_product_entity_text.value='Shipping and handling: $3.5 Each additional item $0.2 FREE SHIPPING ON ORDERS OVER $25'
WHERE catalog_product_entity_text.attribute_id=73 AND catalog_product_entity_int.attribute_id=160 AND catalog_product_entity_int.value=1 ;
(20200422)一定要補作否則checkout會出錯
DELETE FROM core_config_data WHERE path LIKE 'payment/%' AND
path<>'payment/authorizenet_acceptjs/cctypes' AND
path<>'payment/authorizenet_acceptjs/currency' AND
path<>'payment/authorizenet_acceptjs/order_status' AND
path<>'payment/authorizenet_acceptjs/payment_action' ;
-------------- 以下正式轉不用作-----------------
UPDATE core_config_data SET value='http://qt.wg-1.com/' WHERE value='http://www.buck4u.com/';
UPDATE core_config_data SET value='https://qt.wg-1.com/' WHERE value='https://www.buck4u.com/';
UPDATE core_config_data SET value='http://qt.purewaterclub.com/' WHERE value='http://www.purewaterclub.com/';
UPDATE core_config_data SET value='https://qt.purewaterclub.com/' WHERE value='https://www.purewaterclub.com/';
升級資料庫
cd /var/www/magento2/
php bin/magento setup:upgrade
php bin/magento cache:clean
php bin/magento indexer:reindex
chown -R www-data:www-data .
->OK
後台手工改設定
CONTENT->Configuration->改全部theme(web site+store+2 store view)為pwc(原為luma)
CATALOG->Category->Default Category->Design->Use Parent Category Settings->Yes
將PWC下3個子目錄搬至Default Category下 + 刪PWC
x->新增Parts & Tools目錄下FEATURE ITEMS子目錄(ID:應為85)->86 (20200421 前台跑馬燈已改程式)
x->joe /var/www/magento2/app/design/frontend/Lee/pwc/Magento_Cms/templates/html/homepage/home_content.phtml
$categoryId = 86; //85; //FEATURE ITEMS //2;
x->將feature enable的15個product添加FEATURE ITEMS目錄
--- 20200420 第2次試轉 AWS-DV magento8pm 成功
=========================================================================================================================
rm /etc/nginx/sites-enabled/zou-wg-1
rm /etc/nginx/sites-enabled/qtpic-wg-1
mv /etc/nginx/sites-enabled/aws-wg-1* /etc/nginx/sites-available/
ln -s /etc/nginx/sites-available/aws-wg-1 /etc/nginx/sites-enabled/
joe /var/www/magento2/nginx.conf.sample
line 188->
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# START - Multisite customization
fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
fastcgi_param MAGE_MODE $MAGE_MODE;
# END - Multisite customization
include fastcgi_params;
}
joe /etc/nginx/sites-available/qt-wg-1->
upstream fastcgi_backend {
server unix:/run/php/php7.2-fpm.sock;
}
map $http_host $MAGE_RUN_CODE {
qt.wg-1.com b4u_home;
qt.purewaterclub.com pwc_ro;
}
server {
listen 80;
server_name qt.wg-1.com;
set $MAGE_ROOT /var/www/magento2;
set $MAGE_MODE developer;
set $MAGE_RUN_TYPE store;
include /var/www/magento2/nginx.conf.sample;
error_log /var/log/nginx/error.log;
}
server {
listen 80;
server_name qt.purewaterclub.com;
set $MAGE_ROOT /var/www/magento2;
set $MAGE_MODE developer;
set $MAGE_RUN_TYPE store;
include /var/www/magento2/nginx.conf.sample;
error_log /var/log/nginx/error.log;
}
預作nginx的buck4u + pwc 設定
cp /etc/nginx/sites-available/qt-wg-1 /etc/nginx/sites-available/b4-pwc-wk
joe /etc/nginx/sites-available/b4-pwc-wk
upstream fastcgi_backend {
server unix:/run/php/php7.2-fpm.sock;
}
map $http_host $MAGE_RUN_CODE {
www.buck4u.com b4u_home;
www.purewaterclub.com pwc_ro;
}
server {
listen 80;
server_name www.buck4u.com;
set $MAGE_ROOT /var/www/magento2;
set $MAGE_MODE developer;
set $MAGE_RUN_TYPE store;
include /var/www/magento2/nginx.conf.sample;
error_log /var/log/nginx/error.log;
}
server {
listen 80;
server_name www.purewaterclub.com;
set $MAGE_ROOT /var/www/magento2;
set $MAGE_MODE developer;
set $MAGE_RUN_TYPE store;
include /var/www/magento2/nginx.conf.sample;
error_log /var/log/nginx/error.log;
}
以下正式轉好才作--------------
rm /etc/nginx/sites-enabled/qt-wg-1
ln -s /etc/nginx/sites-available/b4-pwc-wk /etc/nginx/sites-enabled/
systemctl restart nginx
systemctl restart php7.2-fpm
--- 20200420 AWS-QT nginx 設定
=========================================================================================================================
(20200419 19:19)
T-1.)magento2.3.4(現成) + 導入magento8pm_20200419_1920.sql + 修改資料庫 + 刪無用data + 升級資料庫
x->後台手工改pwc home page(直接改SQL不用作)
x->STORE->Configuration->Store View->pwc_ro->GENERAL->Web->Default Pages->CMS Home Page->purewaterclub.com(原為Home Page)
導出資料庫-aws-dv
mysqldump -u root -prevres88 --databases magento8pm > /var/www/html/magento8pm_20200419_1920.sql
備份資料庫-aws-qt
cp magento2 magento2_234_8pm_20200419_lee_ok -r
mysqldump -u root -prevres88 --databases magento2 > /var/www/bk-gz/magento2_234_8pm_20200419_lee_ok.sql
導入資料庫
wget 3.22.57.63/magento8pm_20200419_1920.sql
joe magento8pm_20200419_1920.sql
line 22->(原為magento8pm)
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `magento2` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `magento2`;
->
mysql -u root -prevres88
mysql>drop database magento2;
mysql -u root -prevres88 < /var/www/bk-gz/magento8pm_20200419_1920.sql
mysql -u root -prevres88
USE magento2;
先修改資料庫
DROP TABLE ves_blockbuilder_block ;
DROP TABLE ves_blockbuilder_cms ;
DROP TABLE ves_blockbuilder_page ;
DROP TABLE ves_blockbuilder_product ;
DROP TABLE ves_blockbuilder_widget ;
DROP TABLE ves_blog_category ;
DROP TABLE ves_blog_category_store ;
DROP TABLE ves_blog_comment ;
DROP TABLE ves_blog_comment_store ;
DROP TABLE ves_blog_post ;
DROP TABLE ves_blog_post_category ;
DROP TABLE ves_blog_post_related ;
DROP TABLE ves_blog_post_store ;
DROP TABLE ves_blog_post_tag ;
DROP TABLE ves_brand ;
DROP TABLE ves_brand_group ;
DROP TABLE ves_brand_product ;
DROP TABLE ves_brand_store ;
DROP TABLE ves_megamenu_item ;
DROP TABLE ves_megamenu_menu ;
DROP TABLE ves_megamenu_menu_store ;
DROP TABLE ves_testimonial_testimonial ;
DROP TABLE ves_testimonial_testimonial_store ;
DROP TABLE core_config_dataBK;
DROP TABLE theme_0 ;
DROP TABLE catalog_category_entity_text_20191212 ;
DELETE FROM core_config_data WHERE path='dev/static/sign';
DELETE FROM core_config_data WHERE path LIKE 'ves%' ;
UPDATE core_config_data SET value='2' WHERE path='design/theme/theme_id' ;
UPDATE core_config_data SET value='pwc-home' WHERE path='web/default/cms_home_page' AND scope_id=5 ;
DELETE FROM url_rewrite WHERE store_id=1 OR store_id=2 ;
DELETE FROM url_rewrite WHERE request_path LIKE 'ves%' OR target_path LIKE 'ves%' ;
DELETE FROM url_rewrite WHERE request_path LIKE 'zou%' OR target_path LIKE 'zou%' ;
DELETE FROM url_rewrite WHERE url_rewrite_id<=24838 AND entity_type='category' ;
DELETE FROM admin_user WHERE user_id < 5 ;
DELETE FROM store WHERE store_id=1 OR store_id=2 ;
DELETE FROM theme WHERE theme_id > 3 ;
DELETE FROM cms_page WHERE page_id <> 2 AND page_id <> 30 AND page_id <> 36 AND page_id <> 37 AND page_id <> 42 AND page_id <> 44 AND page_id <> 45 AND page_id <> 49;
TRUNCATE TABLE cms_page_store;
INSERT INTO cms_page_store (page_id,store_id) VALUES (2,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (30,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (36,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (37,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (42,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (44,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (45,0) ;
INSERT INTO cms_page_store (page_id,store_id) VALUES (49,0) ;
DELETE FROM cms_block WHERE is_active=0;
DELETE FROM cms_block_store WHERE block_id<32;
UPDATE catalog_product_entity_text SET value='' WHERE value LIKE '%s-Desc%';
-------------- 以下正常轉不用作-----------------
INSERT INTO core_config_data (scope,scope_id,path,value) VALUES ('default',0,'web/default/cms_home_page','home');
UPDATE cms_page SET page_layout='1column',content_heading='',custom_theme='' WHERE page_id=2 ;
UPDATE core_config_data SET value='http://qt.wg-1.com/' WHERE value='http://www.buck4u.com/';
UPDATE core_config_data SET value='https://qt.wg-1.com/' WHERE value='https://www.buck4u.com/';
UPDATE core_config_data SET value='http://qt.wg-1.com/' WHERE value='http://www.purewaterclub.com/';
UPDATE core_config_data SET value='https://qt.wg-1.com/' WHERE value='https://www.purewaterclub.com/';
升級資料庫
cd /var/www/magento2/
php bin/magento setup:upgrade
php bin/magento cache:clean
php bin/magento indexer:reindex
chown -R www-data:www-data .
->OK,bug前台buck4u點logo跳至pwc
後台手工改設定
CONTENT->Configuration->改全部theme(web site+store+2 store view)為pwc(原為luma)
CATALOG->Category->PWC->Design->Use Parent Category Settings->Yes
新增Parts & Tools目錄下FEATURE ITEMS子目錄(ID:應為85)
將PWC下3個子目錄搬至Default Category下+刪PWC
將feature enable的15個product添加FEATURE ITEMS目錄
-------------------------
停止theme Zou產品頁custom tab
mv /var/www/magento2/app/design/frontend/Lee/pwc/Magento_Catalog/layout/catalog_product_view.xml /var/www/magento2/app/design/frontend/Lee/pwc/Magento_Catalog/layout/catalog_product_view.xml-0
停止theme Zou目錄頁上方大圖
mv /var/www/magento2/app/design/frontend/Lee/pwc/Magento_Catalog/layout/catalog_category_view.xml /var/www/magento2/app/design/frontend/Lee/pwc/Magento_Catalog/layout/catalog_category_view.xml-0
批次修改short description防止queue
FREE Shipping
php bin/magento cron:run
joe /var/www/magento2/var/log/magento.cron.log
--- 20200419 AWS-QT magento2.3.4 + 第1次試轉 sql AWS-DV magento8pm 成功
=========================================================================================================================
0.)測試
50GPD Home drinking RO System w/tank extra free 3 PC filters
RQ-5T-50+3
1.)改mysql設定可以查2英文字
參考->https://dev.mysql.com/doc/refman/5.6/en/fulltext-fine-tuning.html#fulltext-word-length
joe /etc/mysql/my.cnf->增加
[mysqld]
innodb_ft_min_token_size=2
ft_min_word_len=2
->
systemctl restart mysql
mysql -u root -p
失敗->mysql> SET GLOBAL innodb_ft_min_token_size = 2;->ERROR 1238 (HY000): Variable 'innodb_ft_min_token_size' is a read only variable
mysql>SHOW VARIABLES LIKE 'innodb_ft_min_token_size';
->
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| innodb_ft_min_token_size | 2 |(原本為3)
+--------------------------+-------+
1 row in set (0.00 sec)
mysql>SHOW VARIABLES LIKE 'ft_min_word_len';
->
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| ft_min_word_len | 2 |(原本為4)
+-----------------+-------+
1 row in set (0.00 sec)
->
2.)修改系統查詢
cd /var/www/magento2
joe vendor/magento/module-catalog-search/etc/search_request.xml
line 16->
(原為should,改為must)
->
/usr/bin/php bin/magento indexer:reindex
/usr/bin/php bin/magento cache:flush
--- 20200419 AWS-QT RO站前台查不到SKU
=========================================================================================================================
magento2->表customer_entity->password_hash
1@aa.com + aa223344
140e8587c46ea4afc679cb70bae56341:70:0->aa223344-osc-v.1
$P$DNVAIbn8kZQQop6d3QAg2lFVkSG2o2/:P$DNVAIbn8kZQQop6d3QAg2lFVkSG2o2/:0->aa223344-osc-v.2
fe3b24a5674b3b2c7fdb8bfe4665037271c85b87d4a0e7b011e369fbe1dab83c:vVuPQqsPntRvuyEw:2->aa223344-magento2.3.4
joe /var/www/magento2/vendor/magento/framework/Encryption/Encryptor.php
1.)修改原有的isValidHash(),加入判斷利用salt位置傳遞的hash值是否為osc v.2,並比對由GenPasswordHash()產生的v.2 hash是否正確
line 272->
public function isValidHash($password, $hash)
{
$this->explodePasswordHash($hash);
foreach ($this->getPasswordVersion() as $hashVersion) {
// $password = $this->hash($this->getPasswordSalt() . $password, $hashVersion);
public function isValidHash($password, $hash)
{
try {
$this->explodePasswordHash($hash);
$recreated = $password;
foreach ($this->getPasswordVersion() as $hashVersion) {
if ($hashVersion === self::HASH_VERSION_ARGON2ID13) {
$recreated = $this->getArgonHash($recreated, $this->getPassw
} else {
//----- 20200419 DV -------
// remark oraginal code
// $recreated = $this->generateSimpleHash($this->getPasswordSalt() . $recreated, $hashVersion);
// code add by dv
$tmpsalt=$this->getPasswordSalt();
//--- check if RO Site 2nd password hash ($P$D... 33 digit)->(P$D... 32 digit)
if($hashVersion==0 && substr($tmpsalt,0,3)=='P$D'){
//--- make hash by salt
$tmpsalt="$".$tmpsalt;
//--- check if password OK with SQL hash($ + P$D..)
if($this->GenPasswordHash($password,$tmpsalt)==$tmpsalt){
//--- set password -> generated hash
$recreated=$tmpsalt;
}
}
else{
// run oraginal code
$recreated = $this->generateSimpleHash($this->getPasswordSalt() . $recreated, $hashVersion);
}
//----------------------------------------------------------
}
$hash = $this->getPasswordHash();
}
} catch (\RuntimeException $exception) {
//Hash is not a password hash.
$recreated = $this->hash($password);
}
return Security::compareStrings(
$recreated,
$hash
);
}
2.)新增產生osc v.2的password hash
line 269->
//----- 20200419 DV ---------------------------------------------------------
public function GenPasswordHash($password,$setting){
$itoa64='./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$count_log2 = strpos($itoa64,$setting[3]);
if ($count_log2 < 7 || $count_log2 > 30)return $output;
$count = 1 << $count_log2;
$salt = substr($setting, 4, 8);
if (strlen($salt) != 8)return $output;
if (PHP_VERSION >= '5') {
$hash = md5($salt . $password, TRUE);
do {
$hash = md5($hash . $password, TRUE);
} while (--$count);
}
else {
$hash = pack('H*', md5($salt . $password));
do {
$hash = pack('H*', md5($hash . $password));
} while (--$count);
}
$output = substr($setting, 0, 12);
$tmpout = '';
$count=16;
$i = 0;
do {
$value = ord($hash[$i++]);
$tmpout .= $itoa64[$value & 0x3f];
if ($i < $count)$value |= ord($hash[$i]) << 8;
$tmpout .= $itoa64[($value >> 6) & 0x3f];
if ($i++ >= $count)break;
if ($i < $count)$value |= ord($hash[$i]) << 16;
$tmpout .= $itoa64[($value >> 12) & 0x3f];
if ($i++ >= $count)break;
$tmpout .= $itoa64[($value >> 18) & 0x3f];
}while ($i < $count);
$output .= $tmpout;
return $output;
}
//----------------------------------------------------------
--- 20200419 AWS-QT 改相容舊RO站客戶登入密碼核心 PHP
=========================================================================================================================
cd /var/www/magento2/app/design/frontend/
cp Zou Lee -r
mv Lee/demo Lee/pwc
joe Lee/pwc/registration.php->
'frontend/Lee/pwc',
joe Lee/pwc/theme.xml->
pwc
cd /var/www/magento2/
php bin/magento cache:flush
改完所有store的theme->pwc
rm /var/www/magento2/app/design/frontend/Zou -r
後台刪theme Zou
--- 20200419 AWS-QT 改Zou/demo -> Lee/pwc
=========================================================================================================================
清理aws-dv
cd /var/www/html/magento8pm-20200319-braintree-ok-dv-fix-chen-test-ok/
tar -czf magento8pm-20200319-braintree-ok-dv-fix-chen-test-ok.tar.gz *
cd /var/www/html/magento8pm-20200416
tar -czf magento8pm-20200416.tar.gz *
mysqldump -u root -prevres88 --databases magento8pm > magento8pm_20200418.sql
----------------------------------------------------
/dev/xvda1 30G 24G 5.5G 82% /
(20200419 11:06)點Flush Cache Storage按鈕->(等於同時按下面3按鈕)
/dev/xvda1 30G 21G 8.2G 72% /
root@awsko:/var/www/html/magento8pm# du -sh -> 810M
----------------------------------------------------
整理+備份aws-qt(wget aws-dv gz)
cd /var/www/bk-gz/
wget 3.22.57.63/magento8pm-20200319-braintree-ok-dv-fix-chen-test-ok.tar.gz
wget 3.22.57.63/magento8pm-20200416.tar.gz
wget 3.22.57.63/magento2-20200405.tar.gz
wget 3.22.57.63/magento232-20200405.tar.gz
wget 3.22.57.63/magento8pm_20200418.sql
cd /var/www/magento2-219-org-ok
tar -czf /var/www/bk-gz/magento2-219-org-ok.tar.gz *
cd /var/www/magento2-219-qt-20200409-ok
tar -czf /var/www/bk-gz/magento2-219-qt-20200409-ok.tar.gz *
cd /var/www/magento2-20200407-org-ok
tar -czf /var/www/bk-gz/magento2-20200407-org-ok.tar.gz *
cd /var/www/magento2_234_8pm_20200414_ok
tar -czf /var/www/bk-gz/magento2_234_8pm_20200414_ok.tar.gz *
cd /var/www/magento2_234_8pm_20200415_ok
tar -czf /var/www/bk-gz/magento2_234_8pm_20200415_ok.tar.gz *
cd /var/www/magento2_234_8pm_20200416_ada_ok
tar -czf /var/www/bk-gz/magento2_234_8pm_20200416_ada_ok.tar.gz *
cd /var/www/pwpic
tar -czf /var/www/bk-gz/pwpic-20200418-new-dir.tar.gz *
cd /var/www/
cp magento2 magento2_234_8pm_20200418_zou_ok -r
mysqldump -u root -prevres88 --databases magento2 > /var/www/bk-gz/magento2_234_8pm_20200418_zou_ok.sql
--- 20200419 整理+備份 AWS-DV + AWS-QT
=========================================================================================================================
備份magento 2.3.4 + 資料庫
cd /var/www/
cp magento2 magento2_234_8pm_ada_ml_20200417_ok -r
mysqldump -u root -prevres88 --databases magento2 > /var/www/bk-gz/magento2_234_8pm_ada_ml_20200417_ok.sql
安裝 Theme Zou demo
cd /var/www/magento2/app/design/frontend/
wget 118.163.15.73/Zou.zip
unzip -q Zou.zip
cd /var/www/magento2/
php bin/magento cache:flush
->OK,測所有index,upgrade,compile,deploy->OK
參考Theme Zou指向demo.js
/var/www/magento2/app/design/frontend/Zou/demo/requirejs-config.js
Magento_Theme/layout/default_head_blocks.xml
參考http://owlcarousel2.github.io/OwlCarousel2/docs/api-options.html
改首頁跑馬燈
joe /var/www/magento2/app/design/frontend/Zou/demo/web/js/demo.js
loop: true,
autoplay: true,
autoplayTimeout: 3000,
dots: true,
items: 5,
mouseDrag: true,
responsive:{
0:{
items:2
},
480:{
items:2
},
767:{
items:4
},
992:{
items:4
},
1200:{
items:5
->
改首頁導航背景色(去掉zou transparent)
joe /var/www/magento2/app/design/frontend/Zou/demo/web/css/demo.css ->最後2行transparent都去掉?
.sections.nav-sections {
/* background: transparent; */
->
改首頁跑馬燈指定目錄
joe /var/www/magento2/app/design/frontend/Zou/demo/Magento_Cms/templates/html/homepage/home_content.phtml
joe /var/www/magento2/app/design/frontend/Lee/pwc/Magento_Cms/templates/html/homepage/home_content.phtml
$categoryId = 85; //FEATURE ITEMS (原為3)
(20200419)
將HOT SELLERS和FEATURE ITEMS上下對調
->
改首頁目錄連接頁在最上面 + 去掉zou slider + static block
joe /var/www/magento2/app/design/frontend/Zou/demo/Magento_Cms/layout/cms_index_index.xml
->(原為before="home_block_container")
參考底部luma layout xml
/var/www/magento2/vendor/magento/theme-frontend-luma/Magento_Theme/layout/default.xml
改zou底部留luma 版權 + 去掉store view選擇
joe /var/www/magento2/app/design/frontend/Zou/demo/Magento_Theme/layout/default.xml
->
改zou底部去掉中間 + 去掉左右大title + 去掉版權
joe /var/www/magento2/app/design/frontend/Zou/demo/Magento_Theme/templates/html/footer_cont.phtml
joe /var/www/magento2/app/design/frontend/Lee/pwc/Magento_Theme/templates/html/footer_cont.phtml
Design->Layout Update XML
block-slideshow-bannertopblock-banner-centernew-products-carouselbanner-mass-bottomproduct-tabsbanner-mass-bottom2
--- 20200202 product-list
=========================================================================================================================
Base URL for User Media Files:/var/www/html/magento8pm/pub/media/
8pm Slider dv