0

I've created a store using this code.

/**
 * @param $groupId
 * @param $websiteId
 * @param $storeName
 * @param $storeCode
 * @return Group
 * @throws Exception
 */
private function createOrUpdateGroup($groupId, $websiteId, $storeName, $storeCode)
{
    $group = $this->groupFactory->create();
    if($groupId){
        $group->load($groupId);
    }
    $group->setWebsiteId($websiteId);
    $group->setName($storeName);
    $group->setCode($storeCode);
    $group->setDefaultStoreId(2);
    $group->save();

    return $group;
}

/**
 * @param $group
 * @param $websiteId
 * @param $storeViewName
 * @param $storeViewCode
 * @param $data
 * @return Store
 * @throws LocalizedException
 */
private function createOrUpdateStore($group, $websiteId, $storeViewName, $storeViewCode, $data)
{
    $store = $this->storeFactory->create();
    if($group->getId() && $group->getDefaultStoreId()){
        $store->load($group->getDefaultStoreId());
    }


    $store->setName($storeViewName . ' - Store View');
    $store->setCode($storeViewCode);
    $store->setWebsiteId($websiteId);
    $store->setGroupId($group->getId());
    $store->setSortOrder($data['sort_order']);
    $store->setIsActive($data['is_active']);
    $store->save();

    return $store;
}

But as some information were missing I deleted this store in the database going in the tables store / store_group , but it looks like I forgot some datas that might be generated under the hood, so now when I try to create the create the store again, I'm getting this error :

Installing schema... SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'stores-2-web/unsecure/base_url' for key 'CORE_CONFIG_DATA_SCOPE_SCOPE_ID_PATH', query was: INSERT INTO core_config_data (scope, scope_id, path, value) VALUES (?, ?, ?, ?)

I can't find this stores-2-web in my table, so my question is :

Is there a way I can see the final full sql request in order to be able to delete the row which seems to be already existing ? Oy much better, do you know what I need to delete to really purge these dead datas ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.