無法將送貨儲存為URL索引鍵

本文提供當您無法針對產品或CMS頁面將送貨儲存為URL索引鍵(例如: /shipping)時問題的因應措施。 當您嘗試儲存URL金鑰時,您會收到一個錯誤,指出URL金鑰是重複的URL。

說明 description

環境

Adobe Commerce (所有部署方法),2.4.x

問題

You cannot save a CMS page with the term shipping in the URL key.

要再現的步驟:

建立 CMS頁面,URL金鑰設為​ shipping

預期結果:

頁面以​ shipping ​儲存為URL金鑰。

實際結果:

發生此錯誤時,您無法儲存:
在URL索引鍵欄位中指定的值會產生已經存在的URL。

原因

送貨是在vendor/magento/module-shipping/etc/frontend/routes.xml中定義的保留字。

<router id="standard">
      <route id="shipping" frontName="shipping">
          <module name="Magento_Shipping" />
      </route>
  </router>

解決方法 resolution

您不能在您的URL金鑰中使用字詞​ shipping,但是您可以使用字詞​ shipping ​搭配其他字母或數字(例如,shipping1 ​和​ shipping2)。

雖然字詞不一定要是​ 送貨+<其他數字或字母> — 只要長度不超過​ 255 ​個字元,字詞可以是任何字串。

執行下列步驟:

  1. 登入Adobe Commerce管理員。

  2. 移至 行銷 > SEO和搜尋 > URL重寫

  3. 按一下 新增URL重寫

  4. 建立URL重寫 下拉式清單中選取 自訂

    1. 輸入要求路徑為​ 送貨

    2. 目標路徑 中,輸入新的URL索引鍵(例如,shipping1)。

    3. 重新導向 下拉式清單中選取

      注意:請求路徑是使用者在瀏覽器中輸入的內容,而目標路徑是它應該重新導向到的位置。)

此外,請避免使用這些標示為​ reserved ​關鍵字的關鍵字,造成出現相同的例外狀況。 使用下列任一關鍵字做為URL索引鍵值將會造成相同的錯誤。

"admin"
"adminAnalytics"
"analytics"
"api"
"backup"
"bulk"
"captcha"
"catalog"
"catalogsearch"
"checkout"
"cms"
"contact"
"cookie"
"customer"
"directory"
"downloadable"
"giftmessage"
"groupedProduct"
"indexer"
"instantpurchase"
"loginascustomer"
"marketplace"
"mui"
"multishipping"
"newsletter"
"oauth"
"paypal"
"persistent"
"productalert"
"releaseNotification"
"reports"
"review"
"robots"
"rss"
"sales"
"search"
"security"
"sendfriend"
"shipping"
"stores"
"swagger"
"swatches"
"tax"
"theme"
"translation"
"vault"
"wishlist"

相關閱讀

recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f