Search in sources :

Example 6 with Category

use of org.broadleafcommerce.core.catalog.domain.Category in project BroadleafCommerce by BroadleafCommerce.

the class OrderBaseTest method setUpCartWithActiveSku.

public Order setUpCartWithActiveSku() throws AddToCartException {
    Customer customer = customerService.saveCustomer(createNamedCustomer());
    Order order = orderService.createNewCartForCustomer(customer);
    Product newProduct = addTestProduct("Plastic Crate Active", "Crates");
    Category newCategory = newProduct.getDefaultCategory();
    order = orderService.addItem(order.getId(), new OrderItemRequestDTO(newProduct.getId(), newProduct.getDefaultSku().getId(), newCategory.getId(), 1), true);
    return order;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Category(org.broadleafcommerce.core.catalog.domain.Category) OrderItemRequestDTO(org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO) Customer(org.broadleafcommerce.profile.core.domain.Customer) Product(org.broadleafcommerce.core.catalog.domain.Product)

Example 7 with Category

use of org.broadleafcommerce.core.catalog.domain.Category in project BroadleafCommerce by BroadleafCommerce.

the class OrderBaseTest method setUpCartWithInactiveSku.

public Order setUpCartWithInactiveSku() throws AddToCartException {
    Customer customer = customerService.saveCustomer(createNamedCustomer());
    Order order = orderService.createNewCartForCustomer(customer);
    Product newProduct = addTestProduct("Plastic Crate Should Be Inactive", "Crates");
    Category newCategory = newProduct.getDefaultCategory();
    order = orderService.addItem(order.getId(), new OrderItemRequestDTO(newProduct.getId(), newProduct.getDefaultSku().getId(), newCategory.getId(), 1), true);
    // Make the SKU inactive
    newProduct.getDefaultSku().setActiveEndDate(DateUtils.addDays(new Date(), -1));
    catalogService.saveSku(newProduct.getDefaultSku());
    return order;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Category(org.broadleafcommerce.core.catalog.domain.Category) OrderItemRequestDTO(org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO) Customer(org.broadleafcommerce.profile.core.domain.Customer) Product(org.broadleafcommerce.core.catalog.domain.Product) Date(java.util.Date)

Example 8 with Category

use of org.broadleafcommerce.core.catalog.domain.Category in project BroadleafCommerce by BroadleafCommerce.

the class TranslationServiceTest method testTranslation.

@Test(groups = { "testTranslation" })
@Transactional
public void testTranslation() throws Exception {
    Category category = new CategoryImpl();
    category.setName("Translation");
    category = catalogService.saveCategory(category);
    translationService.save(TranslatedEntity.CATEGORY.getType(), String.valueOf(category.getId()), "name", "es_MX", "es_MX");
    translationService.save(TranslatedEntity.CATEGORY.getType(), String.valueOf(category.getId()), "name", "es", "es");
    String specificTranslation = translationService.getTranslatedValue(category, "name", new Locale("es", "MX"));
    Assert.assertEquals(specificTranslation, "es_MX");
    String generalTranslation = translationService.getTranslatedValue(category, "name", Locale.forLanguageTag("es"));
    Assert.assertEquals(generalTranslation, "es");
    // test a second time to go through cache
    specificTranslation = translationService.getTranslatedValue(category, "name", new Locale("es", "MX"));
    Assert.assertEquals(specificTranslation, "es_MX");
    generalTranslation = translationService.getTranslatedValue(category, "name", Locale.forLanguageTag("es"));
    Assert.assertEquals(generalTranslation, "es");
}
Also used : CategoryImpl(org.broadleafcommerce.core.catalog.domain.CategoryImpl) Locale(java.util.Locale) Category(org.broadleafcommerce.core.catalog.domain.Category) BaseTest(org.broadleafcommerce.test.BaseTest) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with Category

use of org.broadleafcommerce.core.catalog.domain.Category in project BroadleafCommerce by BroadleafCommerce.

the class CategoryDaoDataProvider method provideBasicCategory.

@DataProvider(name = "basicCategory")
public static Object[][] provideBasicCategory() {
    Category category = new CategoryImpl();
    category.setName("Yuban");
    category.setDescription("Yuban");
    category.setId(1001L);
    return new Object[][] { { category } };
}
Also used : CategoryImpl(org.broadleafcommerce.core.catalog.domain.CategoryImpl) Category(org.broadleafcommerce.core.catalog.domain.Category) DataProvider(org.testng.annotations.DataProvider)

Example 10 with Category

use of org.broadleafcommerce.core.catalog.domain.Category in project BroadleafCommerce by BroadleafCommerce.

the class CategoryParentCategoryFieldPersistenceProvider method checkDirtyState.

protected boolean checkDirtyState(Category instance, Long checkValue) {
    boolean dirty = !(instance == null && checkValue == null) && (instance == null || checkValue == null);
    if (!dirty) {
        Long value = null;
        Category category = getDefaultCategory(instance);
        if (category != null) {
            value = category.getId();
        }
        dirty = value == null || !value.equals(checkValue);
    }
    return dirty;
}
Also used : Category(org.broadleafcommerce.core.catalog.domain.Category)

Aggregations

Category (org.broadleafcommerce.core.catalog.domain.Category)49 Product (org.broadleafcommerce.core.catalog.domain.Product)18 Sku (org.broadleafcommerce.core.catalog.domain.Sku)13 CategoryImpl (org.broadleafcommerce.core.catalog.domain.CategoryImpl)10 Order (org.broadleafcommerce.core.order.domain.Order)8 ExtensionResultStatusType (org.broadleafcommerce.common.extension.ExtensionResultStatusType)7 CategoryProductXref (org.broadleafcommerce.core.catalog.domain.CategoryProductXref)7 ProductImpl (org.broadleafcommerce.core.catalog.domain.ProductImpl)7 SkuImpl (org.broadleafcommerce.core.catalog.domain.SkuImpl)7 ArrayList (java.util.ArrayList)6 CategoryProductXrefImpl (org.broadleafcommerce.core.catalog.domain.CategoryProductXrefImpl)6 CategoryXref (org.broadleafcommerce.core.catalog.domain.CategoryXref)6 Money (org.broadleafcommerce.common.money.Money)5 DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)5 Customer (org.broadleafcommerce.profile.core.domain.Customer)5 ProductBundle (org.broadleafcommerce.core.catalog.domain.ProductBundle)4 BundleOrderItem (org.broadleafcommerce.core.order.domain.BundleOrderItem)4 Calendar (java.util.Calendar)3 ServiceException (org.broadleafcommerce.common.exception.ServiceException)3 ExtensionResultHolder (org.broadleafcommerce.common.extension.ExtensionResultHolder)3