[Magento 2.4.3] SQLSTATE[HY000]: General error: 1419 You do not have the SUPER privilege and binary logging is enabled in setup:performance:generate-fixtures – Solved

Background:

Run below commander in Magento CLI

php bin/magento setup:performance:generate-fixtures -s setup/performance-toolkit/profiles/ce/small.xml

Error msg:

Generating profile with following params:
 |- Admin Users: 50
 |- Websites: 1
 |- Store Groups Count: 1
 |- Store Views Count: 1
 |- Categories: 30
 |- Attribute Sets (Default): 3
 |- Attribute Sets (Extra): 10
 |- Simple products: 800
 |- Configurable products: 16
 |- Product images: 100, 3 per product
 |- Customers: 200
 |- Cart Price Rules: 20
 |- Catalog Price Rules: 20
 |- Coupon Codes: 20
 |- Orders: 80
Config Changes...  done in 00:00:00
SQLSTATE[HY000]: General error: 1419 You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable), query was: CREATE TRIGGER trg_catalog_category_entity_after_insert AFTER INSERT ON catalog_category_entity FOR EACH ROW
BEGIN
INSERT IGNORE INTO `catalog_category_product_cl` (`entity_id`) VALUES (NEW.`entity_id`);
END


How to fix

run in MySQL with root user

set global log_bin_trust_function_creators=1;

Refrence Link:

bitnami community

stackexchange magento

save product redirect to dashboard in Magento backend 编辑保存产品跳转到后台首页

去检查防火墙设置,check firewall seetings on host

我的解决办法,可能不适合你,因为我使用的是宝塔面板,里面有一个收费插件, Nginx防火墙 ,我看到了日志里有关于CC的拦截警告,我的IP也在其中,添加到白名单之后,正常工作。

前面是问题背景和尝试的办法:

Magento Version is 1.9.4.0 点击修改保存按钮后,直接跳转到Dashboard页面了,产品也没保存成功。

网上有些人遇到过,第三个连接提到了 mod_secure 需要关闭,但我不建议这样做。

以下连接:

1.https://magento.stackexchange.com/questions/181083/product-save-and-continue-redirect-to-dashboard

2.https://community.magento.com/t5/Magento-1-x-Technical-Issues/Magento-not-saving-product-edits-and-redirects-to-dashboard/td-p/40275

3. https://stackoverflow.com/questions/37999189/magento-not-saving-product-edits-and-redirects-to-dashboard

我尝试过,换到另外一个服务器,没问题。当然第二台服务器没有开启防火墙

[Solved]Magento install with docker MySql 8 error connect refuse 数据库拒绝链接错误

问题点:

数据库的加密方式( caching_sha2_password )问题造成的。

当然,你有义务去检查的账号密码,至少在命令行里可以正常使用。还有mysql.user的host里是 %(代表已开启远程链接)。

参考链接 中第四点

select host,user,plugin,authentication_string from mysql.user;

看下plugin的加密方式,mysql 8 之后使用了caching_sha2_password,而非比较传统的mysql_native_password,所以如下更新

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';  ### 把root改成123456 mysql的登录密码
flush privileges; ### 刷新生效

这样子,root就可以链接了,更好的做法是选择你相应的数据库user 而不是root。

此外,版本低于12的Navicat可以连接了。

当然,此外是否配置了正确的端口映射/防火墙等其他问题,也是需要注意。

Disallowed file type. magento upload error

后台上传图片遇到这个错误。

如果确保文件类型没错的话,正常的解决办法是 增加后台对于图片
Maximum width  的设置:

System > Configuration > Catalog > Product Image

一般设置到1200~1500px左右,或者按照你实际的来。

参考链接

此外还有一些文章提到CSRF问题,和magento 漏洞有关,希望可以帮到你

中文版

Magento PATCH_SUPEE-11085 get Fatal error: Can’t use method return value in write context in /app/code/core/Mage/Authorizenet/Model/Directpost.php on line 391

Note:这篇文章的解决对象是PHP 5.5 以下版本的magento 报错,如果不是PHP 5.5以下版本,可能帮不到你。我使用的是1.9版本的Magento

PATCH_SUPEE-11085 主要是Magento 应对Authrize 变更key的加密类型,Pacth在SSH很好打。但是在后台创建订单时会像文章标体那样报错。

主要问题点是 PHP 5.5以下版本empty() 函数不能检查变量。

所以把line 391代码修改来适配

$response_data = $response->getData('x_SHA2_Hash'); //rewrite for PHP 5.5 lower BY Burt
  $hashConfigKey = !empty($response_data) ? 'signature_key' : 'trans_md5';

主要参考资料

stock flow

Magento Guide Authorize key

Magento CAPTCHA not show image backend and frontend 验证码不显示1.x版本

最近,Magento官方给出防止暴力破解安全防范意见:

全文连接在此

主要操作包括修改后台管理地址、限制登录错误次数、CAPTCHA、开启安全扫描、两步验证等(个人建议应该加上:使用更强壮的管理员密码)

关于CAPTCHA,以前就遇到过设置了,但是前台或者后台验证码图片并不显示的问题,但是不是必选项,没有深入的了解过。

【对了,如果不熟悉怎么设置CAPTCHA 可以点击这个连接(1.x版本,留意关于contact部分因为市场已经改版,所以失效)来了解如何操作】

简单来说就是文件权限问题。/media/captcha 这个文件夹(里面还有admin和base两个子文件夹)需要有读写权限。修改成775一般就可以了。我直接在FTP里修改还不成功,需要重命名后手动创建。这样前台就可以正常显示了。

终究来说,还是主机没有一个很好的config来适配Magento。

问题到此解决,如果没有办法直接访问FTP修改权限,网络也提供了数据库关闭此项设置的mysql语句:

Update 
  core_config_data  set value=0
WHERE  path LIKE  '%admin/captcha/enable%'

来自 stackflow

这样,你至少还可以继续登录后台。

 

喜乐打赏

magento order number 自定义

主要涉及2个表,eav_entity_type和eav_entity_store

SELECT entity_type_id,entity_type_code,increment_pad_length FROM `eav_entity_type` WHERE entity_type_code =’order’;

SELECT * FROM `eav_entity_store`;

一般order很长,第一个increment_pad_length(eav_entity_type)是订单号码除了increment_prefix(eav_entity_store表)的长度。

increment_last_id(eav_entity_type)是系统组后一个订单号码


如果系统已经有了订单,存在了订单号码,可以sql语句更新

参考:

 

mysql_connect(“localhost”,$user,$psw);

mysql_select_db($db);
$store_id=1;
$prefix=’ABC’;
$start_num=’10001′;

$rs=mysql_query(“SELECT * FROM `sales_flat_order` a WHERE a.`store_id`='”.$store_id.”‘”);

while ($rw=mysql_fetch_array($rs))
{
$order_id=$rw[‘entity_id’];
$order_num = $rw[‘increment_id’];
$order_num_new=$prefix.$start_num;
$start_num++;

echo $order_id.'<br/>’;
echo $order_num.'<br/>’;
echo $order_num_new.'<br/>’;

mysql_query(“update `sales_flat_order` set `increment_id`='”.$order_num_new.”‘ where `increment_id`='”.$order_num.”‘”);
mysql_query(“update `sales_flat_order_grid` set `increment_id`='”.$order_num_new.”‘ where `increment_id`='”.$order_num.”‘”);

mysql_query(“update `sales_flat_creditmemo` set `increment_id`='”.$order_num_new.”‘ where `order_id`='”.$order_id.”‘”);
mysql_query(“update `sales_flat_creditmemo_grid` set `increment_id`='”.$order_num_new.”‘,`order_increment_id`='”.$order_num_new.”‘ where `order_id`='”.$order_id.”‘”);
mysql_query(“update `sales_flat_invoice` set `increment_id`='”.$order_num_new.”‘ where `order_id`='”.$order_id.”‘”);
mysql_query(“update `sales_flat_invoice_grid` set `increment_id`='”.$order_num_new.”‘,`order_increment_id`='”.$order_num_new.”‘ where `order_id`='”.$order_id.”‘”);
mysql_query(“update `sales_flat_shipment` set `increment_id`='”.$order_num_new.”‘ where `order_id`='”.$order_id.”‘”);
mysql_query(“update `sales_flat_shipment_grid` set `increment_id`='”.$order_num_new.”‘,`order_increment_id`='”.$order_num_new.”‘ where `order_id`='”.$order_id.”‘”);
}

magento compiler 后Class ‘Aschroder_SMTPPro_Model_Mysql4_Setup’ not found and Mage registry key “_singleton/dewatasoft_changeattributeset/observer” already exists 错误

错误的原因是手动运行后台的tool–>compiler 设置了enable有些插件没办正确的编译,比如smtppro和changeattributeset这个两个。

解决问题的关键是,关闭compiler。当然这个时候还能登陆后台,去手动关闭是最快的解决办法了。

进入不了后台,网上推荐有两种办法:

1.FTP暂时关闭插件

具体为登陆ftp之后/app/etc/modules/文件夹下重命名对应的插件xml,刷新缓存,就可以登陆后台,再进行操作。

2.SSH进入,关闭compiler

登陆网站所在根目录后 ,执行php -f compiler.php disable

其他的命令包含php -f compiler.php compile 和php -f compiler.php enable

以上内容参考:

stackexchange上Murtuza Zabuawala的回答

stackexchange上Mayers的回答

还有一个值得阅读的帖子

Mage registry key “_singleton/tax/observer” already exists

Magento 后台CMS page 404错误,Error 404 Page Not Found on CMS-page of Magento

登陆后台 点击cms–page 弹出Error 404 Page Not Found 错误页面。如果文件没有丢失的话,是因为删除了store view或者是store的问题。

解决办法,mysql查询:

DELETE FROM cms_page_store
WHERE store_id NOT IN (SELECT store_id FROM core_store);

已经存在的cms page里有些scope指定了store viewsh或store

先删除store view,这里就会出现这个错误。

参考链接:

mdnsolutions.com/

PHP7环境安装magento报错Fatal error: Uncaught Error: Function name must be a string in \app\code\core\Mage\Core\Model\Layout.php:555 Stack trace: #0

magento安装在php7以上的环境是时候,安装或运行的时候有个错误:

Fatal error: Uncaught Error: Function name must be a string in C:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\Layout.php:555 Stack trace: #0 C:\xampp\htdocs\magento\app\code\core\Mage\Core\Controller\Varien\Action.php(390): Mage_Core_Model_Layout->getOutput() #1 C:\xampp\htdocs\magento\app\code\core\Mage\Install\controllers\WizardController.php(120): Mage_Core_Controller_Varien_Action->renderLayout() #2 C:\xampp\htdocs\magento\app\code\core\Mage\Core\Controller\Varien\Action.php(418): Mage_Install_WizardController->beginAction() #3 C:\xampp\htdocs\magento\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('begin') #4 C:\xampp\htdocs\magento\app\code\core\Mage\Core\Controller\Varien\Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) #5 > C:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Controller_Varien_Front->dispatch() #6 C:\xampp\htdocs\magento\app\Mage.php(683): Mage_Core_Mo in C:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\Layout.php on line 555

解决方式是:

本地化app\code\core\Mage\Core\Model\Layout.php文件,

找到

$out .= $this->getBlock($callback[0])->$callback[1]();

改成

$out .= $this->getBlock($callback[0])->{$callback[1]}();

清空cache和session就可以。

 

因为在PHP7里需要声明$callback这个变量。

参考连接:

stackexchange 这个页面有给出其他几根收影响的文件。

stackoverflow

magento addAttributeToFilter 的方法和AND OR使用

文章整理来自网络,主要参考有:

http://fishpig.co.uk/magento/tutorials/addattributetofilter/

http://stackoverflow.com/questions/5301231/addattributetofilter-and-or-condition-in-magentos-collection


主要的句子

$_products = Mage::getResourceModel('catalog/product_collection')
   ->addAttributeToSelect(array('name', 'product_url', 'small_image'))
   ->addAttributeToFilter('sku', array('like' => 'UX%'))
    ->load();

 

addAttributeToSelect没什么要说的,只要筛选正确的数据表有的字段就可以

 

eq的两种写法写法

$_products->addAttributeToFilter('status', array('eq' => 1)); // Using the operator
$_products->addAttributeToFilter('status', 1); // Without using the operator

如果上面有不同的筛选,就相当于AND了,OR的写法:

// OR QUERY

$collection->addAttributeToFilter(array(

array(

'attribute' => 'sku','like' => '%ch%'),

array(

'attribute' => 'status','eq' => '1')

));

 

noequal

$_products->addAttributeToFilter('sku', array('neq' => 'test-product'));

 

$_products->addAttributeToFilter('sku', array('like' => 'UX%'));//like

 

$_products->addAttributeToFilter('sku', array('nlike' => 'err-prod%'));//nolike

 

$_products->addAttributeToFilter('id', array('in' => array(1,4,98)));//in

 

$_products->addAttributeToFilter('id', array('nin' => array(1,4,98))); //not in

 

$_products->addAttributeToFilter('description', array('null' => true));  //null

 

$_products->addAttributeToFilter('description', array('notnull' => true)); //not mull

 

$_products->addAttributeToFilter('id', array('gt' => 5));//Greater Than - gt

 

$_products->addAttributeToFilter('id', array('lt' => 5)); //Less Than - lt

 

$_products->addAttributeToFilter('id', array('gteq' => 5)); //Greater Than or Equals To- gteq

 

$_products->addAttributeToFilter('id', array('lteq' => 5)); //Less Than or Equals To - lteq

 

排错方法

// Method 1
Mage::getResourceModel('catalog/product_collection')->load(true);

// Method 2
$collection = Mage::getResourceModel('catalog/product_collection')

echo $collection->getSelect();

 

 

mysql语句根据sku 查询magento的产品名

答案来自http://stackoverflow.com/questions/5323102/magento-products-import-from-database-using-sql-query

第一步,找出各个属性对应的attribute_code

select attribute_code, attribute_id, backend_type from eav_attribute
    where entity_type_id = (select entity_type_id from eav_entity_type where entity_type_code = 'catalog_product')
      and attribute_code in ('name', 'url_path', 'price', 'image', 'description', 'manufacturer');

一般结果为

+----------------+--------------+--------------+
| attribute_code | attribute_id | backend_type |
+----------------+--------------+--------------+
| description    |           61 | text         |
| image          |           74 | varchar      |
| manufacturer   |           70 | int          |
| name           |           60 | varchar      |
| price          |           64 | decimal      |
| url_path       |           87 | varchar      |
+----------------+--------------+--------------+

对应的name是60

第二步

select p.sku, p.entity_id, n.value name
    from catalog_product_entity p
    join catalog_product_entity_varchar n on n.entity_id = p.entity_id
  where n.attribute_id = 60 AND p.sku='001-C';

可以得出结果了,其他属性自己添加查询

再次感谢Joseph Mastey的回答

 

magento bundle product backend tier price 组合产品的分组价格

magento在后台显示bundle的产品时,是按照Percent Discount的折扣率显示的,不能直接显示bundle的分组价格具体是多少

主要改动文件有两个

\app\code\local\Mage\Bundle\Model\Product\Price.php

搜索  / 100

line 618

 // $tierPrice = $finalPrice – ($finalPrice * ($tierPrice / 100));
            $tierPrice = $tierPrice;

如果也要修改group的话,自己对应修改

第二个,去掉数据验证

1). 1.7的版本以上的

app\code\local\Mage\Core\etc\jstranslator.xml

line 165

  <!–   <validate-percents translate="message" module="core">
        <message>Please enter a number lower than 100.</message>
    </validate-percents>
    –>

2) 1.5的版本的js位置是 \js\prototype\validation.js line 717 这个拿掉全局的Js关于百分比的验证

建议的做法是 app\code\core\Mage\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Attributes.php line 96~97

                    //->setPriceColumnHeader(Mage::helper('bundle')->__('Percent Discount'))
                    ->setPriceColumnHeader(Mage::helper('bundle')->__('Price'))
                    //->setPriceValidation('validate-greater-than-zero validate-percents')

去掉验证,又可以改名字

第三,其他一些文件,比如对应前台主题文件需要修改,不然就会

Buy 1 with 300% discount each

Buy 2 with 200% discount each

暂时就是这样,转载记得署名出处