Oracle Commerce Cloud’s transition from the Classic Framework to the Open Storefront Framework (OSF) signifies a pivotal shift towards more flexible, efficient, and scalable e-commerce solutions. The OSF not only embraces modern web development paradigms but also enhances site performance and enriches user experiences with its API-first approach. This technical guide is tailored to demystify the migration process, supplemented with real-world examples and sample code, including the migration of five common widgets to the OSF.
Why Opt for the Open Storefront Framework?
Transitioning to OSF brings numerous advantages:
- Adoption of Modern Development Technologies: Leveraging frameworks like React, Vue.js, or Angular for creating dynamic and responsive user interfaces.
- Improved Performance: Enhanced loading times and interactive experiences through modern web technologies.
- Flexibility and Customization: Easier customization and modular architecture adapt to business needs more seamlessly.
- Enhanced Developer Experience: Better development tools and practices, including hot module replacement and comprehensive debugging tools.
- API-Driven Interactions: Facilitates a decoupled architecture, allowing for more robust integration and scalability options.
Initial Steps for Migration
1. Evaluate Current Implementation
- Catalog Customizations: Document every customization in your Classic Framework setup, including widgets, layouts, and integrations.
- Understand OSF Capabilities: Familiarize yourself with the features and limitations of OSF to ensure compatibility with your requirements.
2. Prepare Your Development Environment
- Ensure Node.js and npm are installed.
- Clone the OSF starter pack and install dependencies:
git clone https://github.com/oracle-commerce-cloud/osf-starter-pack.git
cd osf-starter-pack
npm install
3. Design Your Migration Approach
- Migration Strategy: Decide whether to adopt a phased approach or a full migration.
- Widget Conversion Planning: Identify how each Classic widget will be represented in OSF.
Migrating Widgets to OSF
Widget Migration Examples
1. Featured Products Widget
Classic: A combination of HTML, CSS, and Knockout.js.
OSF: A React component fetching featured products through Oracle’s REST APIs.
Sample Code:
import React, { useEffect, useState } from 'react';
const FeaturedProducts = () => {
const [products, setProducts] = useState([]);
useEffect(() => {
fetch('/ccstore/v1/products?category=featured')
.then(response => response.json())
.then(data => setProducts(data.items));
}, []);
return (
<div className="featured-products">
{products.map(product => (
<div key={product.id} className="product">
<h3>{product.name}</h3>
<p>{product.description}</p>
<p>Price: {product.price}</p>
</div>
))}
</div>
);
};
export default FeaturedProducts;
2. Search Bar Widget
Classic: HTML form with Knockout.js bindings for search functionality.
OSF: A React component utilizing Oracle’s API for search queries.
Sample Code:
import React, { useState } from 'react';
const SearchBar = () => {
const [query, setQuery] = useState('');
const handleSearch = (event) => {
event.preventDefault();
fetch(`/ccstore/v1/search?query=${query}`)
.then(response => response.json())
.then(data => console.log(data));
};
return (
<form onSubmit={handleSearch}>
<input
type="text"
value={query}
onChange={e => setQuery(e.target.value)}
placeholder="Search products..."
/>
<button type="submit">Search</button>
</form>
);
};
export default SearchBar;
3. Product Carousel Widget
Classic: Custom JavaScript and Knockout.js for a rotating carousel of products.
OSF: A Vue.js component that dynamically displays a carousel of products fetched from the API.
Sample Code:
<template>
<div class="product-carousel">
<!-- Carousel implementation -->
</div>
</template>
<script>
export default {
data() {
return {
products: [],
};
},
mounted() {
fetch('/ccstore/v1/products?category=newArrivals')
.then(response => response.json())
.then(data => {
this.products = data.items;
});
},
};
</script>
4. Navigation Menu Widget
Classic: HTML list elements with Knockout.js for dynamic menu building.
OSF: A React component that builds a navigation menu based on a REST API call to fetch categories.
Sample Code:
import React, { useEffect, useState } from 'react';
const NavigationMenu = () => {
const [categories, setCategories] = useState([]);
useEffect(() => {
fetch('/ccstore/v1/categories')
.then(response => response.json())
.then(data => set
Categories(data.items));
}, []);
return (
<nav>
<ul>
{categories.map(category => (
<li key={category.id}>{category.displayName}</li>
))}
</ul>
</nav>
);
};
export default NavigationMenu;
5. Customer Reviews Widget
Classic: A mix of HTML, CSS, and JavaScript for displaying product reviews.
OSF: A Vue.js component that fetches and displays reviews for a product.
Sample Code:
<template>
<div class="customer-reviews">
<!-- Reviews display -->
</div>
</template>
<script>
export default {
props: ['productId'],
data() {
return {
reviews: [],
};
},
mounted() {
fetch(`/ccstore/v1/products/${this.productId}/reviews`)
.then(response => response.json())
.then(data => {
this.reviews = data.items;
});
},
};
</script>
Finalizing the Migration
After migrating your widgets, thoroughly test your application to ensure all functionalities work as expected in the OSF environment. Pay special attention to performance, SEO, and user experience to leverage the full capabilities of Oracle Commerce Cloud’s Open Storefront Framework.
This migration exemplifies the shift towards a more modular, performant, and scalable e-commerce platform. By embracing the Open Storefront Framework, businesses can achieve faster time-to-market, improved site performance, and a better overall user experience, ensuring they stay ahead in the competitive digital commerce landscape.