enterprise_url_rewrite 테이블 - "inc" 열은 무엇을 저장합니까?
-
29-09-2020 - |
문제
"inc"가 무슨 뜻인지 궁금합니다.내 특별한 경우에는 모든 재작성이 inc=1로 설정되어 있습니다.
mysql> describe enterprise_url_rewrite;
+----------------+----------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+----------------------+------+-----+---------+----------------+
| url_rewrite_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| request_path | varchar(255) | NO | MUL | NULL | |
| target_path | varchar(255) | NO | | NULL | |
| is_system | smallint(5) unsigned | NO | | NULL | |
| guid | varchar(32) | NO | | NULL | |
| identifier | varchar(255) | NO | MUL | NULL | |
| inc | int(10) unsigned | NO | | 1 | |
| value_id | int(10) unsigned | NO | MUL | NULL | |
| store_id | smallint(5) unsigned | NO | | NULL | |
| entity_type | smallint(5) unsigned | NO | | NULL | |
+----------------+----------------------+------+-----+---------+----------------+
10 rows in set (0.00 sec)
감사해요!
해결책
다음은 모두 이 테이블에 저장된 제품 URL에 중점을 두고 있지만 카테고리에도 동일하게 적용됩니다.이것은 제가 디버깅하고 있던 제품을 쉽게 예시하기 위한 것입니다.
이 값이 사용된 것을 찾을 수 있는 곳은 두 군데뿐입니다.
1.카운터 증가
Enterprise_UrlRewrite_Model_Index_Action_Url_Rewrite_RefreshAbstract::_refreshUrlRewrite
해당 메소드에는 URL 재작성을 업데이트하는 쿼리가 있으며 다음과 같은 약간의 PHP 코드가 있습니다.
$insert .= sprintf(' ON DUPLICATE KEY UPDATE %1$s = %1$s + 1',
$this->_getTable('enterprise_urlrewrite/url_rewrite') . '.inc');
이는 다음과 같은 정말 재미있어 보이는 쿼리를 생성하는 데 도움이 됩니다.
INSERT INTO `enterprise_url_rewrite` (`request_path`, `target_path`,
`guid`, `is_system`, `identifier`, `value_id`, `store_id`,
`entity_type`) SELECT `uk`.`value` AS `request_path`,
CONCAT('catalog/product/view/id/', uk.entity_id) AS `target_path`,
'66af826f9f0df53191c06afe93c03159' AS `guid`, 1 AS `is_system`,
`uk`.`value` AS `identifier`, `uk`.`value_id`, `uk`.`store_id`, 3 AS
`entity_type` FROM `catalog_product_entity_url_key` AS `uk` WHERE
(uk.entity_id IN ('19472')) ON DUPLICATE KEY UPDATE
enterprise_url_rewrite.inc = enterprise_url_rewrite.inc + 1
마지막에 주목해야 할 점은 무결성 제약 조건 오류가 있는 경우 카운터가 증가한다는 것입니다.
이 쿼리에 제품이 들어가는 경우, 이 쿼리 후에는 해당 항목이 누락된다는 의미입니다. enterprise_catalog_product_rewrite
.검색을 통해 누락된 제품을 확인하실 수 있습니다 select entity_id, sku from catalog_product_entity where entity_id not in(select product_id from enterprise_catalog_product_rewrite);
.
요청 경로가 이미 존재하기 때문입니다. enterprise_url_rewrite
특정 엔터티 유형/매장에 대해 다음이 표시되어야 합니다. inc
해당 엔터티에 대한 제약 조건 위반이 있는 경우 이 쿼리가 실행될 때마다 숫자가 증가합니다.
이 로직은 추상 클래스에 있으며 이 메서드는 하위 메서드에서 재정의되지 않습니다.
- Changelog (Mview / 업데이트 예정)
- 행(저장 시 업데이트)
- 새로 고침(전체 재색인)
이는 URL에 대한 모든 재색인이 "오류인 경우 카운터 증가"라는 동일한 대체 논리를 갖는다는 것을 의미합니다.
2.증분값 사용
다음 두 가지 호출 모두 parent::_getUrlRewriteSelectSql
Enterprise_UrlRewrite_Model_Index_Action_Url_Rewrite_Redirect_Refresh_Row::_getUrlRewriteSelectSql
Enterprise_UrlRewrite_Model_Index_Action_Url_Rewrite_Redirect_Refresh_Changelog::_getUrlRewriteSelectSql
이는 다음과 같이 정의됩니다.Enterprise_UrlRewrite_Model_Index_Action_Url_Rewrite_Redirect_Refresh::_getUrlRewriteSelectSql
내가 볼 수 있는 유일한 다른 곳은 .inc
데이터베이스의 값입니다.
이들은 기본적으로 insertFromSelect
성명서는 다음과 같이 정말 형편없게 보입니다.
SELECT CONCAT(r.identifier, CASE WHEN ur.inc IS NULL OR `m`.`value` = 1 THEN ''
ELSE CONCAT('-', ur.inc) END) AS `request_path`, `r`.`target_path`,
'65912c647bc5f65fc0f59df5f6477d05' AS `guid`, 0 AS `is_system`,
CONCAT(r.identifier, CASE WHEN ur.inc IS NULL OR `m`.`value` = 1
THEN '' ELSE CONCAT('-', ur.inc) END) AS `identifier`,
`r`.`redirect_id` AS `value_id`, `r`.`store_id`, 1 AS `entity_type`
FROM `enterprise_url_rewrite_redirect` AS `r` LEFT JOIN
enterprise_url_rewrite` AS `ur` ON ur.identifier = r.identifier
AND ur.store_id = r.store_id AND ur.entity_type = 1 LEFT JOIN
`enterprise_index_multiplier` AS `m` ON ur.identifier IS NOT NULL
제가 볼 때 핵심적인 부분은CASE WHEN ur.inc IS NULL OR
중.
값= 1 THEN '' ELSE CONCAT('-', ur.inc) END)
.increment가 null이면 증분 값을 적용하지 마세요. 그렇지 않으면 URL 끝에 연결하세요.이 쿼리는 1단계의 논리에 입력됩니다. _refreshUrlRewrite
그러나 잠재적으로 끝에 숫자가 증가할 수 있습니다.
모두 합쳐지면 중복이 발견될 때 URL 끝에 적용할 번호를 추적하기 위해 이 논리가 적용되는 것 같습니다.