yhrhhhhh / yhr

exam
The Unlicense
0 stars 0 forks source link

Title translation problem under option_type_id #15

Open yhrhhhhh opened 3 months ago

yhrhhhhh commented 3 months ago

由于美国站配置同步主站需求的变更,因此现代码逻辑如下: option1

目前出现的问题: option_id下title的代码处理没有问题,经测试,结果正常。 但是option_type_id下的title在翻译时仅仅翻译了英国站点的title,其他站点没有变化,但我没有改过翻译部分的代码,只在增加了对customer option 的title是否变更做出了判断,并且经过梳理代码逻辑依然不知道该bug发生的原因。 数据库表显示:(其中store_id=17为英国站点,只有该站点发生了同步,原本预期应该是所有站点都同步) image

参考PR:https://github.com/kyo-ye/fridaypartsv2/pull/52

1.不是缓存问题,已经通过清理缓存尝试,无果 2.通过debug获取数据,数据结果正确 image image image

因此,推测问题出在updateOptionTypeTitles方法内的。

经排查:锁定代码

 // 获取所有的 store_id!=0 的 title
        $select = $this->connection->select()
            ->from(['cpott' => $this->resource->getTableName('catalog_product_option_type_title')], [
                'option_type_id',
                'store_id'
            ])
            ->where('option_type_id IN (?)', $optionTypeIds)
            ->where('store_id != ?', self::GLOBAL_STORE);
        $optionTypeTitleStoreIds = $this->connection->fetchPairs($select);

就dubug结果知道:预期查询结果是所有store_id!=0的站点的store_id,但是实际查询结果为17,也就是只有英国站点的store_id。 image

代码:feature/task_333_1 原因: fetchPairs 会覆盖重复的键(即最后的值会覆盖之前相同键的值