วิธี Reindex ข้อมูลใน Magento 2

ในเว็บที่ทำจาก Magento 2 เวลาที่เจ้าของเว็บมีการอัพเดทข้อมูลสินค้า หรือออกโปรโมชั่น ข้อมูลอาจจะไม่ได้อัพเดททันที เพราะข้อมูลใหม่นั้นยังไม่ได้ index ข้อมูลเข้าไปใน Database บทความนี้จะแนะนำการ Reindex ข้อมูลเว็บด้วยตัวเอง

โปรแกรมที่ต้องใช้

  • Mac OSX : โปรแกรม Terminal ที่ติดมากับเครื่อง หรือ โปรแกรม Terminus
  • Windows : โปรแกรม Terminus
    โปรแกรม Terminus โหลดได้ที่นี่ครับ https://termius.com

วิธีการ Index ข้อมูลผ่านโปรแกรม Terminal หรือ Terminus

  • เปิดโปรแกรม terminal ขึ้นมา แล้วพิมพ์ ssh youruser@ip  เช่น user สำหรับเข้า SSH ของคุณคือ dussthai ส่วน ip คือ 123.456.789.101 ก็ให้พิมพ์ ssh [email protected] แล้ว enter (จบทุกคำสั่งให้กด enter นะครับ)
  • ระบบจะให้ใส่ password ให้ใส่ password แล้ว enter
    ต่อมาให้พิมพ์ cd webapps/user  ในที่นี้ user คือ dussthai ก็ให้พิมพ์ cd webapps/dussthai แล้ว enter
  • คำสั่งสุดท้าย พิมพ์ php -dmemory_limit=-1 bin/magento indexer:reindex แล้ว enter ก็เสร็จการ index ข้อมูลครับ

ในโปรแกรม Terminus ใน windows ก็ใช้คำสั่งเดียวกันครับ

สรุป พิมพ์แค่ 3 คำสั่งดังนี้

  • ssh [email protected]
  • cd webapps/dussthai
  • php -dmemory_limit=-1 bin/magento indexer:reindex