如何在 Magento 2 中验证优惠券而不需要 customerid

问题描述 投票:0回答:1

我是个新人,如果我很愚蠢,请纠正我。

我已将大约 500 万个优惠券代码导入 Magento 2,除了与表“salesrule_customer”的通信之外,一切都运行得很快。

所以我想如果需要验证客户 ID 并始终让所有客户 ID 对于所有购物车规则都有效,我就可以摆脱它。

这就是我需要帮助的地方。我似乎无法确定进行验证的区域。所以我不知道在我的模块中要覆盖什么。

我一直在涉足:Magento\SalesRule\Model\ResourceModel\Rule

但老实说我很迷失。

这里有人以前做过这个或者知道怎么做吗?

我认为以下代码可能是罪魁祸首:

/**
     * Limit rules collection by specific customer group
     *
     * @param int $customerGroupId
     * @return $this
     * @since 100.1.0
     */
    public function addCustomerGroupFilter($customerGroupId)
    {
        $entityInfo = $this->_getAssociatedEntityInfo('customer_group');
        if (!$this->getFlag('is_customer_group_joined')) {
            $this->setFlag('is_customer_group_joined', true);
            $this->getSelect()->join(
                ['customer_group' => $this->getTable($entityInfo['associations_table'])],
                $this->getConnection()
                    ->quoteInto('customer_group.' . $entityInfo['entity_id_field'] . ' = ?', $customerGroupId)
                . ' AND main_table.' . $entityInfo['rule_id_field'] . ' = customer_group.'
                . $entityInfo['rule_id_field'],
                []
            );
        }
        return $this;
    }

我也可能完全错了。

php magento2
1个回答
0
投票

从文件vendor/magento/module-sales-rule/Model/Utility.php检查方法canProcessRule

© www.soinside.com 2019 - 2024. All rights reserved.