Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add virtual category with installer #395

Closed
madonzy opened this issue Apr 18, 2017 · 10 comments
Closed

Add virtual category with installer #395

madonzy opened this issue Apr 18, 2017 · 10 comments
Assignees
Labels

Comments

@madonzy
Copy link

madonzy commented Apr 18, 2017

I want to install virtual category with an installer (InstallData.php). (Only while installing Magento)

Preconditions

Linux debian-8 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) x86_64 GNU/Linux

Magento Version: 2.1.4 CE
ElasticSuite Version : 2.3.4
Environment : default

Steps to reproduce

  1. I added sequence to my module Smile_ElasticsuiteVirtualCategory
  2. php bin/magento setup:install ...

Expected result

All modules installed successfully

Actual result

I have an error:

Attribute with attributeCode "use_name_in_product_search" does not exist. 

If I don't add the sequence, then the category is added but fields is_virtual_category and virtual_category_root aren't set. I add the category like that:

$category = $this->categoryFactory->create();
$category
    ->setName('Test')
    ->setParentId($parentCategory->getId())
    ->setIsActive(true)
    ->setIncludeInMenu(false)
    ->setCustomAttributes([
        'is_virtual_category'   => '1',
        'url_key'               => 'test',
        'virtual_category_root' => $parentCategory->getParentCategory()->getId(),
    ]);

$this->categoryRepository->save($category);
@romainruaud
Copy link
Collaborator

Hello @madonzy

For me this is due to Magento not cleaning the EAV cache when adding an attribute via addAttribute in setups.

Please could you give a try to the PR #397 and tell me if this solves the issue ?

Best regards

@romainruaud romainruaud self-assigned this Apr 19, 2017
@romainruaud
Copy link
Collaborator

I just updated the PR.

I was able to reproduce your bug on a "raw" install from Magento sources when having setup files which were creating categories.

You are right, adding a sequence to elasticsuite modules is not enough, so I added a cleaning of EAV cache manually after creating the attributes, since Magento does not do it when using addAttribute.

Feel free to test it and give us comments.

BR

@madonzy
Copy link
Author

madonzy commented Apr 20, 2017

@romainruaud I've added $this->cacheTypeList->cleanType('eav'); on the very beginning of installation script and nothing changed. The same error.

@romainruaud
Copy link
Collaborator

@madonzy please consider testing the fix by switching to my branch and not implementing your own fix by inspirating with mine.

My branch is working when launching Magento install based on one of our project containing categories creation in Setup files. This was crashing before my fix with the same error as yours. So I think I fixed the point.

Let me know,

@madonzy
Copy link
Author

madonzy commented Apr 20, 2017

@romainruaud how can I switch to "your" branch? What exactly do you mean? Please provide some steps, because I'm not really understand you.

@romainruaud
Copy link
Collaborator

You could do either :

  • require my branch via composer, by doing this : http://stackoverflow.com/a/13500676

  • or just report the modifications I made in this branch to the instance you are testing the install process, by writing directly on the module files, just for testing purposes.

Then try again to run your bin/magento setup:install and tell me if this does solve the issue.

Regards,

@madonzy
Copy link
Author

madonzy commented Apr 20, 2017

@romainruaud Still not clear... What is your branch? What did you do? Where? Is it official fix? maybe I can just update elsticsuite with a composer?

@madonzy
Copy link
Author

madonzy commented Apr 20, 2017

@romainruaud I did second way and it works!! Thank you!!

@romainruaud
Copy link
Collaborator

Fine !

You'll be able to switch back to our 2.3.x branch once @afoucret will have merged this.

Bes regards

@romainruaud
Copy link
Collaborator

Fixed by PR #397 . Please wait for the next minor 2.3 release or feel free to use the 2.3.x branch while waiting for it.

Best regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants