Commit e220abc6 by Ravindra Kanojiya

updated slug same name

1 parent 44372be9
......@@ -37,15 +37,15 @@ const ProductPage = ({ productData, cataloguesData }) => {
{ href: "/", label: "Collections" },
{
href: `/collections/${category}`,
label: category.replace(/-/g, " "),
label: category?.replace(/-/g, " ") || "",
},
{
href: `/collections/${category}/${subCategoryData.slug}`,
label: subCategoryData.title,
href: `/collections/${category}/${subCategoryData?.slug ?? subCategorySlug ?? ""}`,
label: subCategoryData?.title ?? subCategorySlug?.replace(/-/g, " ") ?? "",
},
{
href: router.asPath,
label: productData.title,
label: productData?.title ?? "",
},
];
......@@ -129,9 +129,9 @@ export default ProductPage;
/* ---------- SSR ---------- */
export async function getServerSideProps({ params }) {
try {
const { productSlug } = params;
const { productSlug, subCategory } = params;
const productData = await getCollectionDetailCategoryData(productSlug);
const productData = await getCollectionDetailCategoryData(productSlug, subCategory);
const cataloguesData = await getCataloguesBySlug();
if (!productData || productData.length === 0) {
......
import { fetchFromStrapi } from "./api";
export async function getCollectionDetailCategoryData(productSlug) {
try {
const query = {
filters: {
slug: {
$eq: productSlug,
const POPULATE = {
image: true,
collection_sub_category: {
populate: true,
},
gallery: {
populate: {
image: true,
},
},
aboutInfo: {
populate: true,
},
video: {
populate: {
video: true,
},
},
exploreProducts: {
populate: {
item: {
populate: {
image: true,
},
},
populate: {
image: true,
// isDoorAndPartitionsLayouts:true,
collection_sub_category: {
populate: true,
},
gallery: {
populate: {
image: true,
},
},
productTabs: {
populate: {
companyOverview: {
populate: {
items: {
populate: {
image: true,
},
},
},
aboutInfo: {
populate: true,
},
videoSection: {
populate: {
video: true,
},
video: {
populate: {
video: true,
},
},
aboutInfo: true,
technicalDetails: {
populate: {
image: true,
details: true,
},
exploreProducts: {
populate: {
item: {
populate: {
image: true,
},
},
},
},
gallery: {
populate: {
image: true,
},
productTabs: {
populate: {
companyOverview: {
populate: {
items: {
populate: {
image: true,
},
},
},
},
videoSection: {
populate: {
video: true,
},
},
aboutInfo: true,
technicalDetails: {
populate: {
image: true,
details: true,
},
},
gallery: {
populate: {
image: true,
},
},
},
},
},
},
aboutInfoStone: {
populate: {
aboutInfo: { populate: "*" },
detailsItem: { populate: "*" },
aboutInfoTwo: { populate: "*" },
detailsItemTwo: { populate: "*" },
bottomInfo: { populate: "*" },
video: { populate: "*" },
gallery: {
populate: {
image: true,
},
aboutInfoStone: {
populate: {
aboutInfo: {
populate: "*",
},
detailsItem: {
populate: "*",
},
aboutInfoTwo: {
populate: "*",
},
detailsItemTwo: {
populate: "*",
},
bottomInfo: {
populate: "*",
},
video: {
populate: "*",
},
gallery: {
populate: {
image: true,
},
},
},
},
},
};
export async function getCollectionDetailCategoryData(productSlug, subCategorySlug) {
try {
if (subCategorySlug) {
const scopedQuery = {
filters: {
slug: { $eq: productSlug },
collection_sub_category: {
slug: { $eq: subCategorySlug },
},
},
populate: POPULATE,
};
const scopedResponse = await fetchFromStrapi(
"/api/collection-detail-categories",
scopedQuery,
);
// productTabs:{
// populate: "*",
if (scopedResponse?.data?.length > 0) {
return scopedResponse.data;
}
}
// },
// technicalDetails:{
// populate:"*"
// },
// explore:{
// populate:"*"
// }
const fallbackQuery = {
filters: {
slug: { $eq: productSlug },
},
populate: POPULATE,
};
const response = await fetchFromStrapi(
const fallbackResponse = await fetchFromStrapi(
"/api/collection-detail-categories",
query,
fallbackQuery,
);
return response?.data || [];
return fallbackResponse?.data || [];
} catch (error) {
console.error("Product fetch error:", error);
return [];
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!