sonata-project / ecommerce

[Abandoned] E-Commerce solution provided by Sonata
https://sonata-project.org
MIT License
165 stars 139 forks source link

Problem with Category menu #431

Closed GothicBezimienny closed 7 years ago

GothicBezimienny commented 7 years ago

Hello i have problem, installed sonata with all bundles for e-commerce, and now try configur to working smooth. But, when i open page /shop/catalog/ have this issue :


'SELECT p0_.enabled AS enabled_0, p0_.main AS main_1, p0_.updated_at AS updated_at_2, p0_.created_at
AS created_at_3, p0_.id AS id_4, c1_.name AS name_5, c1_.enabled AS enabled_6, c1_.slug AS slug_7,
c1_.description AS description_8, c1_.position AS position_9, c1_.created_at AS created_at_10,
c1_.updated_at AS updated_at_11, c1_.id AS id_12, p0_.product_id AS product_id_13, p0_.category_id AS
category_id_14, c1_.parent_id AS parent_id_15, c1_.context AS context_16, c1_.media_id AS media_id_17
FROM product__product_category p0_ LEFT JOIN classification__category c1_ ON p0_.category_id = c1_.id
WHERE p0_.enabled = 1 AND c1_.enabled = 1 GROUP BY c1_.id':

SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #2 of SELECT list is not in GROUP BY
 clause and contains nonaggregated column 'storage.p0_.main' which is not functionally dependent on 
columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by") in 
SonataProductBundle:Catalog:layout.html.twig at line `26.`

When i delete this block:
{% block product_category %}
            {{ sonata_block_render({'type': 'sonata.product.block.categories_menu', 'settings': {
                'current_uri': app.request.requestUri,
                'extra_cache_keys': {
                    'block_id':    'sonata.product.block.categories_menu',
                    'updated_at':  'now',
                },
                'ttl': 60
            }}) }}
        {% endblock `%}

from layout.html.twig web working fine but withotu category menu. 

my configs: 

```sonata_product:
    products:
        service_id:
            provider: service_id.type
            manager: service_id.manager
    class:
            product:              Application\Sonata\ProductBundle\Entity\Product
            product_category:     Application\Sonata\ProductBundle\Entity\ProductCategory
            product_collection:   Application\Sonata\ProductBundle\Entity\ProductCollection
            category:             Application\Sonata\ClassificationBundle\Entity\Category
            collection:           Application\Sonata\ClassificationBundle\Entity\Collection
            delivery:             Application\Sonata\ProductBundle\Entity\Delivery
            gallery:              Application\Sonata\MediaBundle\Entity\Gallery

sonata_block:
    default_contexts: [cms]
    context_manager: sonata.page.block.context_manager
    blocks:
        sonata.user.block.menu:    # used to display the menu in profile pages
        sonata.user.block.account: # used to display menu option (login option)
        sonata.block.service.text: # used to if you plan to use Sonata user routes
        sonata.block.service.rss: # used to if you plan to use Sonata user routes
        sonata.admin.block.admin_list:
            contexts: [admin]
        sonata.product.block.categories_menu:

 "require": {
        "php": ">=5.3.9",
        "symfony/symfony": "2.8.*",
        "doctrine/orm": "^2.4.8",
        "doctrine/doctrine-bundle": "~1.4",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "sensio/distribution-bundle": "~5.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "~2.0",
        "sonata-project/admin-bundle": "3.x-dev",
        "sonata-project/doctrine-orm-admin-bundle": "3.x-dev",
        "friendsofsymfony/user-bundle": "1.3.x-dev",
        "sonata-project/user-bundle": "3.x-dev",
        "sonata-project/google-authenticator": "1.x-dev",
        "nelmio/api-doc-bundle": "^2.13",
        "twig/twig": "1.28.2",
        "sonata-project/classification-bundle": "^3.0",
        "sonata-project/cache-bundle": "^2.3",
        "sonata-project/seo-bundle": "^2.1",
        "sonata-project/notification-bundle": "^3.1",
        "sonata-project/page-bundle": "^3.4",
        "sonata-project/media-bundle": "^3.5",
        "sonata-project/ecommerce": "dev-master",
        "sonata-project/intl-bundle": "2.x-dev",
        "twbs/bootstrap": "^3.3",
        "craue/formflow-bundle": "^2.1",
        "sonata-project/formatter-bundle": "^3.2"
azlotnikov commented 7 years ago

What db driver do you use? SF version? Please, provide environment and bundles versions info.

GothicBezimienny commented 7 years ago

My sf its 2.8.

azlotnikov commented 7 years ago

I suppose you should turn off sql_mode=only_full_group_by

GothicBezimienny commented 7 years ago

Oh thanks, so much i spand on this so much time.

GothicBezimienny commented 7 years ago

If think ins't closed i wanna as for other problem if i can. I sorry if i shoudl use new issue thema for new ask. As an user when i want click on procut and show details i have this error:


Controller "Application\Sonata\ProductBundle\Controller\ProductController::viewAction()" 
requires that you provide a value for the "$product" argument (because there is no 
default value or because there is a non optional argument after this one).
`

my controler is extend BaseProductControler nad viewAction looks that:

/**
     * @param $product
     *
     * @throws NotFoundHttpException
     *
     * @return Response
     */
public function viewAction($product)
    {
        var_dump($product);
        if (!is_object($product)) {
            throw new NotFoundHttpException('invalid product instance');
        }

        $provider = $this->get('sonata.product.pool')->getProvider($product);

        $formBuilder = $this->get('form.factory')->createNamedBuilder('add_basket', 'form', null, array('data_class' => $this->container->getParameter('sonata.basket.basket_element.class'), 'csrf_protection' => false));
        $provider->defineAddBasketForm($product, $formBuilder);

        $form = $formBuilder->getForm()->createView();

        $currency = $this->get('sonata.price.currency.detector')->getCurrency();

        // Add twitter/FB metadata
        $this->updateSeoMeta($product, $currency);

        return $this->render(
            sprintf('%s:view.html.twig', $provider->getBaseControllerName()),
            array(
                'provider' => $provider,
                'product' => $product,
                'cheapest_variation' => $provider->getCheapestEnabledVariation($product),
                'currency' => $currency,
                'form' => $form,
            )
        );
    }

and view:

{% extends 'SonataProductBundle:Product:view.html.twig' %}
{% block product_title %}{{ product.name }}{% endblock %}
{% block product_description %}
    {{ product.description|raw }}
{% endblock %}
{% block product_gallery %}Product gallery{% endblock %}
azlotnikov commented 7 years ago

Please, create a separate issue (and close this), because this is definitely a bug (I can confirm it). I'll give you a temporary solution there.