Git Product home page Git Product logo

Comments (4)

pjedrzejewski avatar pjedrzejewski commented on May 22, 2024

Can you check again now? It should be fixed in e0895f0.

from sylius.

cnoa23 avatar cnoa23 commented on May 22, 2024

No, still error while executing insert. I update app completly and make the fix, but the exception is present.

from sylius.

cnoa23 avatar cnoa23 commented on May 22, 2024

Hi, could fix this problem but the changes was made in AssortmentBundle, i comment here because i post here, maybe you can move it to AssortmentBundle issue.
When you create a product normaly, it dispatch 4 events

sylius.product.pre_create
sylius.product.pre_update
sylius.variant.pre_create
sylius.variant.pre_update

And sylius.listener.image_upload is listening this event, when its hear this event it make all about image...

The problem its when you create a product from prototype, any of this event are dispatch, so path in INSERT INTO sylius_variant_image is empty and throw an exception.

To fix it I chage
AssortmentBundle\Controller\PrototypeController, buildAction. When form is POST i call $productController->create (inherit FROM RESOURCE CONTROLLER) , it persis,flush and dispatch event.
I delete the persist and flush directly from the $productController->getManager().

It look so

public function buildAction(Request $request, $id)
{
    $prototype = $this->findOr404(array('id' => $id));
    $productController = $this->getProductController();

    $product = $productController->createNew();

    $this
        ->getBuilder()
        ->build($prototype, $product)
    ;

    $form = $productController->getForm($product);


    if ($request->isMethod('POST') && $form->bind($request)->isValid()) {            

        //$manager = $productController->getManager();
        //$manager->persist($product);
        //$manager->flush();

        $productController->create($product);   

        $productController->setFlash('success', '%resource% has been successfully created.');

        return $productController->redirectTo($product);
    }

    return $productController->renderResponse('build.html', array(
        'prototype' => $prototype,
        'product'   => $product,
        'form'      => $form->createView()
    ));
}

Now when you create a product from prototype and choose a image it work all fine.

Greeting,
Carlos

from sylius.

pjedrzejewski avatar pjedrzejewski commented on May 22, 2024

This is the fix indeed! Thanks for debugging the issue. Can you open a PR for assortment bundle?

Simplest way to do it, is to install vendors with composer install --prefer-source. Then inside vendors/sylius/assortment-bundle... you'll have Sylius assortment bundle repository. You can fork it, add as remote and push your changes there - finally open PR. :) Or you can just fork&clone assortment bundle, make the changes, push, open PR.

I can help you with all that if you want. Thanks!

from sylius.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.